all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: killing the result of isearch
Date: Tue, 07 Nov 2017 12:53:38 -0500	[thread overview]
Message-ID: <jwvlgjiro80.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: CA277B3D-6B23-46BE-9C20-C80B26AF1C8F@gmail.com

> I must be missing something big...
> I have an isearch that highlights a string, and I just want to delete
> that string.

> In other editors I'd just hit delete on that selection, but that won't
> work in Emacs...

It should be fairly easy to get what you want.
You could start with

    (defun sm-isearch-done ()
      ;; Activate the region corresponding to the found string.
      (unless (or isearch-mode-end-hook-quit ;; Leaving with C-g!
                  mark-active)               ;; Already selecting a region!
        (push-mark isearch-other-end nil t)
        (when (eq transient-mark-mode t)
          ;; Mark the selected region in the same way as is done by S-right,
          ;; so that subsequent navigation commands automatically deactivate
          ;; the region.
          (push 'only transient-mark-mode))))
    (add-hook 'isearch-mode-end-hook #'sm-isearch-done)

so you can do `C-s foo <delete>` and it will delete the found `foo`.
You can also do `C-s foo RET DEL` to get the same result.
And if you use `delete-selection-mode`, then `C-s foo RET b` will
replace `foo` with `b'.

Many Emacs users rely on isearch for navigation, in which case the above
could prove annoying.  Also, currently isearch pushes a mark at the
position where you started the search, so you can do

     C-s foo RET C-w

to delete the text between point and the first occurrence of `foo`.
The above will break such usage (as well as various others).

Maybe something like the above code could be added to isearch.el but
I think it'll have to be made conditional on a config var, so users
can elect to use this behavior or not (since old-timers used to the
details of the current behavior will probably want to keep using that).

Feel free to use this code snippet in a feature request (via M-x
report-emacs-bug).


        Stefan




  parent reply	other threads:[~2017-11-07 17:53 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  2:41 killing the result of isearch Jean-Christophe Helary
2017-11-07  5:34 ` Drew Adams
2017-11-07  6:01   ` Jean-Christophe Helary
2017-11-07  6:25     ` Søren Pilgård
     [not found]     ` <mailman.3103.1510035932.27995.help-gnu-emacs@gnu.org>
2017-11-07  7:07       ` Loris Bennett
2017-11-07  7:49         ` Jean-Christophe Helary
2017-11-07  8:43         ` Jean-Christophe Helary
     [not found]         ` <mailman.3106.1510044223.27995.help-gnu-emacs@gnu.org>
2017-11-07 10:49           ` Loris Bennett
2017-11-07 12:45             ` Jean-Christophe Helary
2017-11-07 15:26               ` Drew Adams
2017-11-07 15:51                 ` Jean-Christophe Helary
2017-11-07 16:46                   ` Drew Adams
2017-11-07 22:38                     ` Jean-Christophe Helary
2017-11-07 16:53                   ` Eric Abrahamsen
2017-11-07 17:24                     ` Drew Adams
2017-11-07 17:45                       ` Eric Abrahamsen
2017-11-08  8:21               ` Thien-Thi Nguyen
2017-11-08 13:47                 ` Emanuel Berg
2017-11-11 15:36                   ` Charles A. Roelli
     [not found]             ` <mailman.3114.1510058721.27995.help-gnu-emacs@gnu.org>
2017-11-07 15:08               ` Loris Bennett
2017-11-07 15:28                 ` Jean-Christophe Helary
2017-11-07 16:24                   ` Drew Adams
2017-11-07 22:34                     ` Jean-Christophe Helary
2017-11-07 22:54                       ` Drew Adams
2017-11-08 22:24                   ` Tomas Nordin
2017-11-08 22:44                     ` Jean-Christophe Helary
2017-11-08 23:07                       ` Emanuel Berg
2017-11-09 21:38                       ` Tomas Nordin
2017-11-10 13:11                         ` Jean-Christophe Helary
2017-11-10 16:54                           ` Drew Adams
2017-11-07  8:31     ` Marcin Borkowski
2017-11-07 15:26     ` Drew Adams
2017-11-07 20:59     ` Bob Proulx
2017-11-07 22:10       ` Drew Adams
2017-11-07 22:53         ` Bob Proulx
2017-11-07 23:15       ` Jean-Christophe Helary
2017-11-08  4:27         ` Bob Proulx
2017-11-08  5:29           ` Jean-Christophe Helary
2017-11-08 18:50             ` Bob Proulx
2017-11-07 17:53 ` Stefan Monnier [this message]
2017-11-07 22:59   ` Jean-Christophe Helary
2017-11-12 20:02     ` Tomas Nordin
2017-11-12 22:13       ` Emanuel Berg
2017-11-13 21:17         ` Tomas Nordin
2017-11-13 22:13           ` Emanuel Berg
2017-11-20  3:24           ` Emanuel Berg
2017-11-15 14:48       ` Emanuel Berg

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

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

  git send-email \
    --in-reply-to=jwvlgjiro80.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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.
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.