[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: |
Juri Linkov |
Subject: |
bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first |
Date: |
Sun, 03 Mar 2013 11:31:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> So the question is: should the default value in the caller
> `highlight-regexp' be changed from `(car regexp-history)'
> to code that gets the tag at point? You could propose
> such a change, but since it changes the long-standing behavior,
> expect some disagreement (not from me :-)
There are surprisingly many users who prefer the previous item from the
history instead of the tag at point as the default value of `occur',
`highlight-regexp', `rgrep'. They got `(car regexp-history)' hard-coded
into core Emacs for `occur' and `highlight-regexp', but not for `rgrep',
so they raise the questions how to do the same for `rgrep', and get such
horribly ugly solutions as this one:
http://stackoverflow.com/questions/15161592/make-emacs-rgrep-default-to-last-search-term-rather-than-word-at-point
This situation suggests that the default values should be customizable.
Possible variants:
1. Put a special value on the command's symbol like:
(put 'highlight-regexp 'default 'history)
(put 'highlight-regexp 'default 'tag-at-point)
checked on `this-command' in minibuffer-reading functions.
Cons: Not easy to use.
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.
3. In the DEFAULT arg of minibuffer-reading calls
specify a function that returns default values:
(defun highlight-regexp (regexp &optional face)
(interactive
(list
(read-regexp "Regexp to highlight" 'highlight-regexp-default)
...
(defun highlight-regexp-default ()
(car regexp-history))
where users can override it with another function:
(defun highlight-regexp-default ()
(let* ((tagf (or find-tag-default-function
(get major-mode 'find-tag-default-function)
'find-tag-default))
(tag (funcall tagf)))
(cond ((not tag) "")
((eq tagf 'find-tag-default)
(format "\\_<%s\\_>" (regexp-quote tag)))
(t (regexp-quote tag)))))
Pros: Flexible and easy to configure.
- bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first,
Juri Linkov <=
- 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, 2013/03/08
- 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