Skip to content

Commit

Permalink
Make minibuffer prompt sensitive to search type
Browse files Browse the repository at this point in the history
This function will also be useful for #89, as it can be advised.
  • Loading branch information
Wilfred committed Feb 19, 2021
1 parent 3ea915f commit ca16c37
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions deadgrep.el
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,18 @@ with a text face property `deadgrep-match-face'."
'action #'deadgrep--search-term
'help-echo "Change search term")

(defun deadgrep--search-prompt (&optional default)
"."
(let ((kind (if (eq deadgrep--search-type 'regexp)
"by regexp" "for text")))
(if default
(format "Search %s (default %s): " kind default)
(format "Search %s: " kind))))

(defun deadgrep--search-term (_button)
(setq deadgrep--search-term
;; TODO: say string or regexp
(read-from-minibuffer
"Search term: "
(deadgrep--search-prompt)
deadgrep--search-term))
(rename-buffer
(deadgrep--buffer-name deadgrep--search-term default-directory) t)
Expand Down Expand Up @@ -1378,9 +1385,7 @@ for a string, offering the current word as a default."
;; TODO: prompt should say search string or search regexp
;; as appropriate.
(prompt
(if sym
(format "Search term (default %s): " sym-name)
"Search term: ")))
(deadgrep--search-prompt sym-name)))
(setq search-term
(read-from-minibuffer
prompt nil nil nil 'deadgrep-history sym-name))
Expand Down

0 comments on commit ca16c37

Please sign in to comment.