[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Counting SLOC in Emacs
From: |
Stefan Monnier |
Subject: |
Re: Counting SLOC in Emacs |
Date: |
Fri, 28 Nov 2014 09:04:25 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> (save-excursion
> (save-restriction
> (narrow-to-region beg end)
> (goto-char (point-min))
> (let ((count 0))
> (while (not (eobp))
I'd use
(save-excursion
(goto-char beg
(let ((count 0))
(while (< (point) end)
since narrowing can have all kinds of weird effects.
> (message "SLOC in %s: %s."
> (if (use-region-p) "region" "buffer")
> count)))))
And don't re-call use-region-p here, in the off-chance that it returns
something else than in the first call. E.g. you can use (if (and (=
beg (point-min)) (= end (point-max))) "buffer" "region") instead.
Stefan
- Counting SLOC in Emacs, Marcin Borkowski, 2014/11/28
- Re: Counting SLOC in Emacs, Marcin Borkowski, 2014/11/28
- Re: Counting SLOC in Emacs,
Stefan Monnier <=
- Re: Counting SLOC in Emacs, Marcin Borkowski, 2014/11/28
- Re: Counting SLOC in Emacs, Stefan Monnier, 2014/11/28
- Re: Counting SLOC in Emacs, Marcin Borkowski, 2014/11/28
- Re: Counting SLOC in Emacs, Thien-Thi Nguyen, 2014/11/29
- Re: Counting SLOC in Emacs, Marcin Borkowski, 2014/11/29
- Re: Counting SLOC in Emacs, Grant Rettke, 2014/11/29
Re: Counting SLOC in Emacs, Phillip Lord, 2014/11/28