all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Christoph'" <cschol2112@googlemail.com>, <emacs-devel@gnu.org>
Subject: RE: [PATCH] (Or "question"...) isearch-kill-found
Date: Sun, 30 May 2010 17:48:21 -0700	[thread overview]
Message-ID: <AC53749E6CF0499A96890331F446479E@us.oracle.com> (raw)
In-Reply-To: <4C02E48A.7080305@gmail.com>

> > I proposed the feature to emacs-devel on 2007-07-10:
> > http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg00490.html
> >
> > The bottom line was Richard's decision:
> >
> >   "I don't think it is needed.  You can type C-@ C-r C-r to put
> >   the region around the match that was just found."
>  
> In that same thread Davis Herring had an idea that sounds interesting 
> and useful to me:
> http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg00492.html
> 
> >  Thinking about this, I realize
> >  that I would get almost all the utility of this idea with 
> >  just one command added to isearch which meant "exit and move
> >  point to start of match", or (closer to your idea) a command
> >  which meant "exit and drop mark at start
> >  of match" in place of your toggle.  WDOT?
> 
> I think a function "exit and drop mark at start of match" 
> would be very useful.

Hm.  That interesting and useful idea that "Davis Herring had" I implemented in
2006, a year before the proposal.  And I pointed the list (hence Davis too) to
that code.

I call that command `set-region-around-search-target'.[*]

(defun set-region-around-search-target ()
  "Set the region around the last search or query-replace target."
  (interactive)
  (case last-command
    ((isearch-forward isearch-backward
      isearch-forward-regexp isearch-backward-regexp)
     (push-mark isearch-other-end t 'activate))
    (t (push-mark (match-beginning 0) t 'activate)))
  (setq deactivate-mark nil))

It does exactly what he described: "drop mark at start of match".  Unlike
`isearchp-set-region' (the proposal), it is not conditional on the user option
or on `transient-mark-mode', and thus not sensitive to the toggle key, `C-SPC'.

I do not bind that command by default, but you can bind it in `isearch-map'.  Or
you can add it, in place of `isearchp-set-region', to `isearch-mode-end-hook'.

It is in fact the _same_ as `isearchp-set-region' (the proposal) in this
context, except that it is unconditional instead of respecting the toggle key.

IOW, if `transient-mark-mode' is on and the option is on, then the proposed
behavior is exactly what Davis described: just put mark at the match start.  If
t-m-mode is off and you still want the start to be marked, then use
`set-region-around-search-target' instead.

Here is what I proposed (I use it on `isearch-mode-end-hook'):

(defun isearchp-set-region ()
  "Set region around search target, if `isearchp-set-region-flag'.
Used only for Transient Mark mode."
  (when (and isearchp-set-region-flag transient-mark-mode)
    (push-mark isearch-other-end t 'activate)))

You might notice, BTW, that Davis started by saying that he does not use either
transient-mark mode or delete-selection mode.  Yet t-m mode is the context the
feature was designed for - it is active only in t-m mode.  (Transient-mark mode
is now the default.)

---
[*] There is perhaps a better test to use here than `last-command'.  Maybe
isearch has a state variable that can be checked for this - dunno.




  parent reply	other threads:[~2010-05-31  0:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-30 12:37 [PATCH] (Or "question"...) isearch-kill-found Deniz Dogan
2010-05-30 14:05 ` Johan Bockgård
2010-05-30 14:11   ` Deniz Dogan
2010-05-30 15:25     ` Drew Adams
2010-05-30 22:19       ` Christoph
2010-05-30 22:40         ` Lennart Borgman
2010-05-31  0:28           ` Drew Adams
2010-05-31  3:30           ` Michael Welsh Duggan
2010-05-31 15:32             ` Lennart Borgman
2010-05-31  0:48         ` Drew Adams [this message]
2010-05-30 18:36 ` Juri Linkov
2010-05-31 14:24   ` Chong Yidong
2010-05-31 15:38     ` Lennart Borgman
2010-05-31 15:54     ` Stefan Monnier
2010-05-31 16:50       ` Lennart Borgman
2010-05-31 19:14       ` Drew Adams
2010-05-31 19:50         ` Stefan Monnier
2010-05-31 20:04           ` Drew Adams
2010-06-01  3:10             ` Stefan Monnier
2010-06-01  4:43               ` Drew Adams
2010-06-01 12:56                 ` Stefan Monnier
2010-06-01 13:55                   ` Lennart Borgman
2010-06-01 19:03                     ` Stefan Monnier
2010-06-01 19:15                       ` Lennart Borgman
2010-06-01 21:03                 ` Richard Stallman
2010-05-31 20:14       ` Juri Linkov

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=AC53749E6CF0499A96890331F446479E@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=cschol2112@googlemail.com \
    --cc=emacs-devel@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.