From e9ab825f6e795cae820628262d64d8c435c76092 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 26 Apr 2005 18:31:19 +0000 Subject: [PATCH] (line-move-1): Avoid using vertical-motion in easy cases. --- lisp/simple.el | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 3082112ec1b..36f09267235 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3403,19 +3403,33 @@ Outline mode sets this." (goto-char (next-char-property-change (point)))) ;; Now move a line. (end-of-line) - (and (zerop (vertical-motion 1)) - (if (not noerror) - (signal 'end-of-buffer nil) - (setq done t))) + ;; If there's no invisibility here, move over the newline. + (if (not (line-move-invisible-p (point))) + ;; We avoid vertical-motion when possible + ;; because that has to fontify. + (if (eobp) + (setq done t) + (forward-line 1)) + ;; Otherwise move a more sophisticated way. + ;; (What's the logic behind this code?) + (and (zerop (vertical-motion 1)) + (if (not noerror) + (signal 'end-of-buffer nil) + (setq done t)))) (unless done (setq arg (1- arg)))) + ;; The logic of this is the same as the loop above, + ;; it just goes in the other direction. (while (and (< arg 0) (not done)) (beginning-of-line) - - (if (zerop (vertical-motion -1)) - (if (not noerror) - (signal 'beginning-of-buffer nil) - (setq done t))) + (if (not (line-move-invisible-p (1- (point)))) + (if (bobp) + (setq done t) + (forward-line -1)) + (if (zerop (vertical-motion -1)) + (if (not noerror) + (signal 'beginning-of-buffer nil) + (setq done t)))) (unless done (setq arg (1+ arg)) (while (and ;; Don't move over previous invis lines -- 2.39.2