all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Minimizing automatic scrolling
@ 2023-11-12 13:53 Psionic K
  2023-11-12 16:36 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Psionic K @ 2023-11-12 13:53 UTC (permalink / raw)
  To: help-gnu-emacs

I cannot find an option to disable all automatic scrolling caused by
minibuffer setup or transient setup.  I devised a solution that illustrates
the issue I'm managing:

    ;; Auto-scroll as little as possible.  Avoid moving the point.
    ;; Firstly, dynamically set `scroll-conservatively' to avoid automatic
re-centers.
    ;; We want automatic re-center when swiper for example goes off screen,
but for
    ;; minibuffer or transient display, we want the minimum possible scroll.
    ;; And finally, dynamically shrink the margin so that the space created
by
    ;; margin will all be used up before automatic scrolling can occur and
margins
    ;; will not be maintained during minibuffer or transient display.
    (defvar pmx--no-herky-jerk-margin nil)
    (defvar pmx--no-herky-jerk-scroll-conservatively nil)
    (setq scroll-margin 12) ; larger than ivy size, eliminating most scrolls
    (defun pmx--no-herky-jerk-enter (&rest _)
      "Shrinks margin."
      (setq pmx--no-herky-jerk-scroll-conservatively scroll-conservatively)
      (setq scroll-conservatively 101)
      (setq pmx--no-herky-jerk-margin scroll-margin)
      (setq scroll-margin 0))

    (defun pmx--no-herky-jerk-exit ()
      "Expands margin."
      (when pmx--no-herky-jerk-scroll-conservatively
        (setq scroll-conservatively
pmx--no-herky-jerk-scroll-conservatively))
      (setq pmx--no-herky-jerk-scroll-conservatively nil)
      (when pmx--no-herky-jerk-margin
        (setq scroll-margin pmx--no-herky-jerk-margin))
      (setq pmx--no-herky-jerk-margin nil))

    (add-hook 'minibuffer-setup-hook #'pmx--no-herky-jerk-enter)
    (add-hook 'minibuffer-exit-hook #'pmx--no-herky-jerk-exit)

    ;; Add the same for transient
    (with-eval-after-load 'transient
      (advice-add 'transient-setup :before #'pmx--no-herky-jerk-enter)
      (add-hook 'transient-exit-hook #'pmx--no-herky-jerk-exit)
      (setopt transient-hide-during-minibuffer-read t))

Happy to work on a patch if one is needed.

I also noticed that transient's default side-window display has a very
desirable property of only triggering scrolling once and then leaving the
window in a state where it won't scroll during the next transient display.
The minibuffer cleans up its scrolling, causing repeated "herky-jerk"
events.

I believe we need two options.  The first should be to not automatically
scroll unselected windows during resize.  The second should be to retain
scrolls caused by minibuffer expansion.

From what I have gathered, the window data model doesn't have a way to
express the idea that a window is temporary, so packages can't advertise to
Emacs that they are intended for temporary focused usage.

On focus, a window should scroll if appropriate, helping to visually
indicate that a window has become selected and fix the mis-indication that
a buffer has become selected and received unintended commands when a resize
has occurred.  Having an option to simply not auto scroll during resize
when not selected and another option to preserve scrolls caused by
minibuffer expansion would allow near perfect behavior.

-- 

남백호
대표 겸 공동 창업자
포지트론


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Minimizing automatic scrolling
  2023-11-12 13:53 Minimizing automatic scrolling Psionic K
@ 2023-11-12 16:36 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-11-12 16:36 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Psionic K <psionik@positron.solutions>
> Date: Sun, 12 Nov 2023 22:53:32 +0900
> 
> I cannot find an option to disable all automatic scrolling caused by
> minibuffer setup or transient setup.  I devised a solution that illustrates
> the issue I'm managing:

I'm sorry, but I couldn't understand what you mean by "automatic
scrolling" nor why would you want to disable it, and the code you
posted didn't clarify that to me.

Emacs scrolls when point's line is not fully visible in the window, or
when point ends up in the scroll margins.  It never scrolls in other
situations.  You cannot disable scrolling when point goes out of the
window.  If you want to disable the scrolling when point ends up in
the margin, simply don't customize the scroll margin to a non-zero
value.

So I don't really understand what you want to do and why, nor what it
has to do with minibuffer setup or transient setup.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-12 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-12 13:53 Minimizing automatic scrolling Psionic K
2023-11-12 16:36 ` Eli Zaretskii

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.