diff options
| author | Glenn Morris | 2014-02-13 23:36:42 -0800 |
|---|---|---|
| committer | Glenn Morris | 2014-02-13 23:36:42 -0800 |
| commit | b8630261dda1988bd1cabe7fc1b567b6e140eabb (patch) | |
| tree | f0c5bb6f392ab72b6a899a877b183232b986dfbc /lisp/replace.el | |
| parent | b2bf2a254fba3ec86fb763a95289f51251428ac4 (diff) | |
| download | emacs-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.el | 64 |
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 | ||
| 451 | Non-interactively, TO-STRINGS may be a list of replacement strings. | 451 | Non-interactively, TO-STRINGS may be a list of replacement strings. |
| 452 | 452 | ||
| 453 | Interactively, reads the regexp using `read-regexp'. | ||
| 453 | Use \\<minibuffer-local-map>\\[next-history-element] \ | 454 | Use \\<minibuffer-local-map>\\[next-history-element] \ |
| 454 | to pull the last incremental search regexp to the minibuffer | 455 | to pull the last incremental search regexp to the minibuffer |
| 455 | that reads REGEXP. | 456 | that 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'. |
| 631 | This function should take no arguments and return one of nil, a | 632 | This function should take no arguments and return one of: nil, a |
| 632 | regexp or a list of regexps. The return value of this function is used | 633 | regexp, or a list of regexps. Interactively, `read-regexp' uses |
| 633 | as DEFAULTS param of `read-regexp'. This function is called only during | 634 | the return value of this function for its DEFAULT argument. |
| 634 | interactive use. | ||
| 635 | 635 | ||
| 636 | If you need different defaults for different commands, | 636 | As an example, set this variable to `find-tag-default-as-regexp' |
| 637 | use `this-command' to identify the command under execution. | 637 | to default to the symbol at point. |
| 638 | 638 | ||
| 639 | You can customize `read-regexp-defaults-function' to the value | 639 | To provide different default regexps for different commands, |
| 640 | `find-tag-default-as-regexp' to highlight a symbol at point." | 640 | the 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. |
| 669 | When PROMPT doesn't end with a colon and space, it adds a final \": \". | 669 | Prompt with the string PROMPT. If PROMPT ends in \":\" (followed by |
| 670 | If the first element of DEFAULTS is non-nil, it's added to the prompt. | 670 | optional whitespace), use it as-is. Otherwise, add \": \" to the end, |
| 671 | 671 | possible preceded by the default result (see below). | |
| 672 | Optional arg DEFAULTS has the form (DEFAULT . SUGGESTIONS) | 672 | |
| 673 | or simply DEFAULT where DEFAULT, if non-nil, should be a string that | 673 | The optional argument DEFAULTS can be either: nil, a string, a list |
| 674 | is returned as the default value when the user enters empty input. | 674 | of strings, or a symbol. We use DEFAULTS to construct the default |
| 675 | SUGGESTIONS is a list of strings that can be inserted into | 675 | return value in case of empty input. |
| 676 | the minibuffer using \\<minibuffer-local-map>\\[next-history-element]. \ | 676 | |
| 677 | The values supplied in SUGGESTIONS | 677 | If DEFAULTS is a string, we use it as-is. |
| 678 | are prepended to the list of standard suggestions returned by | 678 | |
| 679 | `read-regexp-suggestions'. The default values can be customized | 679 | If DEFAULTS is a list of strings, the first element is the |
| 680 | by `read-regexp-defaults-function'. | 680 | default return value, but all the elements are accessible |
| 681 | 681 | using the history command \\<minibuffer-local-map>\\[next-history-element]. | |
| 682 | Optional arg HISTORY is a symbol to use for the history list. | 682 | |
| 683 | If HISTORY is nil, `regexp-history' is used." | 683 | If DEFAULTS is a non-nil symbol, then if `read-regexp-defaults-function' |
| 684 | is 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 | |||
| 690 | We append the standard values from `read-regexp-suggestions' to DEFAULTS | ||
| 691 | before using it. | ||
| 692 | |||
| 693 | If the first element of DEFAULTS is non-nil (and if PROMPT does not end | ||
| 694 | in \":\", followed by optional whitespace), we add it to the prompt. | ||
| 695 | |||
| 696 | The optional argument HISTORY is a symbol to use for the history list. | ||
| 697 | If 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 |