mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-06 11:55:48 +00:00
(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.
This commit is contained in:
parent
dffd9d9ad6
commit
360289a661
@ -1005,7 +1005,8 @@ which means to discard all text properties."
|
|||||||
(nreverse result))))
|
(nreverse result))))
|
||||||
|
|
||||||
(defun occur-read-primary-args ()
|
(defun occur-read-primary-args ()
|
||||||
(let* ((default
|
(let* ((default (car regexp-history))
|
||||||
|
(defaults
|
||||||
(list (and transient-mark-mode mark-active
|
(list (and transient-mark-mode mark-active
|
||||||
(regexp-quote
|
(regexp-quote
|
||||||
(buffer-substring-no-properties
|
(buffer-substring-no-properties
|
||||||
@ -1020,12 +1021,20 @@ which means to discard all text properties."
|
|||||||
(regexp-quote (or (car search-ring) ""))
|
(regexp-quote (or (car search-ring) ""))
|
||||||
(car (symbol-value
|
(car (symbol-value
|
||||||
query-replace-from-history-variable))))
|
query-replace-from-history-variable))))
|
||||||
(default (delete-dups (delq nil (delete "" default))))
|
(defaults (delete-dups (delq nil (delete "" defaults))))
|
||||||
|
;; Don't add automatically the car of defaults for empty input
|
||||||
|
(history-add-new-input nil)
|
||||||
(input
|
(input
|
||||||
(read-from-minibuffer
|
(read-from-minibuffer
|
||||||
"List lines matching regexp: "
|
(if default
|
||||||
nil nil nil 'regexp-history default)))
|
(format "List lines matching regexp (default %s): "
|
||||||
(list input
|
(query-replace-descr default))
|
||||||
|
"List lines matching regexp: ")
|
||||||
|
nil nil nil 'regexp-history defaults)))
|
||||||
|
(list (if (equal input "")
|
||||||
|
default
|
||||||
|
(prog1 input
|
||||||
|
(add-to-history 'regexp-history input)))
|
||||||
(when current-prefix-arg
|
(when current-prefix-arg
|
||||||
(prefix-numeric-value current-prefix-arg)))))
|
(prefix-numeric-value current-prefix-arg)))))
|
||||||
|
|
||||||
@ -1123,6 +1132,8 @@ See also `multi-occur'."
|
|||||||
(buffer-list))))))
|
(buffer-list))))))
|
||||||
|
|
||||||
(defun occur-1 (regexp nlines bufs &optional buf-name)
|
(defun occur-1 (regexp nlines bufs &optional buf-name)
|
||||||
|
(unless (and regexp (not (equal regexp "")))
|
||||||
|
(error "Occur doesn't work with the empty regexp"))
|
||||||
(unless buf-name
|
(unless buf-name
|
||||||
(setq buf-name "*Occur*"))
|
(setq buf-name "*Occur*"))
|
||||||
(let (occur-buf
|
(let (occur-buf
|
||||||
|
Loading…
Reference in New Issue
Block a user