bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Wed, 06 Mar 2013 23:30:27 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Juri Linkov <address@hidden> writes:

>> 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:

See bug#13892.  I have gone with (3).  For now, I have modified
hi-lock.el.  Modifications to occur will follow soon.


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





reply via email to

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