From ca16c37ffa5caa5f698bc049012489a2e3071bcc Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Thu, 18 Feb 2021 23:48:42 -0800 Subject: [PATCH] Make minibuffer prompt sensitive to search type This function will also be useful for #89, as it can be advised. --- deadgrep.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/deadgrep.el b/deadgrep.el index 13e27b0..ebf4ac3 100644 --- a/deadgrep.el +++ b/deadgrep.el @@ -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) @@ -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))