dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
471 stars 38 forks source link

extend rg-define-search :format to accept lisp form #76

Closed nverno closed 4 years ago

nverno commented 4 years ago

Extends :format argument to allow evaluation of lisp form, but still respects literal and regexp symbols. Thus, a search function that could replace projectile's ripgrep function could look like (search literal with no prefix, regexp with a prefix) -- closes #74

;;;###autoload(autoload 'my-projectile-rg "my-rg")
(rg-define-search my-projectile-rg
  :query (or (thing-at-point 'symbol) (read-from-minibuffer "Search: "))
  :dir project
  :format (not current-prefix-arg)
  :files (concat
          (mapconcat
           #'identity
           (--map (concat "--glob !" it)
                  (append projectile-globally-ignored-files
                          projectile-globally-ignored-directories)) " "))
  :flags '("--type all"))
coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 83.362% when pulling 715e2032cb19f2c44722214d5f200f6ce34bc5ed on nverno:extend-format into ed638db439e5010d1968a6ce904b7c21383506e8 on dajva:master.

nverno commented 4 years ago

Sure, are you OK with the documentation I added in the code, ie. the following

:format     Specifies if :query is interpreted literally (`literal')
            or as a regexp (`regexp').  If it is a form, eg.
            (not `current-prefix-arg'), and is non-nil the :query is
            interpreted literally, otherwise as a regexp.
            Default is `regexp'.
dajva commented 4 years ago

Yes, that will be super.

dajva commented 4 years ago

And you don't need to bother with generating the info file. I can do that separately. Thanks.

nverno commented 4 years ago

K, added docs and fixed subr name. Thanks!

dajva commented 4 years ago

Thanks