]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/easy-mmode.el: Fix most obvious bug#34723
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 13 Mar 2019 19:55:39 +0000 (15:55 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 13 Mar 2019 19:55:39 +0000 (15:55 -0400)
(easy-mmode-define-navigation): Don't scroll in the opposite direction of
the movement.

lisp/emacs-lisp/easy-mmode.el

index 0cb9a6fa122389edd2fb1e18fe1d7e1fe2b0e63b..8ac0a1d5938344d32981c9e5637ba10bdf5eb2f6 100644 (file)
@@ -628,6 +628,7 @@ BODY is executed after moving to the destination location."
                  ,body
                  (when was-narrowed (funcall #',narrowfun)))))))
     (unless name (setq name base-name))
+    ;; FIXME: Move most of those functions's bodies to helper functions!
     `(progn
        (defun ,next-sym (&optional count)
         ,(format "Go to the next COUNT'th %s.
@@ -649,7 +650,11 @@ Interactively, COUNT is the prefix numeric argument, and defaults to 1." name)
                                         `(re-search-forward ,re nil t 2)))
                                    (point-max))))
                     (unless (pos-visible-in-window-p endpt nil t)
-                      (recenter '(0)))))))
+                      (let ((ws (window-start)))
+                        (recenter '(0))
+                        (if (< (window-start) ws)
+                            ;; recenter scrolled in the wrong direction!
+                            (set-window-start nil ws))))))))
            ,@body))
        (put ',next-sym 'definition-name ',base)
        (defun ,prev-sym (&optional count)