[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp)
From: |
Jambunathan K |
Subject: |
bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first |
Date: |
Fri, 08 Mar 2013 18:32:36 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Juri Linkov <juri@jurta.org> writes:
> 2. Add a new defcustom like:
> (defcustom minibuffer-defaults '((highlight-regexp-default . tag-at-point)
> (rgrep . history)
> (occur . tag-at-point)
> (how-many . history)
> ...))
> Cons: Too large list of commands for one option.
I am attaching a patch that handles `occur'. I will commit this patch
tomorrow.
ps: I have never used how-many. The defaults for grep and rgrep never
bothered me. So I leave these two commands out of my current scope.
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2013-03-08 08:11:28 +0000
+++ lisp/ChangeLog 2013-03-08 12:52:16 +0000
@@ -1,5 +1,11 @@
2013-03-08 Jambunathan K <kjambunathan@gmail.com>
+ * replace.el (occur-read-regexp-defaults-function): New var.
+ (occur-read-regexp-defaults): New defun.
+ (occur-read-primary-args): Propagate above change (bug#13892).
+
+2013-03-08 Jambunathan K <kjambunathan@gmail.com>
+
* hi-lock.el (hi-lock-read-regexp-defaults-function): New var.
(hi-lock-read-regexp-defaults): New defun.
(hi-lock-line-face-buffer, hi-lock-face-buffer)
=== modified file 'lisp/replace.el'
--- lisp/replace.el 2013-03-08 04:18:16 +0000
+++ lisp/replace.el 2013-03-08 12:45:40 +0000
@@ -1135,12 +1135,33 @@ which means to discard all text properti
:group 'matching
:version "22.1")
+(defvar occur-read-regexp-defaults-function
+ 'occur-read-regexp-defaults
+ "Function that provides default regexp(s) for occur commands.
+This function should take no arguments and return one of nil, a
+regexp or a list of regexps for use with occur commands -
+`occur', `multi-occur' and `multi-occur-in-matching-buffers'.
+The return value of this function is used as DEFAULTS param of
+`read-regexp' while executing the occur command. This function
+is called only during interactive use.
+
+For example, to check for occurrence of a symbol at point by
+default use
+
+ \(setq occur-read-regexp-defaults-function
+ 'find-tag-default-as-regexp\).")
+
+(defun occur-read-regexp-defaults ()
+ "Return the latest regexp from `regexp-history'.
+See `occur-read-regexp-defaults-function' for details."
+ (car regexp-history))
+
(defun occur-read-primary-args ()
(let* ((perform-collect (consp current-prefix-arg))
(regexp (read-regexp (if perform-collect
"Collect strings matching regexp"
"List lines matching regexp")
- (car regexp-history))))
+ (funcall occur-read-regexp-defaults-function))))
(list regexp
(if perform-collect
;; Perform collect operation
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first, Juri Linkov, 2013/03/03
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first, Jambunathan K, 2013/03/06
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first,
Jambunathan K <=
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Juri Linkov, 2013/03/08
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Drew Adams, 2013/03/08
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Jambunathan K, 2013/03/08
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Drew Adams, 2013/03/08
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Jambunathan K, 2013/03/08
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first, Drew Adams, 2013/03/08