* How to get isearch-string, but only if I was in isearch?
@ 2017-02-12 7:04 Marcin Borkowski
2017-02-13 1:41 ` Michael Heerdegen
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2017-02-12 7:04 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
I'd like my command to use isearch-string as a default value, but only
if that command was triggered (using M-x, for instance) during isearch.
I tried this naive approach:
(when (memq last-command '(isearch-forward isearch-backward))
isearch-string)
to no avail, since it turned out that last-command was (in my case)
isearch-printing-char. Is there a way for an Emacs command to "know"
that isearch was active when it was invoked? (I could use an approach
similar to the above, but with a longer list of commands, including
most/all things from isearch-mode-map, but this seems fragile and far
from elegant.)
A similar thing to what I want happens with M-% and C-M-% during
isearch, but AFAICT these are just bound to special "wrapper" commands
in isearch-mode-map, and I don't want to have to bind my command to any
key (I use it seldom enough that I just use M-x).
TIA,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get isearch-string, but only if I was in isearch?
2017-02-12 7:04 How to get isearch-string, but only if I was in isearch? Marcin Borkowski
@ 2017-02-13 1:41 ` Michael Heerdegen
2017-02-13 5:09 ` Marcin Borkowski
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2017-02-13 1:41 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list
Marcin Borkowski <mbork@mbork.pl> writes:
> Is there a way for an Emacs command to "know" that isearch was active
> when it was invoked?
Looking at how things are implemented...maybe there isn't.
> (I could use an approach similar to the above, but with a longer list
> of commands, including most/all things from isearch-mode-map, but this
> seems fragile and far from elegant.)
Maybe you could use `isearch-mode-end-hook' in some clever way?
Regards,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get isearch-string, but only if I was in isearch?
2017-02-13 1:41 ` Michael Heerdegen
@ 2017-02-13 5:09 ` Marcin Borkowski
2017-02-18 16:10 ` Marcin Borkowski
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2017-02-13 5:09 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: Help Gnu Emacs mailing list
On 2017-02-13, at 02:41, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Is there a way for an Emacs command to "know" that isearch was active
>> when it was invoked?
>
> Looking at how things are implemented...maybe there isn't.
Well, after I sent my message, it occurred to me that I could check if
the first 7 characters of (symbol-name last-command) are "isearch". Not
exactly a clean method (neither extremely reliable), but might work.
>> (I could use an approach similar to the above, but with a longer list
>> of commands, including most/all things from isearch-mode-map, but this
>> seems fragile and far from elegant.)
>
> Maybe you could use `isearch-mode-end-hook' in some clever way?
Hm. I could use it to set 'this-command to 'isearch. I wonder what
could break then, though...
> Regards,
>
> Michael.
Thanks a lot!
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get isearch-string, but only if I was in isearch?
2017-02-13 5:09 ` Marcin Borkowski
@ 2017-02-18 16:10 ` Marcin Borkowski
0 siblings, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2017-02-18 16:10 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: Help Gnu Emacs mailing list
On 2017-02-13, at 06:09, Marcin Borkowski <mbork@mbork.pl> wrote:
> On 2017-02-13, at 02:41, Michael Heerdegen <michael_heerdegen@web.de> wrote:
>
>> Marcin Borkowski <mbork@mbork.pl> writes:
>>
>>> Is there a way for an Emacs command to "know" that isearch was active
>>> when it was invoked?
>>
>> Looking at how things are implemented...maybe there isn't.
>
>> Maybe you could use `isearch-mode-end-hook' in some clever way?
>
> Hm. I could use it to set 'this-command to 'isearch. I wonder what
> could break then, though...
Correction: 'last-command. See here for a solution:
http://mbork.pl/2017-02-18_Using_isearch-string_on_exit_from_isearch
Thanks,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-18 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-12 7:04 How to get isearch-string, but only if I was in isearch? Marcin Borkowski
2017-02-13 1:41 ` Michael Heerdegen
2017-02-13 5:09 ` Marcin Borkowski
2017-02-18 16:10 ` Marcin Borkowski
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.