help-gnu-emacs
[Top][All Lists]
Advanced

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

How to get isearch-string, but only if I was in isearch?


From: Marcin Borkowski
Subject: How to get isearch-string, but only if I was in isearch?
Date: Sun, 12 Feb 2017 08:04:31 +0100
User-agent: mu4e 0.9.19; emacs 26.0.50.3

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



reply via email to

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