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

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

Merged
merged 1 commit into from
Mar 7, 2020

Conversation

nverno
Copy link
Contributor

@nverno nverno commented Mar 2, 2020

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
Copy link

coveralls commented Mar 2, 2020

Coverage Status

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

Copy link
Owner

@dajva dajva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. Looks great.

Documentation also needs to change in docs/configuration.org.

rg.el Outdated
(eval-when-compile
;; parse :format arg, default (non-nil) means to use regexp, otherwise
;; do a literal search
(defsubst rg--parse-format-literal (format-opt)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package does not use -- convention for internal defs.

@nverno
Copy link
Contributor Author

nverno commented Mar 4, 2020

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
Copy link
Owner

dajva commented Mar 4, 2020

Yes, that will be super.

@dajva
Copy link
Owner

dajva commented Mar 4, 2020

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

@nverno
Copy link
Contributor Author

nverno commented Mar 5, 2020

K, added docs and fixed subr name. Thanks!

@dajva dajva merged commit 5d3080d into dajva:master Mar 7, 2020
@dajva
Copy link
Owner

dajva commented Mar 7, 2020

Thanks

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

Successfully merging this pull request may close these issues.

More flexibility in rg-define-search :format
3 participants