diff 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
line wrap: on
line diff
--- a/lisp/simple.el	Mon May 11 18:04:58 2015 +0100
+++ b/lisp/simple.el	Fri May 15 18:11:47 2015 +0100
@@ -809,19 +809,7 @@
 		 (message "Line %d" buffer-line)))))))
   (setq zmacs-region-stays t))
 
-;; new in XEmacs 21.2 (not in FSF).
-(defun line-number (&optional pos respect-narrowing)
-  "Return the line number of POS (defaults to point).
-If RESPECT-NARROWING is non-nil, then the narrowed line number is returned;
-otherwise, the absolute line number is returned.  The returned line can always
-be given to `goto-line' to get back to the current line."
-  (if (and pos (/= pos (point)))
-      (save-excursion
-	(goto-char pos)
-	(line-number nil respect-narrowing))
-    (1+ (count-lines (if respect-narrowing (point-min) 1) (point-at-bol)))))
-
-;; FSF 22.0.50.1 (CVS) version of above.
+;; FSF 22.0.50.1 (CVS) version of #'line-number.
 (defun line-number-at-pos (&optional pos)
   (line-number pos t))