X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fsimple.el;h=f198f8eae2a3fa9d490f1107d685a5ca92034913;hb=cc952c87134f98975102ee428e3c3a9cdb012a7b;hp=cf2652a22c730102c1681c956ba0974f67d3aa3e;hpb=f52a96980ed9280f8f906a20d4b899dc0b027644;p=chise%2Fxemacs-chise.git- diff --git a/lisp/simple.el b/lisp/simple.el index cf2652a..f198f8e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -719,9 +719,18 @@ BUFFER defaults to the current buffer." (message "Line %d" buffer-line))))))) (setq zmacs-region-stays t)) -;;; Bob Weiner, Altrasoft, 02/12/1998 -;;; Added the 3rd arg in `count-lines' to conditionalize the counting of -;;; collapsed lines. +;; 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))))) + (defun count-lines (start end &optional ignore-invisible-lines-flag) "Return number of lines between START and END. This is usually the number of newlines between them, @@ -729,7 +738,13 @@ 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. With optional IGNORE-INVISIBLE-LINES-FLAG non-nil, lines collapsed with -selective-display are excluded from the line count." +selective-display are excluded from the line count. + +NOTE: The expression to return the current line number is not obvious: + +(1+ (count-lines 1 (point-at-bol))) + +See also `line-number'." (save-excursion (save-restriction (narrow-to-region start end) @@ -2001,6 +2016,17 @@ is nil. If BUFFER is nil, the current buffer is assumed." (beginning-of-buffer nil) (end-of-buffer nil)))) +(defun scroll-up-one () + "Scroll text of current window upward one line. +On attempt to scroll past end of buffer, `end-of-buffer' is signaled. +On attempt to scroll past beginning of buffer, `beginning-of-buffer' is +signaled. + +If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer +boundaries do not cause an error to be signaled." + (interactive "_") + (scroll-up-command 1)) + (defun scroll-up-command (&optional n) "Scroll text of current window upward ARG lines; or near full screen if no ARG. A near full screen is `next-screen-context-lines' less than a full screen. @@ -2020,6 +2046,17 @@ boundaries do not cause an error to be signaled." (beginning-of-buffer nil) (end-of-buffer nil)))) +(defun scroll-down-one () + "Scroll text of current window downward one line. +On attempt to scroll past end of buffer, `end-of-buffer' is signaled. +On attempt to scroll past beginning of buffer, `beginning-of-buffer' is +signaled. + +If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer +boundaries do not cause an error to be signaled." + (interactive "_") + (scroll-down-command 1)) + (defun scroll-down-command (&optional n) "Scroll text of current window downward ARG lines; or near full screen if no ARG. A near full screen is `next-screen-context-lines' less than a full screen.