Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Wilfred opened this issue Apr 29, 2016 · 2 comments
Open

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

Wilfred opened this issue Apr 29, 2016 · 2 comments

Comments

@Wilfred
Copy link
Owner

Wilfred commented Apr 29, 2016

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

@Wilfred
Copy link
Owner Author

Wilfred commented Sep 28, 2016

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.

@wbolster
Copy link

wbolster commented Sep 28, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants