emacs-devel
[Top][All Lists]
Advanced

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

Re: Simple isearch concerns


From: Ergus
Subject: Re: Simple isearch concerns
Date: Thu, 8 Apr 2021 05:32:34 +0200

Hi Juri:

Sorry to bother. But I don't understand much of this email. Is this documented
somewhere? Could you add a simple use case example for a simple user
or dumb lisper like me?


On Wed, Apr 07, 2021 at 11:12:12PM +0300, Juri Linkov wrote:

If you want a separate option, this is fine.  But then there is no need
to duplicate the key remapping feature.  To make the new feature more powerful,
you could attach to command symbol properties a function that
defines where to move point before searching the next match.

This is similar to how isearch-yank-internal funcalls its arg 'jumpform',
and how its callers like isearch-yank-char uses

 (lambda () (forward-char arg) (point))

or isearch-yank-word uses

 (lambda () (forward-word arg) (point))

to define where to move point before using it as the buffer position.

So command symbol properties could be defined using the same logic:

 (put 'beginning-of-buffer 'isearch-match-scroll 'beginning-of-buffer)
 (put 'end-of-buffer 'isearch-match-scroll 'end-of-buffer)
 (put 'scroll-up-command 'isearch-match-scroll (lambda () (goto-char 
(window-end))))
 (put 'scroll-down-command 'isearch-match-scroll (lambda () (goto-char 
(window-start))))

where the symbol property is called like (funcall 'beginning-of-buffer)
before repeating the search.

Then there is no need to add such ad-hoc commands as isearch-scroll-up
and isearch-scroll-down.

And instead of

 (setq this-command (get this-command 'isearch-match-scroll))

isearch-pre-command-hook could contain the same code
that is currently duplicated in several commands:

 (setq isearch-just-started t)
 (goto-char (window-end))  ;; only this line needs to be
                           ;; replaced with (funcall jumpform)
 (isearch-repeat 'forward)

Whereas it would be easy to handle more commands like below:



Actually, the 'isearch-match-scroll' above doesn't do what is needed.
It just goes to the next match, whereas the need was to go to the next line
before searching for a new match.

With the logic above, this is easy to define like:

 (put 'next-line 'isearch-match-scroll (lambda () (forward-line 1)))



reply via email to

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