all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs 26.2 - Scroll command breaks if allowed during Isearch
@ 2019-11-13 16:06 Andrea Greselin
  2019-11-16  9:11 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Greselin @ 2019-11-13 16:06 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hello,

I noticed that a command that uses `set-window-hscroll' doesn't work the
same way during an isearch if `isearch-allow-scroll' is non nil and the
command has the properties `scroll-command' or `isearch-scroll'.

To reproduce, run `emacs -Q' and evaluate
--------------------------------------------------------------------------------
;;
0123456789

;; Set up the window and enable scrolling during isearch.
(set-frame-width nil 80)
(setq hscroll-margin 5)
(toggle-truncate-lines)
(setq isearch-allow-scroll t)

(defun h-scroll ()
  (interactive)
  (set-window-hscroll (selected-window) 10))

(defun h-not-so-scroll ()
  (interactive)
  (set-window-hscroll (selected-window) 10))

;; Even if you comment out one of these two settings the behaviour is the
same
(put 'h-scroll 'scroll-command t)
(put 'h-scroll 'isearch-scroll t)

(global-set-key (kbd "C-S-l") #'h-scroll)
(global-set-key (kbd "C-S-k") #'h-not-so-scroll)
--------------------------------------------------------------------------------
Now `h-scroll' (C-S-l) never quits isearch but
 - when I search for 0 in the first line and type C-S-l nothing happens
(`window-hscroll' remains 0);
 - if I search for 1 <= n <= 5 (columns 74 to 78, within `hscroll-margin'
from the right edge), isearch scrolls the window left, C-S-l then brings it
back all the way to the right (`window-hscroll' is brought back to 0);
 - if I search for n >= 6 then type C-S-l, `window-hscroll' is set to 10,
as expected.
C-S-k always sets `window-hscroll' to 10, but it exits isearch. Outside of
isearch both commands always work correctly.

What's the reason for this behaviour? Can I change it so that `h-scroll'
always sets the `window-hscroll' to 10 without exiting isearch?

Thanks,
Andrea


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

* Re: Emacs 26.2 - Scroll command breaks if allowed during Isearch
  2019-11-13 16:06 Emacs 26.2 - Scroll command breaks if allowed during Isearch Andrea Greselin
@ 2019-11-16  9:11 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2019-11-16  9:11 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Andrea Greselin <greselin.andrea@gmail.com>
> Date: Wed, 13 Nov 2019 17:06:33 +0100
> 
> What's the reason for this behaviour?

The reason is that you have Isearch fighting you: it itself calls
set-window-hscroll, trying to preserve the value it saw at the
beginning of the search command, as much as possible.  See
isearch-update in isearch.el.

> Can I change it so that `h-scroll' always sets the `window-hscroll'
> to 10 without exiting isearch?

Why do you want to do that?  Is there some problem with the hscrolling
Isearch does by default?



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

end of thread, other threads:[~2019-11-16  9:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-13 16:06 Emacs 26.2 - Scroll command breaks if allowed during Isearch Andrea Greselin
2019-11-16  9:11 ` 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.