# HG changeset patch # User Stefan Monnier # Date 1186602295 0 # Node ID 81f6622e1040eec6297bf8fe031e761c66da7667 # Parent 3db577f2c6a5b050ce5c2e4158435033b28bbbd4 (Man-next-section): Make sure we do not move backward. diff -r 3db577f2c6a5 -r 81f6622e1040 lisp/man.el --- a/lisp/man.el Wed Aug 08 16:37:46 2007 +0000 +++ b/lisp/man.el Wed Aug 08 19:44:55 2007 +0000 @@ -64,7 +64,7 @@ ;; ========== Features ========== ;; + Runs "man" in the background and pipes the results through a ;; series of sed and awk scripts so that all retrieving and cleaning -;; is done in the background. The cleaning commands are configurable. +;; is done in the background. The cleaning commands are configurable. ;; + Syntax is the same as Un*x man ;; + Functionality is the same as Un*x man, including "man -k" and ;; "man
", etc. @@ -1291,14 +1291,18 @@ (defun Man-next-section (n) "Move point to Nth next section (default 1)." (interactive "p") - (let ((case-fold-search nil)) + (let ((case-fold-search nil) + (start (point))) (if (looking-at Man-heading-regexp) (forward-line 1)) (if (re-search-forward Man-heading-regexp (point-max) t n) (beginning-of-line) (goto-char (point-max)) ;; The last line doesn't belong to any section. - (forward-line -1)))) + (forward-line -1)) + ;; But don't move back from the starting point (can happen if `start' + ;; is somewhere on the last line). + (if (< (point) start) (goto-char start)))) (defun Man-previous-section (n) "Move point to Nth previous section (default 1)."