changeset 18498:78a8721a690c

(forward-visible-line): Handle 0 arg correctly.
author Richard M. Stallman <rms@gnu.org>
date Sun, 29 Jun 1997 21:36:37 +0000
parents 60c1807220a6
children 65274adec5a2
files lisp/simple.el
diffstat 1 files changed, 25 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Sun Jun 29 20:42:56 1997 +0000
+++ b/lisp/simple.el	Sun Jun 29 21:36:37 1997 +0000
@@ -1157,28 +1157,32 @@
 		 (point))))
 
 (defun forward-visible-line (arg)
-  "Move forward by ARG lines, ignoring currently invisible newlines only."
+  "Move forward by ARG lines, ignoring currently invisible newlines only.
+If ARG is negative, move backward -ARG lines.
+If ARG is zero, move to the beginning of the current line."
   (condition-case nil
-      (progn
-	(while (> arg 0)
-	  (or (zerop (forward-line 1))
-	      (signal 'end-of-buffer nil))
-	  ;; If the following character is currently invisible,
-	  ;; skip all characters with that same `invisible' property value,
-	  ;; then find the next newline.
-	  (while (and (not (eobp))
-		      (let ((prop
-			     (get-char-property (point) 'invisible)))
-			(if (eq buffer-invisibility-spec t)
-			    prop
-			  (or (memq prop buffer-invisibility-spec)
-			      (assq prop buffer-invisibility-spec)))))
-	    (if (get-text-property (point) 'invisible)
-		(goto-char (next-single-property-change (point) 'invisible))
-	      (goto-char (next-overlay-change (point))))
-	    (or (zerop (forward-line 1))
-		(signal 'end-of-buffer nil)))
-	  (setq arg (1- arg)))
+      (if (>= arg 0)
+	  (while (>= arg 0)
+	    (if (zerop arg)
+		(beginning-of-line)
+	      (or (zerop (forward-line 1))
+		  (signal 'end-of-buffer nil)))
+	    ;; If the following character is currently invisible,
+	    ;; skip all characters with that same `invisible' property value,
+	    ;; then find the next newline.
+	    (while (and (not (eobp))
+			(let ((prop
+			       (get-char-property (point) 'invisible)))
+			  (if (eq buffer-invisibility-spec t)
+			      prop
+			    (or (memq prop buffer-invisibility-spec)
+				(assq prop buffer-invisibility-spec)))))
+	      (if (get-text-property (point) 'invisible)
+		  (goto-char (next-single-property-change (point) 'invisible))
+		(goto-char (next-overlay-change (point))))
+	      (or (zerop (forward-line 1))
+		  (signal 'end-of-buffer nil)))
+	    (setq arg (1- arg)))
 	(while (< arg 0)
 	  (or (zerop (vertical-motion -1))
 	      (signal 'beginning-of-buffer nil))