unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: How to get isearch-string, but only if I was in isearch?
Date: Sun, 12 Feb 2017 08:04:31 +0100	[thread overview]
Message-ID: <87o9y7j3eo.fsf@mbork.pl> (raw)

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	other threads:[~2017-02-12  7:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-12  7:04 Marcin Borkowski [this message]
2017-02-13  1:41 ` How to get isearch-string, but only if I was in isearch? Michael Heerdegen
2017-02-13  5:09   ` Marcin Borkowski
2017-02-18 16:10     ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o9y7j3eo.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).