aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJambunathan K2013-02-16 14:56:42 +0530
committerJambunathan K2013-02-16 14:56:42 +0530
commit2b0afdd959577f6049dbcb64e17885fcf75a95b9 (patch)
tree9bf18e94b289d27a62dd1ec9809b57b81df3109c /lisp/replace.el
parenta7a84eea2d2f38e0029e656faa6566ae11de03a3 (diff)
downloademacs-2b0afdd959577f6049dbcb64e17885fcf75a95b9.tar.gz
emacs-2b0afdd959577f6049dbcb64e17885fcf75a95b9.zip
(read-regexp): Add regexp for symbol at point to the defaults (Bug#13687).
* lisp/replace.el (read-regexp): Tighten the regexp that matches tag. When tag is retrieved with `find-tag-default', use regexp that matches tag at point. Also update docstring.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 7757426cf95..0b8aaa7d349 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -585,27 +585,32 @@ of `history-length', which see.")
585When PROMPT doesn't end with a colon and space, it adds a final \": \". 585When PROMPT doesn't end with a colon and space, it adds a final \": \".
586If DEFAULTS is non-nil, it displays the first default in the prompt. 586If DEFAULTS is non-nil, it displays the first default in the prompt.
587 587
588Non-nil optional arg DEFAULTS is a string or a list of strings that 588Optional arg DEFAULTS is a string or a list of strings that are
589are prepended to a list of standard default values, which include the 589prepended to a list of standard default values, which include the
590string at point, the last isearch regexp, the last isearch string, and 590tag at point, the last isearch regexp, the last isearch string,
591the last replacement regexp. 591and the last replacement regexp.
592 592
593Non-nil HISTORY is a symbol to use for the history list. 593Non-nil HISTORY is a symbol to use for the history list.
594If HISTORY is nil, `regexp-history' is used." 594If HISTORY is nil, `regexp-history' is used."
595 (let* ((default (if (consp defaults) (car defaults) defaults)) 595 (let* ((defaults
596 (defaults
597 (append 596 (append
598 (if (listp defaults) defaults (list defaults)) 597 (if (listp defaults) defaults (list defaults))
599 (list (regexp-quote 598 (list
600 (or (funcall (or find-tag-default-function 599 ;; Regexp for tag at point.
600 (let* ((tagf (or find-tag-default-function
601 (get major-mode 'find-tag-default-function) 601 (get major-mode 'find-tag-default-function)
602 'find-tag-default)) 602 'find-tag-default))
603 "")) 603 (tag (funcall tagf)))
604 (cond ((not tag) "")
605 ((eq tagf 'find-tag-default)
606 (format "\\_<%s\\_>" (regexp-quote tag)))
607 (t (regexp-quote tag))))
604 (car regexp-search-ring) 608 (car regexp-search-ring)
605 (regexp-quote (or (car search-ring) "")) 609 (regexp-quote (or (car search-ring) ""))
606 (car (symbol-value 610 (car (symbol-value
607 query-replace-from-history-variable))))) 611 query-replace-from-history-variable)))))
608 (defaults (delete-dups (delq nil (delete "" defaults)))) 612 (defaults (delete-dups (delq nil (delete "" defaults))))
613 (default (car defaults))
609 ;; Do not automatically add default to the history for empty input. 614 ;; Do not automatically add default to the history for empty input.
610 (history-add-new-input nil) 615 (history-add-new-input nil)
611 (input (read-from-minibuffer 616 (input (read-from-minibuffer