GNU bug report logs - #34723
27.0.50; customize and improve diff-mode recentering

Previous Next

Package: emacs;

Reported by: charles <at> aurox.ch

Date: Sun, 3 Mar 2019 20:33:01 UTC

Severity: minor

Found in version 27.0.50

Full log


View this message in rfc822 format

From: charles <at> aurox.ch (Charles A. Roelli)
To: Juri Linkov <juri <at> linkov.net>
Cc: 34723 <at> debbugs.gnu.org
Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering
Date: Mon, 04 Mar 2019 20:06:13 +0100
> From: Juri Linkov <juri <at> linkov.net>
> Date: Sun, 03 Mar 2019 23:33:16 +0200
> 
> I use `C-M-l' (reposition-window) to recenter during search,
> and it works quite well to recenter diff hunks with
> 
>   (setq isearch-push-state-function
>         (lambda ()
>           (when (and isearch-success (not (pos-visible-in-window-p)))
>             (reposition-window))
>           `(lambda (cmd)
>              (when isearch-success
>                (set-window-start nil ,(window-start))))))

Can we add something like this to isearch.el, maybe as a defcustom?
Or maybe we could add it in a way such that other packages that show
search results (grep, xref) could use the same function to reposition
the window.  The function could inspect a defcustom in simple.el to
decide whether (or how) to reposition the window.

> but the problem is that I also have to change the default definition
> of reposition boundaries used by `C-M-l' (reposition-window)
> 
>    (add-hook 'diff-mode-hook
>              (lambda ()
>                (set (make-local-variable 'beginning-of-defun-function)
>                     #'diff-beginning-of-hunk)
>                (set (make-local-variable 'end-of-defun-function)
>                     #'diff-end-of-hunk)))
> 
> to recenter at diff hunk boundaries, not at diff file boundaries
> as defined in `diff-mode' by default, because usually there are
> much more lines covered by all file changes, and when reposition-window
> tries to fit all file changes into the screen, it puts the current line
> at the bottom line of the window, thus not showing the lower part
> of the current hunk.

I noticed this too.  If it makes sense, we should make these values of
beginning-of-defun-function and end-of-defun-function the default.




This bug report was last modified 6 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.