diff lisp/simple.el @ 5842:9e5f3a0d4e66

Add `noerror' optional argument to `live-move'. 2014-12-31 Michael Sperber <mike@xemacs.org> * simple.el (line-move): Add `noerror' optional argument, as in GNU Emacs.
author Mike Sperber <sperber@deinprogramm.de>
date Sat, 03 Jan 2015 16:24:56 +0100
parents b79e1e02bf01
children ccb0cff115d2
line wrap: on
line diff
--- a/lisp/simple.el	Fri Dec 19 15:01:46 2014 -0700
+++ b/lisp/simple.el	Sat Jan 03 16:24:56 2015 +0100
@@ -2441,7 +2441,7 @@
 
 ;; This is the guts of next-line and previous-line.
 ;; Count says how many lines to move.
-(defun line-move (count)
+(defun line-move (count &optional noerror)
   ;; Don't run any point-motion hooks, and disregard intangibility,
   ;; for intermediate positions.
   (let ((inhibit-point-motion-hooks t)
@@ -2470,14 +2470,16 @@
 			     (zerop (forward-line 1)))
 		    (and (zerop (forward-line count))
 			 (bolp)))
-		  (signal (if (< count 0)
-			      'beginning-of-buffer
-			    'end-of-buffer)
-			  nil))
+		  (if (not noerror)
+		      (signal (if (< count 0)
+				  'beginning-of-buffer
+				'end-of-buffer)
+			      nil)))
 	    ;; Move by count lines, but ignore invisible ones.
 	    (while (> count 0)
 	      (end-of-line)
 	      (and (zerop (vertical-motion 1))
+		   (not noerror)
 		   (signal 'end-of-buffer nil))
 	      ;; If the following character is currently invisible,
 	      ;; skip all characters with that same `invisible' property value.
@@ -2495,6 +2497,7 @@
 	    (while (< count 0)
 	      (beginning-of-line)
 	      (and (zerop (vertical-motion -1))
+		   (not noerror)
 		   (signal 'beginning-of-buffer nil))
 	      (while (and (not (bobp))
 			  (let ((prop