diff options
| author | Juri Linkov | 2008-05-01 23:55:44 +0000 |
|---|---|---|
| committer | Juri Linkov | 2008-05-01 23:55:44 +0000 |
| commit | 360289a661cb8a72d83683ed5d636eb8d80160a4 (patch) | |
| tree | 64f790a98c6baf4bda3e56d274eaaef6ea5a5abf | |
| parent | dffd9d9ad62e23829304abea77dc3b2b6dacb86c (diff) | |
| download | emacs-360289a661cb8a72d83683ed5d636eb8d80160a4.tar.gz emacs-360289a661cb8a72d83683ed5d636eb8d80160a4.zip | |
(occur-read-primary-args): Set default to the car of
regexp-history and display it in the prompt, but don't add to the
list of minibuffer defaults. Bind history-add-new-input to nil to
not add automatically `default'. For empty input return `default'.
Otherwise, add `input' to regexp-history and return it.
(occur-1): Signal an error for the empty regexp.
| -rw-r--r-- | lisp/replace.el | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index d62da35f082..962b02774d9 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -1005,7 +1005,8 @@ which means to discard all text properties." | |||
| 1005 | (nreverse result)))) | 1005 | (nreverse result)))) |
| 1006 | 1006 | ||
| 1007 | (defun occur-read-primary-args () | 1007 | (defun occur-read-primary-args () |
| 1008 | (let* ((default | 1008 | (let* ((default (car regexp-history)) |
| 1009 | (defaults | ||
| 1009 | (list (and transient-mark-mode mark-active | 1010 | (list (and transient-mark-mode mark-active |
| 1010 | (regexp-quote | 1011 | (regexp-quote |
| 1011 | (buffer-substring-no-properties | 1012 | (buffer-substring-no-properties |
| @@ -1020,12 +1021,20 @@ which means to discard all text properties." | |||
| 1020 | (regexp-quote (or (car search-ring) "")) | 1021 | (regexp-quote (or (car search-ring) "")) |
| 1021 | (car (symbol-value | 1022 | (car (symbol-value |
| 1022 | query-replace-from-history-variable)))) | 1023 | query-replace-from-history-variable)))) |
| 1023 | (default (delete-dups (delq nil (delete "" default)))) | 1024 | (defaults (delete-dups (delq nil (delete "" defaults)))) |
| 1025 | ;; Don't add automatically the car of defaults for empty input | ||
| 1026 | (history-add-new-input nil) | ||
| 1024 | (input | 1027 | (input |
| 1025 | (read-from-minibuffer | 1028 | (read-from-minibuffer |
| 1026 | "List lines matching regexp: " | 1029 | (if default |
| 1027 | nil nil nil 'regexp-history default))) | 1030 | (format "List lines matching regexp (default %s): " |
| 1028 | (list input | 1031 | (query-replace-descr default)) |
| 1032 | "List lines matching regexp: ") | ||
| 1033 | nil nil nil 'regexp-history defaults))) | ||
| 1034 | (list (if (equal input "") | ||
| 1035 | default | ||
| 1036 | (prog1 input | ||
| 1037 | (add-to-history 'regexp-history input))) | ||
| 1029 | (when current-prefix-arg | 1038 | (when current-prefix-arg |
| 1030 | (prefix-numeric-value current-prefix-arg))))) | 1039 | (prefix-numeric-value current-prefix-arg))))) |
| 1031 | 1040 | ||
| @@ -1123,6 +1132,8 @@ See also `multi-occur'." | |||
| 1123 | (buffer-list)))))) | 1132 | (buffer-list)))))) |
| 1124 | 1133 | ||
| 1125 | (defun occur-1 (regexp nlines bufs &optional buf-name) | 1134 | (defun occur-1 (regexp nlines bufs &optional buf-name) |
| 1135 | (unless (and regexp (not (equal regexp ""))) | ||
| 1136 | (error "Occur doesn't work with the empty regexp")) | ||
| 1126 | (unless buf-name | 1137 | (unless buf-name |
| 1127 | (setq buf-name "*Occur*")) | 1138 | (setq buf-name "*Occur*")) |
| 1128 | (let (occur-buf | 1139 | (let (occur-buf |