Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 5914:bd4d2c8ef9cc
Use the existing C-level line number cache within #'line-number.
src/ChangeLog addition:
2015-05-15 Aidan Kehoe <kehoea@parhasard.net>
* buffer.c:
* buffer.c (Fline_number): New C implementation, using the line
number cache of line-number.c, with a new optional BUFFER
argument.
* buffer.c (syms_of_buffer):
Make it available to Lisp.
* line-number.c (buffer_line_number):
New argument, RESPECT-NARROWING, describing whether to count from
the beginning of the visible region or from the beginning of the
buffer.
* line-number.h:
* line-number.h (buffer_line_number): Update its declaration.
* redisplay.c (window_line_number): Call it with the new argument.
lisp/ChangeLog addition:
2015-05-15 Aidan Kehoe <kehoea@parhasard.net>
* simple.el:
* simple.el (line-number): Moved to buffer.c; we have an existing
line number cache in C, it's a shame not to have it available.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 15 May 2015 18:11:47 +0100 |
parents | c8bbb32fe124 |
children |
comparison
equal
deleted
inserted
replaced
5913:1b2fdcc3cc5c | 5914:bd4d2c8ef9cc |
---|---|
807 (t | 807 (t |
808 ;; give a basic line count | 808 ;; give a basic line count |
809 (message "Line %d" buffer-line))))))) | 809 (message "Line %d" buffer-line))))))) |
810 (setq zmacs-region-stays t)) | 810 (setq zmacs-region-stays t)) |
811 | 811 |
812 ;; new in XEmacs 21.2 (not in FSF). | 812 ;; FSF 22.0.50.1 (CVS) version of #'line-number. |
813 (defun line-number (&optional pos respect-narrowing) | |
814 "Return the line number of POS (defaults to point). | |
815 If RESPECT-NARROWING is non-nil, then the narrowed line number is returned; | |
816 otherwise, the absolute line number is returned. The returned line can always | |
817 be given to `goto-line' to get back to the current line." | |
818 (if (and pos (/= pos (point))) | |
819 (save-excursion | |
820 (goto-char pos) | |
821 (line-number nil respect-narrowing)) | |
822 (1+ (count-lines (if respect-narrowing (point-min) 1) (point-at-bol))))) | |
823 | |
824 ;; FSF 22.0.50.1 (CVS) version of above. | |
825 (defun line-number-at-pos (&optional pos) | 813 (defun line-number-at-pos (&optional pos) |
826 (line-number pos t)) | 814 (line-number pos t)) |
827 | 815 |
828 (defun count-lines (start end &optional ignore-invisible-lines-flag) | 816 (defun count-lines (start end &optional ignore-invisible-lines-flag) |
829 "Return number of lines between START and END. | 817 "Return number of lines between START and END. |