aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorGlenn Morris2014-02-13 23:36:42 -0800
committerGlenn Morris2014-02-13 23:36:42 -0800
commitb8630261dda1988bd1cabe7fc1b567b6e140eabb (patch)
treef0c5bb6f392ab72b6a899a877b183232b986dfbc /lisp/replace.el
parentb2bf2a254fba3ec86fb763a95289f51251428ac4 (diff)
downloademacs-b8630261dda1988bd1cabe7fc1b567b6e140eabb.tar.gz
emacs-b8630261dda1988bd1cabe7fc1b567b6e140eabb.zip
Some read-regexp doc
* lisp/replace.el (map-query-replace-regexp) (read-regexp-defaults-function, read-regexp): Doc fixes. * etc/NEWS: Related edits.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el64
1 files changed, 39 insertions, 25 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index cebb10d5133..fafa5ec8390 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -450,6 +450,7 @@ of the region. Otherwise, operate from point to the end of the buffer.
450 450
451Non-interactively, TO-STRINGS may be a list of replacement strings. 451Non-interactively, TO-STRINGS may be a list of replacement strings.
452 452
453Interactively, reads the regexp using `read-regexp'.
453Use \\<minibuffer-local-map>\\[next-history-element] \ 454Use \\<minibuffer-local-map>\\[next-history-element] \
454to pull the last incremental search regexp to the minibuffer 455to pull the last incremental search regexp to the minibuffer
455that reads REGEXP. 456that reads REGEXP.
@@ -627,17 +628,16 @@ of `history-length', which see.")
627 "History of regexp for occur's collect operation") 628 "History of regexp for occur's collect operation")
628 629
629(defcustom read-regexp-defaults-function nil 630(defcustom read-regexp-defaults-function nil
630 "Function that provides default regexp(s) for regexp reading commands. 631 "Function that provides default regexp(s) for `read-regexp'.
631This function should take no arguments and return one of nil, a 632This function should take no arguments and return one of: nil, a
632regexp or a list of regexps. The return value of this function is used 633regexp, or a list of regexps. Interactively, `read-regexp' uses
633as DEFAULTS param of `read-regexp'. This function is called only during 634the return value of this function for its DEFAULT argument.
634interactive use.
635 635
636If you need different defaults for different commands, 636As an example, set this variable to `find-tag-default-as-regexp'
637use `this-command' to identify the command under execution. 637to default to the symbol at point.
638 638
639You can customize `read-regexp-defaults-function' to the value 639To provide different default regexps for different commands,
640`find-tag-default-as-regexp' to highlight a symbol at point." 640the function that you set this to can check `this-command'."
641 :type '(choice 641 :type '(choice
642 (const :tag "No default regexp reading function" nil) 642 (const :tag "No default regexp reading function" nil)
643 (const :tag "Latest regexp history" regexp-history-last) 643 (const :tag "Latest regexp history" regexp-history-last)
@@ -647,7 +647,7 @@ You can customize `read-regexp-defaults-function' to the value
647 find-tag-default-as-regexp) 647 find-tag-default-as-regexp)
648 (function-item :tag "Tag at point as symbol regexp" 648 (function-item :tag "Tag at point as symbol regexp"
649 find-tag-default-as-symbol-regexp) 649 find-tag-default-as-symbol-regexp)
650 (function :tag "Function to provide default for read-regexp")) 650 (function :tag "Your choice of function"))
651 :group 'matching 651 :group 'matching
652 :version "24.4") 652 :version "24.4")
653 653
@@ -666,21 +666,35 @@ via \\<minibuffer-local-map>\\[next-history-element]."
666 666
667(defun read-regexp (prompt &optional defaults history) 667(defun read-regexp (prompt &optional defaults history)
668 "Read and return a regular expression as a string. 668 "Read and return a regular expression as a string.
669When PROMPT doesn't end with a colon and space, it adds a final \": \". 669Prompt with the string PROMPT. If PROMPT ends in \":\" (followed by
670If the first element of DEFAULTS is non-nil, it's added to the prompt. 670optional whitespace), use it as-is. Otherwise, add \": \" to the end,
671 671possible preceded by the default result (see below).
672Optional arg DEFAULTS has the form (DEFAULT . SUGGESTIONS) 672
673or simply DEFAULT where DEFAULT, if non-nil, should be a string that 673The optional argument DEFAULTS can be either: nil, a string, a list
674is returned as the default value when the user enters empty input. 674of strings, or a symbol. We use DEFAULTS to construct the default
675SUGGESTIONS is a list of strings that can be inserted into 675return value in case of empty input.
676the minibuffer using \\<minibuffer-local-map>\\[next-history-element]. \ 676
677The values supplied in SUGGESTIONS 677If DEFAULTS is a string, we use it as-is.
678are prepended to the list of standard suggestions returned by 678
679`read-regexp-suggestions'. The default values can be customized 679If DEFAULTS is a list of strings, the first element is the
680by `read-regexp-defaults-function'. 680default return value, but all the elements are accessible
681 681using the history command \\<minibuffer-local-map>\\[next-history-element].
682Optional arg HISTORY is a symbol to use for the history list. 682
683If HISTORY is nil, `regexp-history' is used." 683If DEFAULTS is a non-nil symbol, then if `read-regexp-defaults-function'
684is non-nil, we use that in place of DEFAULTS in the following:
685 If DEFAULTS is the symbol `regexp-history-last', we use the first
686 element of HISTORY (if specified) or `regexp-history'.
687 If DEFAULTS is a function, we call it with no arguments and use
688 what it returns, which should be either nil, a string, or a list of strings.
689
690We append the standard values from `read-regexp-suggestions' to DEFAULTS
691before using it.
692
693If the first element of DEFAULTS is non-nil (and if PROMPT does not end
694in \":\", followed by optional whitespace), we add it to the prompt.
695
696The optional argument HISTORY is a symbol to use for the history list.
697If nil, uses `regexp-history'."
684 (let* ((defaults 698 (let* ((defaults
685 (if (and defaults (symbolp defaults)) 699 (if (and defaults (symbolp defaults))
686 (cond 700 (cond