unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Isearch functionality
@ 2007-07-31 13:23 weber
  2007-07-31 13:59 ` Drew Adams
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: weber @ 2007-07-31 13:23 UTC (permalink / raw)
  To: help-gnu-emacs

Hello folks

I'd like to implement a command inside isearch that deletes the
current match _from the buffer_ (not from the search string)

This would be very useful since many times the search string you are
looking for is exactly what you want to remove, and it may be
something inside a word, so you can't just end isearch and do a kill
word. Do you get me ?

Anyway, I'd really appreciate some tips on how to implement this.
Maybe one could search the buffer for the specific type of overlay for
current match??

Thanks in advance,

Hugo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Isearch functionality
  2007-07-31 13:23 Isearch functionality weber
@ 2007-07-31 13:59 ` Drew Adams
       [not found] ` <mailman.4162.1185890445.32220.help-gnu-emacs@gnu.org>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2007-07-31 13:59 UTC (permalink / raw)
  To: weber, help-gnu-emacs

> I'd like to implement a command inside isearch that deletes the
> current match _from the buffer_ (not from the search string)
>
> This would be very useful since many times the search string you are
> looking for is exactly what you want to remove, and it may be
> something inside a word, so you can't just end isearch and do a kill
> word. Do you get me ?
>
> Anyway, I'd really appreciate some tips on how to implement this.
> Maybe one could search the buffer for the specific type of overlay for
> current match??

Any of these ways:

1. End Isearch when you find what you want to delete. Then `C-@ C-r C-r'.

2. Use isearch+.el. You can choose to end Isearch with the search target
selected.

3. Use Icicles search, and replace search hits on the fly (with nothing, in
this case).

For #1 and #2, just hit C-w to delete the search hit, or, if you use
`delete-selection-mode', just hit Backspace.

#1 and #2 require you to exit Isearch; #3 lets you delete any number of
selected search hits without exiting search.

For #2: see http://www.emacswiki.org/cgi-bin/wiki/IsearchPlus.

For #3: see
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Search_Commands%2c_Overview,
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Search-And-Replace.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Isearch functionality
       [not found] ` <mailman.4162.1185890445.32220.help-gnu-emacs@gnu.org>
@ 2007-07-31 14:18   ` weber
  0 siblings, 0 replies; 7+ messages in thread
From: weber @ 2007-07-31 14:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 31 jul, 10:59, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > I'd like to implement a command inside isearch that deletes the
> > current match _from the buffer_ (not from the search string)
>
> > This would be very useful since many times the search string you are
> > looking for is exactly what you want to remove, and it may be
> > something inside a word, so you can't just end isearch and do a kill
> > word. Do you get me ?
>
> > Anyway, I'd really appreciate some tips on how to implement this.
> > Maybe one could search the buffer for the specific type of overlay for
> > current match??
>
> Any of these ways:
>
> 1. End Isearch when you find what you want to delete. Then `C-@ C-r C-r'.
>
> 2. Use isearch+.el. You can choose to end Isearch with the search target
> selected.
>
> 3. Use Icicles search, and replace search hits on the fly (with nothing, in
> this case).
>
> For #1 and #2, just hit C-w to delete the search hit, or, if you use
> `delete-selection-mode', just hit Backspace.
>
> #1 and #2 require you to exit Isearch; #3 lets you delete any number of
> selected search hits without exiting search.
>
> For #2: seehttp://www.emacswiki.org/cgi-bin/wiki/IsearchPlus.
>
> For #3: seehttp://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Search_Commands%2c_Ov...,http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Search-And-Replace.

Many thanks for your answer, it was very complete.
Isearch+ is pretty much what I want :)

Also i had this snippet to force isearch to always put the cursor in
the beginning of the match:

(defun custom-goto-match-beginning ()
  "Use with isearch hook to end search at first char of match."
   (when isearch-forward (goto-char isearch-other-end)))

which i just changed to:

(defun custom-goto-match-beginning ()
  "Use with isearch hook to end search at first char of match."
  (when isearch-forward (exchange-point-and-mark)))

to work with isearch+.

Cheers,
weber

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Isearch functionality
  2007-07-31 13:23 Isearch functionality weber
  2007-07-31 13:59 ` Drew Adams
       [not found] ` <mailman.4162.1185890445.32220.help-gnu-emacs@gnu.org>
@ 2007-07-31 16:59 ` Joel J. Adamson
  2007-08-01 13:35   ` weber
  2007-08-04  8:48 ` Dieter Wilhelm
       [not found] ` <mailman.4378.1186217273.32220.help-gnu-emacs@gnu.org>
  4 siblings, 1 reply; 7+ messages in thread
From: Joel J. Adamson @ 2007-07-31 16:59 UTC (permalink / raw)
  To: help-gnu-emacs

weber <hugows@gmail.com> writes:

> This would be very useful since many times the search string you are
> looking for is exactly what you want to remove, and it may be
> something inside a word, so you can't just end isearch and do a kill
> word. Do you get me ?

Hmmm...I'm unsure if I understand what you want.  It sounds like what
you want is search and replace, replacing with "" (nothing, that is,
accomplished by hitting return when prompted for a replacement
string).  I do this all the time.  I often think there must be an even
more elegant way to do it.  You can even use a regexp replacement
search to delete stuff.  It's very versatile.

How is what you want different?

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

"Today in the Western world only children argue this way,
and only children believe the earth is at rest."
 	 -Thomas S. Kuhn, _The Copernican Revolution_, pg 44

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Isearch functionality
  2007-07-31 16:59 ` Joel J. Adamson
