unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Tom <adatgyujto@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Occur should use the region as input if it's active
Date: Fri, 17 Jan 2014 10:11:12 +0200	[thread overview]
Message-ID: <871u0758pr.fsf@mail.jurta.org> (raw)
In-Reply-To: <loom.20140116T205921-957@post.gmane.org> (Tom's message of "Thu,  16 Jan 2014 20:11:30 +0000 (UTC)")

> Picking up the symbol around the cursor is a good idea, so for occur
> it would be a good default to use the symbol around the cursor if there
> is no region active and use the region for search if it's active.

This can be implemented with 1-line patch:

=== modified file 'lisp/replace.el'
--- lisp/replace.el	2013-12-20 20:31:30 +0000
+++ lisp/replace.el	2014-01-17 08:11:03 +0000
@@ -658,6 +658,7 @@ (defun read-regexp-suggestions ()
 appends the list returned by this function to the end of values available
 via \\<minibuffer-local-map>\\[next-history-element]."
   (list
+   (if (use-region-p) (buffer-substring-no-properties (region-beginning) (region-end)))
    (find-tag-default-as-regexp)
    (find-tag-default-as-symbol-regexp)
    (car regexp-search-ring)

that uses the region as input with `M-s o down RET'.
Since this looks like a new feature, until feature freeze is over,
you can customize `read-regexp-defaults-function' to a function like

(lambda ()
  (list
   (if (use-region-p)
       (buffer-substring-no-properties (region-beginning) (region-end)))
   (find-tag-default-as-regexp)))

that uses the region as input with just `M-s o RET'.

> Limiting search with the region is infrequently needed and it can
> easily be done with narrowing. The above two features are much
> more useful and they can be used much more frequently (quickly
> picking an input for occur), so they should take precedence.

Yes, it's infrequently needed but still makes sense
for consistency with limiting in query-replace.



  reply	other threads:[~2014-01-17  8:11 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
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 [this message]
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

  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=871u0758pr.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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