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

Feature request: ag-regexp to initialise input prompt with active region #176

Open
heaysa opened this issue Sep 24, 2024 · 0 comments
Open

Comments

@heaysa
Copy link

heaysa commented Sep 24, 2024

On my machine, the output of ag --version is: ag version 2.2.0 Features: +jit +lzma +zlib
My Emacs version is: GNU Emacs 29.4
I'm using: Ubuntu 22

I use ag-regexp for simple searches rather than the ag function. It would be convenient if ag-regexp used ag/read-from-minibuffer as ag does, so that the active region is used as a default search.

Perhaps:

(defun ag-regexp (string directory)
  "Search using ag in a given DIRECTORY for a given regexp.
The regexp should be in PCRE syntax, not Emacs regexp
syntax. STRING defaults to the symbol under point.

If called with a prefix, prompts for flags to pass to ag."
  (interactive (list (ag/read-from-minibuffer "Search string")
                     (read-directory-name "Directory: ")))
  (ag/search string directory :regexp t))

One catch is that an active region returned by ag/read-from-minibuffer will not be escaped to guarantee a matching regex.

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

1 participant