X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=e59f91df88044c9559454985759c418b2008d90c;hp=59d499784c5b0c1dd0309bf36ec060d5de31af74;hb=6a424578cb6dc578f4b5a7898637ee3f8d651221;hpb=ad5b189ed8fc69decabec27c14973015d877452a diff --git a/org-ref.org b/org-ref.org index 59d4997..e59f91d 100644 --- a/org-ref.org +++ b/org-ref.org @@ -452,6 +452,7 @@ label:test `((t (:inherit org-link :foreground ,org-ref-ref-color))) "Face for ref links in org-ref.") + (defun org-ref-colorize-links () "Colorize org-ref links." (hi-lock-mode 1) @@ -459,6 +460,7 @@ label:test (highlight-regexp org-ref-label-re 'org-ref-label-face) (highlight-regexp org-ref-ref-re 'org-ref-ref-face)) + (when org-ref-colorize-links (add-hook 'org-mode-hook 'org-ref-colorize-links)) #+END_SRC @@ -3391,9 +3393,52 @@ I like convenience. Here are some aliases for faster typing. * Helm interface [[https://github.com/tmalsburg/helm-bibtex][helm-bibtex]] is a very cool interface to bibtex files. Out of the box though, it is not super convenient for org-ref. Here, we modify it to make it fit our workflow and extend it where needed. +Let us add keywords as a searchable field. +#+BEGIN_SRC emacs-lisp +(setq helm-bibtex-additional-search-fields '(keywords)) +#+END_SRC + +Next, we are going to add keywords to the helm interface. +#+BEGIN_SRC emacs-lisp +(defun helm-bibtex-candidates-formatter (candidates source) + "Formats BibTeX entries for display in results list." + (cl-loop + with width = (with-helm-window (window-width)) + for entry in candidates + for entry = (cdr entry) + for entry-key = (helm-bibtex-get-value entry 'entry-key) + for fields = (--map (helm-bibtex-clean-string + (helm-bibtex-get-value entry it " ")) + '(author title year has-pdf has-note entry-type)) + for fields = (-update-at 0 'helm-bibtex-shorten-authors fields) + for fields = (append fields + (list (or (helm-bibtex-get-value entry 'keywords) + "" ))) + collect + (cons (s-format "$0 $1 $2 $3 $4$5 $6" 'elt + (-zip-with (lambda (f w) (truncate-string-to-width f w 0 ?\s)) + fields (list 36 (- width 85) 4 1 1 7 7))) + entry-key))) + +#+END_SRC + 1. Make the default action to insert selected keys. 2. Make open entry second action #+BEGIN_SRC emacs-lisp :tangle org-ref.el +(defun org-ref-tag-entries (candidates) + "Set tags on selected entries." + (let ((keywords (read-input "Keywords (comma separated): "))) + (loop for key in (helm-marked-candidates) + do + (save-window-excursion + (helm-bibtex-show-entry key) + (bibtex-set-field + "keywords" + (concat + keywords + "," (bibtex-autokey-get-field "keywords"))) + (save-buffer))))) + (setq helm-source-bibtex '((name . "BibTeX entries") (init . helm-bibtex-init) @@ -3403,11 +3448,12 @@ I like convenience. Here are some aliases for faster typing. ("Show entry" . helm-bibtex-show-entry) ("Open PDF file (if present)" . helm-bibtex-open-pdf) ("Open URL or DOI in browser" . helm-bibtex-open-url-or-doi) - ("Insert reference" . helm-bibtex-insert-reference) + ("Insert formatted reference" . helm-bibtex-insert-reference) ("Insert BibTeX key" . helm-bibtex-insert-key) ("Insert BibTeX entry" . helm-bibtex-insert-bibtex) ("Attach PDF to email" . helm-bibtex-add-PDF-attachment) ("Edit notes" . helm-bibtex-edit-notes) + ("Tag entries" . org-ref-tag-entries) )))) #+END_SRC