ag.el icon indicating copy to clipboard operation
ag.el copied to clipboard

Provide a tip if user just re-types the string at point

Open Wilfred opened this issue 9 years ago • 2 comments

If the region is active, we should probably pre-populate the input anyway. The M-down shortcut is not discoverable.

Wilfred avatar Apr 29 '16 09:04 Wilfred

Other thoughts: we should truncate the default input if it's too long. If there's nothing at point, and nothing selected, offer the previous search input as the default.

Wilfred avatar Sep 28 '16 19:09 Wilfred

i've been using this hack locally for a few days and i'm actually quite happy with how it works in practice:

modified   Emacs/elpa/ag-20160731.1323/ag.el
@@ -112,6 +112,12 @@ If set to nil, fall back to finding VCS root directories."
   :type '(repeat (string))
   :group 'ag)

+(defcustom ag-editable-default nil
+  "Non-nil means the default search string is editable when reading
+from the minibuffer."
+  :type 'boolean
+  :group 'ag)
+
 (require 'compile)

 ;; Although ag results aren't exactly errors, we treat them as errors
@@ -476,14 +482,15 @@ If called with a prefix, prompts for flags to pass to ag."
 If there's a string at point, offer that as a default."
   (let* ((suggested (ag/dwim-at-point))
          (final-prompt
-          (if suggested
+          (if (and suggested (not ag-editable-default))
               (format "%s (default %s): " prompt suggested)
             (format "%s: " prompt)))
          ;; Ask the user for input, but add `suggested' to the history
          ;; so they can use M-n if they want to modify it.
          (user-input (read-from-minibuffer
                       final-prompt
-                      nil nil nil nil suggested)))
+                      (when ag-editable-default suggested)
+                      nil nil nil suggested)))
     ;; Return the input provided by the user, or use `suggested' if
     ;; the input was empty.
     (if (> (length user-input) 0)

to delete the whole line from the minibuffer, i use C-u (readline/bash style) so for me it's quite simple to replace the suggested search string.

wbolster avatar Sep 28 '16 20:09 wbolster