unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Bob Proulx <bob@proulx.com>
To: help-gnu-emacs@gnu.org
Subject: Re: killing the result of isearch
Date: Tue, 7 Nov 2017 15:53:17 -0700	[thread overview]
Message-ID: <20171107151258910761350@bob.proulx.com> (raw)
In-Reply-To: <e00b8b10-440c-4c29-9d03-e26128788297@default>

Drew Adams wrote:
> >   Let's change "One-two, Buckle my shoe" to something else.
> >   C-s one-two, buckle my shoe C-r RET C-s C-s RET C-x C-x C-w
> 
> (You don't need the `C-x C-x' here, unless you want to
> see highlighted what `C-w' will delete.)

True.  But I always like the positive feedback about the region that
will be deleted.  So I am almost always using C-x C-x prior to region
commands.

Plus I was originally thinking of using DEL there and that needs the
highlight to be active.  In that case I needed C-x C-x to highlight
the region so that DEL would delete it.

> > Personally I always bind C-s to isearch-forward-regexp instead of
> > leaving it at isearch-forward.  Regular expressions are so much more
> > powerful and useful.
> 
> OK, but what you show above does not work, in general,
> for regexps.  Regexp search forward and backward do not
> find the same text, generally.

In the completely general case, true.  But most of the time they will
work fine.

  One:  One, two, buckle shoe.

  C-s one.*shoe

That will obviously match all of the way back to the "One:" part,
undesirably, when search forward.  But that doesn't invalidate the
technique all of the time.  I certainly wouldn't give up on regular
expressions simply because not every regular expression can be used in
every case.  And in the above if you try it forward with C-s and see
that it matches too much and then reverse direction with C-r one
finds that it matched exactly what was desired with non-greedy
matching.  (I haven't ever dug into figuring out why.)  But all along
the way there is feedback as to what is happening.  It isn't going to
silently do something scary.  I wouldn't avoid it.  Because that would
mean missing out on all of the capabilities of regular expressions.

> If you regexp-search for the same text, `one-two,
> buckle my shoe', no problem.  But if you use `o.*oe'
> you'll be in trouble.

Using "o" trying to match for "one" and "oe" trying to match for
"shoe" doesn't feel solid enough for me.  Matching only one and two
letters feels like it is asking to match something unexpected.  I
suggest putting enough text in there to anchor it firmly.  Remembering
that all of this is interacive editing, if it isn't doing what you
want then take corrective action and be more explicit by adding more
anchoring text.

When I took my CS200 intro to programming class at university some
time ago the first couple of weeks of the class was teaching us how to
use the text editor.  (What?  No programming?  No, learn to edit files
first!  I think today they expect students to already know how to edit
files, yet from what I can see most students could use a class on it.)
And they started us off right at the beginning editing with regular
expressions.  Literally we had to learn REs before even starting to
work on the programming assignments.  The department expected us to be
proficient editing text!  Looking back on it I am glad they did.  It
has been very useful to me.

Bob



  reply	other threads:[~2017-11-07 22: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 [this message]
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
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

  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=20171107151258910761350@bob.proulx.com \
    --to=bob@proulx.com \
    --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).