[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: Tue, 05 Mar 2019 21:11:13 +0100

> Date: Tue, 05 Mar 2019 18:11:57 +0200
> From: Eli Zaretskii <address@hidden>
> CC: address@hidden, address@hidden
> > >   (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.
> Isn't it easier to temporarily bind scroll-margin to a non-zero value,
> then force redisplay?
> Or maybe I'm missing something in this discussion.

I'm not sure how binding scroll-margin would change the behavior here.

IIUC the aim of this snippet is to reposition the window to show as
much of the function definition (or diff hunk, or some other text
structure) that includes the search hit as possible.  For example, if
you evaluate the snippet from emacs -Q, then type, for example

M-x find-library RET simple.el RET
C-s quit-flag

Then Emacs positions the window to show the definition (from the
beginning) of the function containing the search hit.  When you try
that again in another session without evaluating the snippet, Emacs
centers the search hit in the window, giving you less useful context.

reply via email to

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