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

Per-object args-to-string #50

Closed
swflint opened this issue Dec 20, 2024 · 2 comments
Closed

Per-object args-to-string #50

swflint opened this issue Dec 20, 2024 · 2 comments
Labels
enhancement:core Change to behavior of p-search

Comments

@swflint
Copy link
Contributor

swflint commented Dec 20, 2024

Would it be possible to make p-search--args-to-string overridable (similar to the lighter function for candidate generators)?

For the denote mapping (see #48), based on the options I provide, I'd like to be able to add custom information about the option state when the whole of the mapping information is hidden.

@zkry
Copy link
Owner

zkry commented Dec 20, 2024

This is a good idea!

@zkry zkry added this to the Initial Release milestone Dec 20, 2024
@zkry zkry added the enhancement:core Change to behavior of p-search label Dec 22, 2024
@zkry
Copy link
Owner

zkry commented Dec 23, 2024

Should be available now as a property :condenced-arg-display-function which can be given to candidate generators and mappings. The function should take three arguments, the input-spec and option-spec and args (alist of combined input and options). For example,

(defconst p-search-candidate-generator-filesystem
  (p-search-candidate-generator-create
   :id 'p-search-candidate-generator-filesystem
   :name "FILESYSTEM"
   :input-spec `((base-directory . (p-search-infix-directory
                                    :key "d"
                                    :description "Directories"
                                    :default-value (lambda () default-directory)))
                 (filename-regexp . (p-search-infix-regexp
                                     :key "f"
                                     :description "Filename Pattern"
                                     :default-value ".*"))
                 (search-tool . (p-search-infix-choices
                                 :key "t"
                                 :description "Search Tool"
                                 :choices (:grep :rg :ag)
                                 :default-value ,(or p-search-default-search-tool :grep))))
   :options-spec '((ignore-pattern . (p-search-infix-regexp
                                      :key "-i" ;; TODO - allow multiple (?)
                                      :description "Ignore Pattern"))
                   (use-git-ignore . (p-search-infix-toggle
                                      :key "-g"
                                      :description "Git ls-files"
                                      :default-value on)))
   :function #'p-search--filesystem-generator-function
   :term-frequency-function #'p-search--filesystem-term-frequency-function
   :lighter-function #'p-search--filesystem-lighter-function
   :condenced-arg-display-function
   (lambda (in opt arg)
     (format "~%s %s %s~" in opt arg))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:core Change to behavior of p-search
Projects
None yet
Development

No branches or pull requests

2 participants