[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34723: 27.0.50; customize and improve diff-mode recentering

From: Charles A. Roelli
Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering
Date: Mon, 04 Mar 2019 20:06:13 +0100

> From: Juri Linkov <address@hidden>
> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]