* occur patch
@ 2010-11-11 4:44 Nathaniel Flath
2010-11-11 7:30 ` Geoff Gole
2010-11-11 20:10 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Nathaniel Flath @ 2010-11-11 4:44 UTC (permalink / raw
To: emacs-devel
Hello,
I found it useful to have occur default to the current word instead of
the last regexp, so I modified replace.el to support this. The patch
is below, if it should be installed into emacs itself - let me know of
any issues.
Thanks,
Nathaniel Flath
diff --git a/lisp/replace.el b/lisp/replace.el
index baea282..12c95cf 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1006,9 +1006,17 @@ which means to discard all text properties."
:group 'matching
:version "22.1")
+(defcustom occur-read-method 'history
+ "Method that Occur uses to prompt for a regex."
+ :type '(choice (const :tag "Last regex" 'history)
+ (const :tag "Current word" 'current-word))
+ :group 'matching)
+
(defun occur-read-primary-args ()
(list (read-regexp "List lines matching regexp"
- (car regexp-history))
+ (if (eq occur-read-method 'history)
+ (car regexp-history)
+ (current-word)))
(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: occur patch
2010-11-11 4:44 occur patch Nathaniel Flath
@ 2010-11-11 7:30 ` Geoff Gole
2010-11-11 20:10 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Geoff Gole @ 2010-11-11 7:30 UTC (permalink / raw
To: Nathaniel Flath; +Cc: emacs-devel
I agree that this is useful, I have something like this in my .emacs.
A minor problem with the patch is that the result of current-word is
used unquoted. Depending on whether people expect more restrictive or
more permissive searching, it may also be desirable to add
beginning/end of symbol:
(let ((word (current-word)))
(when word
(concat "\\_<" (regexp-quote word) "\\_>")))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: occur patch
2010-11-11 4:44 occur patch Nathaniel Flath
2010-11-11 7:30 ` Geoff Gole
@ 2010-11-11 20:10 ` Stefan Monnier
2010-11-14 22:19 ` Juri Linkov
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2010-11-11 20:10 UTC (permalink / raw
To: Nathaniel Flath; +Cc: emacs-devel
> I found it useful to have occur default to the current word instead of
> the last regexp, so I modified replace.el to support this. The patch
> is below, if it should be installed into emacs itself - let me know of
> any issues.
I think a better solution than a config var is to provide both values.
So a single M-n chooses one and a second M-n chooses the other.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: occur patch
2010-11-11 20:10 ` Stefan Monnier
@ 2010-11-14 22:19 ` Juri Linkov
0 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2010-11-14 22:19 UTC (permalink / raw
To: Stefan Monnier; +Cc: Nathaniel Flath, emacs-devel
>> I found it useful to have occur default to the current word instead of
>> the last regexp, so I modified replace.el to support this. The patch
>> is below, if it should be installed into emacs itself - let me know of
>> any issues.
>
> I think a better solution than a config var is to provide both values.
> So a single M-n chooses one and a second M-n chooses the other.
And this is what occur already does now.
Maybe the order of these M-n values should be configurable?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-14 22:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-11 4:44 occur patch Nathaniel Flath
2010-11-11 7:30 ` Geoff Gole
2010-11-11 20:10 ` Stefan Monnier
2010-11-14 22:19 ` Juri Linkov
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.