all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: charles@aurox.ch (Charles A. Roelli)
Cc: 34723@debbugs.gnu.org
Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering
Date: Wed, 13 Mar 2019 15:56:50 -0400	[thread overview]
Message-ID: <jwvd0mu8s6g.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvimwm8tmt.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 13 Mar 2019 15:40:16 -0400")

>> There are cases where recentering does "make sure that the whole entry
>> is visible", but as we saw in the first post of this report, there is
>> at least one case where recentering makes less useful context visible.
> That's clearly undesirable, indeed.  I think it's a plain bug.
> Basically when moving in one direction, diff-hunk-next/prev should never
> scroll the buffer in the other direction.

I installed the patch below which should fix this most glaring problem.


        Stefan


diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index b866a95443..57cf5c86f4 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -625,6 +625,7 @@ easy-mmode-define-navigation
                  ,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.
@@ -646,7 +647,11 @@ easy-mmode-define-navigation
                                         `(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)





  reply	other threads:[~2019-03-13 19:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-03 20:38 bug#34723: 27.0.50; customize and improve diff-mode recentering Charles A. Roelli
2019-03-03 21:33 ` Juri Linkov
2019-03-04 19:06   ` Charles A. Roelli
2019-03-04 21:12     ` Juri Linkov
2019-03-05 16:11     ` Eli Zaretskii
2019-03-05 20:11       ` Charles A. Roelli
2019-03-05 20:22         ` Eli Zaretskii
2019-03-07 19:12           ` Charles A. Roelli
2019-03-05 15:46 ` Eli Zaretskii
2019-03-05 19:49   ` Charles A. Roelli
2019-03-05 19:44     ` Eli Zaretskii
2019-03-05 20:37       ` Charles A. Roelli
2019-03-06 16:06         ` Eli Zaretskii
2019-03-07 19:49           ` Charles A. Roelli
2019-03-13 19:40             ` Stefan Monnier
2019-03-13 19:56               ` Stefan Monnier [this message]
2019-03-16 19:39                 ` Charles A. Roelli
2019-03-16 22:37                   ` Stefan Monnier
2019-03-16 20:21               ` Charles A. Roelli
2019-03-22 19:32                 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd0mu8s6g.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=34723@debbugs.gnu.org \
    --cc=charles@aurox.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.