@ 2007-08-01 13:35   ` weber
  0 siblings, 0 replies; 7+ messages in thread
From: weber @ 2007-08-01 13:35 UTC (permalink / raw)
  To: help-gnu-emacs

On 31 jul, 13:59, jadam...@partners.org (Joel J. Adamson) wrote:
> weber <hug...@gmail.com> writes:
> > This would be very useful since many times the search string you are
> > looking for is exactly what you want to remove, and it may be
> > something inside a word, so you can't just end isearch and do a kill
> > word. Do you get me ?
>
> Hmmm...I'm unsure if I understand what you want.  It sounds like what
> you want is search and replace, replacing with "" (nothing, that is,
> accomplished by hitting return when prompted for a replacement
> string).  I do this all the time.  I often think there must be an even
> more elegant way to do it.  You can even use a regexp replacement
> search to delete stuff.  It's very versatile.
>
> How is what you want different?
>
> Joel
>
> --
> Joel J. Adamson
> Biostatistician
> Pediatric Psychopharmacology Research Unit
> Massachusetts General Hospital
> Boston, MA  02114
> (617) 643-1432
> (303) 880-3109
>
> "Today in the Western world only children argue this way,
> and only children believe the earth is at rest."
>          -Thomas S. Kuhn, _The Copernican Revolution_, pg 44

Yeah, well.. i don't know.
I guess in this case of a single replacement, isearch is more handy
because that's the keybinding I use for moving around all the time.
But of course for several fixes on the code I'm always using query-
replace-regexp.

Cheers,
weber

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Isearch functionality
  2007-07-31 13:23 Isearch functionality weber
                   ` (2 preceding siblings ...)
  2007-07-31 16:59 ` Joel J. Adamson
@ 2007-08-04  8:48 ` Dieter Wilhelm
       [not found] ` <mailman.4378.1186217273.32220.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 7+ messages in thread
From: Dieter Wilhelm @ 2007-08-04  8:48 UTC (permalink / raw)
  To: weber; +Cc: help-gnu-emacs

weber <hugows@gmail.com> writes:

> I'd like to implement a command inside isearch that deletes the
> current match _from the buffer_ (not from the search string)

I'd try the key sequence M-% within isearch, it switches to
query-replace and you can replace the current search string with "".

(You can bail out of query-replace by typing RET or q *or* C-s for
further searches 8-))

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Isearch functionality
       [not found] ` <mailman.4378.1186217273.32220.help-gnu-emacs@gnu.org>
@ 2007-08-04 15:03   ` weber
  0 siblings, 0 replies; 7+ messages in thread
From: weber @ 2007-08-04 15:03 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 4, 5:48 am, Dieter Wilhelm <die...@duenenhof-wilhelm.de> wrote:
> weber <hug...@gmail.com> writes:
> > I'd like to implement a command inside isearch that deletes the
> > current match _from the buffer_ (not from the search string)
>
> I'd try the key sequence M-% within isearch, it switches to
> query-replace and you can replace the current search string with "".
>
> (You can bail out of query-replace by typing RET or q *or* C-s for
> further searches 8-))
>
> --
>     Best wishes
>
>     H. Dieter Wilhelm
>     Darmstadt, Germany

Cool! that will useful in a lot of other situations as well!

Regards,
weber

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-08-04 15:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-31 13:23 Isearch functionality weber
2007-07-31 13:59 ` Drew Adams
     [not found] ` <mailman.4162.1185890445.32220.help-gnu-emacs@gnu.org>
2007-07-31 14:18   ` weber
2007-07-31 16:59 ` Joel J. Adamson
2007-08-01 13:35   ` weber
2007-08-04  8:48 ` Dieter Wilhelm
     [not found] ` <mailman.4378.1186217273.32220.help-gnu-emacs@gnu.org>
2007-08-04 15:03   ` weber

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).