emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Re: [WIP PATCH] Controlling Isearch from the minibuffer


From: Drew Adams
Subject: RE: [External] : Re: [WIP PATCH] Controlling Isearch from the minibuffer
Date: Wed, 12 May 2021 23:07:55 +0000

> While isearching, I regularly find myself reaching for regular
> navigation/editing commands (C-a, C-b, M-b, M-DEL… even C-x o, on
> occasion), 

You "regularly" want to move within the search-pattern,
to do some editing of it besides at the end.  Is that it?

But in that case, what about `C-x o'?

> and tripping out of isearch.  

You don't want to end Isearch when you move to another
window?  Is it because you don't want to have to hit
`C-s' again, after `C-x o'?  Or do you regularly want
to both switch windows and edit the search string,
without hitting `C-s'?

> This thread made me discover M-e,

Really?  In that case, I suggest you first try using
that to do your editing, before asking that Isearch
be rewritten to be minibuffer-based.  It's really not
a big deal to use `M-e', IMO.

> but I doubt I'll use it much, since it takes the
> "i" out of "isearch".

I don't think so.  If you're using `M-b' and such to
get to the middle of the search pattern you're already
taking the "i" out of "isearch" to a degree.

`M-e M-b X C-s' is not a lot different from `M-b X',
and how often is this need "regularly" felt?

Anyway, I do sympathize with the need/desire to
sometimes want to directly go to the middle of the
pattern somewhere and insert or delete something
there.

Which is why I added an option to do that - but without
making Isearch depend on the minibuffer all the time.
Have Isearch use the minibuffer only for editing the
search pattern, as it does now, but obviate having to
hit `M-e' to do so, for certain movement etc. keys.

How would you feel about what I described as existing
in isearch+.el:

Customize `isearchp-initiate-edit-commands' to include
`beginning-of-line' (`C-a'), `backward-kill-word'
(`M-DEL'),...?

It already includes `C-b', `M-b', `C-M-b', `<left>',
C-<left>', and `M-<left>'.  Your wish is half granted,
even by default.

These are all prepared for possible inclusion, but are
commented out in the code - just to give folks an idea:

;; backward-delete-char                ; `DEL'
;; backward-delete-char-untabify       ; `DEL'
;; backward-kill-paragraph             ; `C-backspace'
;; backward-kill-sentence              ; `C-x DEL'
;; backward-kill-sexp                  ; `C-M-backspace'
;; backward-kill-word                  ; `M-DEL'
;; backward-list                       ; `C-M-p'
;; backward-page                       ; `C-x ['
;; backward-paragraph                  ; `C-up', `M-{'
;; backward-sentence                   ; `M-a'
;; backward-to-indentation             ; Not bound by default
;; backward-up-list                    ; `C-M-u', `C-M-up'
;; delete-backward-char
;; kill-backward-up-list               ; Not bound by default
;; beginning-of-buffer                 ; `M-<', `C-home'
;; beginning-of-defun                  ; `C-M-a', `C-M-home',
;; beginning-of-line                   ; `C-a', `home'
;; beginning-of-line-text              ; Not bound by default
;; beginning-of-visual-line            ; `C-a', `home'

(For most search patterns some of those likely wouldn't
be very useful - e.g., `backward-page'.  But if they're
not useful here then they're surely not useful in the
even more general case where all of Isearch would use
the minibuffer!)

With any such keys included, hitting the key does what
`M-e' does, but it also does what the command does.

E.g., `C-a' puts point at the beginning of the line in
the minibuffer (as `M-e C-a' would today).  Just insert
some text there, then hit `C-s' to continue with the
edited search pattern.

Like `M-e', this still uses the minibuffer only for
search-pattern editing.  And it lets users still use
other keys during Isearch that are specific to Isearch,
including using keys to exit Isearch.  (It's important
to some people to be able to exit using a bunch of keys
apparently.)  Isearch+ binds lots more keys during
Isearch - for things controlling search behavior (other
than just the search pattern).

Note that you can include any command.  But what
commands does it really make most sense to include?
Answer, I think: commands that move point _backward_
in the search pattern, possibly deleting some text
before or after movement (i.e. from the end or from
the new position).

Why?  Because the regular Isearch behavior of having
`DEL' delete chars from the end is _good_ - that's
what most pattern "editing" is about, in practice.

Being able to delete more than a char from the end
can sometimes be handy - e.g. delete a sexp.  Likewise,
moving backward various amounts, to insert or delete
some text from the middle or the beginning of the
pattern.

But _general_ minibuffer keys?  I don't think so.
(I really don't, as much as I practically live in the
minibuffer.)

Sure, even `C-x o' could be useful.  But in that case
do you want to continue searching with the same
pattern in the other window?  If so, even today that's
just `C-x o' then `C-s'.  Or do you want to, at the
same time, make some pattern edit?  The use case isn't
clear, to me.

Think about it.  Is this really pretty much only about
editing the search pattern?  If so, then I see no good
reason to reimplement Isearch based on the minibuffer.

What's needed for that is much less.  In that case, it
sounds like the only complaint is that some find the
need to hit `M-e' annoying.  Or it's something they're
not used to (perhaps, like you, they've just found out
about `M-e').  And to take care of that perceived
annoyance I propose what I mention above: implicit
`M-e' for certain keys.

Yes, to tell Emacs you're done editing the pattern in
a non-trivial way you need to hit `C-s'.  Worth it, IMO.

reply via email to

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