tmalsburg / helm-bibtex

Search and manage bibliographies in Emacs
GNU General Public License v2.0
462 stars 73 forks source link

ivy-bibtex custom history variable #341

Closed mohkale closed 4 years ago

mohkale commented 4 years ago

I've been using ivy-bibtex to insert pdftools links in my org buffers. It's been working pretty well so far, except that I often insert links to the same pdf in multiple places and ivy-bibtex shares its search history with regular ivy so I need to keep going back through irrelevant search terms before reaching the query I last used.

I believe ivy-bibtex would be much nicer if it kept it's own history variable. Here's a simple patch that can get the desired affect.

Thoughts?

@@ -123,6 +123,9 @@
             :caller 'ivy-bibtex-fallback
             :action (lambda (candidate) (bibtex-completion-fallback-action (cdr candidate) search-expression))))

+(defvar ivy-bibtex-history nil
+  "Search history for `ivy-bibtex'")
+
 ;;;###autoload
 (defun ivy-bibtex (&optional arg local-bib)
   "Search BibTeX entries using ivy.
@@ -148,6 +151,7 @@
               candidates
               :preselect preselect
               :caller 'ivy-bibtex
+              :history 'ivy-bibtex-history
               :action ivy-bibtex-default-action)))

 ;;;###autoload
tmalsburg commented 4 years ago

This looks useful. Thanks. Will add it tomorrow or so. It's strange though that this is not handled by ivy directly.

tmalsburg commented 4 years ago

My theory of ivy: it's simpler and faster than helm until they're finished reinventing helm. ;)

mohkale commented 4 years ago

It's strange though that this is not handled by ivy directly.

@tmalsburg I suspect it might be so that history can easily be shared among different completion functions. Same completion history in ivy-find-file and counsel-find-file for example. Or maybe they kinda just expect the developers to decide for themselves if it's worth creating a custom history variable for it (such as in this case).

My theory of ivy: it's simpler and faster than helm until they're finished reinventing helm. ;)

LOL. :laughing:.

tmalsburg commented 4 years ago

Same completion history in ivy-find-file and counsel-find-file

Good point! The PR is merged. Thank you!