emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Occur should use the region as input if it's active


From: Juri Linkov
Subject: Re: Occur should use the region as input if it's active
Date: Fri, 17 Jan 2014 10:11:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]