Created
October 27, 2012 14:29
-
-
Save jorgenschaefer/3964871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; This is from simple.el of Bzr-110657. Looks normal? Please take a | |
| ;; look at the second if statement. What's the condition, the | |
| ;; consequent, and the alternative? Once you thought about that, count | |
| ;; parens. (Or paste it over to another buffer and actually let Emacs | |
| ;; indent it.) | |
| (defun count-lines (start end) | |
| "Return number of lines between START and END. | |
| This is usually the number of newlines between them, | |
| but can be one more if START is not equal to END | |
| and the greater of them is not at the start of a line." | |
| (save-excursion | |
| (save-restriction | |
| (narrow-to-region start end) | |
| (goto-char (point-min)) | |
| (if (eq selective-display t) | |
| (save-match-data | |
| (let ((done 0)) | |
| (while (re-search-forward "[\n\C-m]" nil t 40) | |
| (setq done (+ 40 done))) | |
| (while (re-search-forward "[\n\C-m]" nil t 1) | |
| (setq done (+ 1 done))) | |
| (goto-char (point-max)) | |
| (if (and (/= start end) | |
| (not (bolp))) | |
| (1+ done) | |
| done))) | |
| (- (buffer-size) (forward-line (buffer-size))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment