From: Drew Adams <drew.adams@oracle.com>
To: Tom <adatgyujto@gmail.com>, emacs-devel@gnu.org
Subject: RE: Occur should use the region as input if it's active
Date: Thu, 16 Jan 2014 11:23:38 -0800 (PST) [thread overview]
Message-ID: <a1edd7e4-c492-4a50-b0bd-f1b6004a82d5@default> (raw)
In-Reply-To: <loom.20140116T194740-227@post.gmane.org>
> If often happens to me that I'm perusing a buffer and I want to
> search for some word or phrase in it. To do this I simply select the
> text and use this code to instantly get occur matches of it:
>
> (defun my-occur ()
> (interactive)
> (if (use-region-p)
> (occur (buffer-substring-no-properties
> (region-beginning) (region-end)))
> (call-interactively 'occur)))
>
> Shouldn't the builtin occur do this? It's quite convenient and
> efficient and in my experience most of the occur searches are
> of these kind (searching for something I see) and it's less
> often that I actualy need to type in the search term.
Yes and no. The region can also be useful to delimit the
search without narrowing.
FWIW, in my code, a user option decides this:
,----
| search/replace-region-as-default-flag is a variable defined in `replace+.el'.
| Its value is nil
|
| Documentation:
| Non-nil means use the active region text as default for search/replace.
| That is, if the region is currently active then use its text as the
| default input. All text properties are removed from the text.
|
| Note that in this case the active region is not used to limit the
| search/replacement scope. But in that case you can of course just
| narrow the buffer temporarily to restrict the operation scope.
|
| A non-nil value of this option takes precedence over the use of option
| `search/replace-2nd-sel-as-default-flag'. To give that option
| precedence over using the active region, you can set this option to
| nil and use `region-or-non-nil-symbol-name-nearest-point' as the value
| of option `search/replace-default-fn'.
|
| You can customize this variable.
`----
next prev parent reply other threads:[~2014-01-16 19:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-16 18:55 Occur should use the region as input if it's active Tom
2014-01-16 19:23 ` Drew Adams [this message]
2014-01-16 19:32 ` Tom
2014-01-16 19:51 ` Drew Adams
2014-01-16 19:36 ` Drew Adams
2014-01-16 20:11 ` Tom
2014-01-17 8:11 ` Juri Linkov
2014-01-17 0:52 ` Tak Kunihiro
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=a1edd7e4-c492-4a50-b0bd-f1b6004a82d5@default \
--to=drew.adams@oracle.com \
--cc=adatgyujto@gmail.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.