X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=6d69a14b072a55ae10b5c99e5860cc26ff7d66f8;hp=e0c321698a9e8fef054d6a5ea4ad07f2fa88d2ec;hb=53b3fd00bcb4b10930e6ebc334e22e9488694cf7;hpb=df65a98ea7c2c73e802724707ea3f3b063619de7 diff --git a/org-ref.org b/org-ref.org index e0c3216..6d69a14 100644 --- a/org-ref.org +++ b/org-ref.org @@ -1,3 +1,4 @@ +# -*- org-edit-src-content-indentation: 0; -*- #+TITLE: Org-ref - The best reference handling for org-mode #+AUTHOR: John Kitchin #+DATE: April 29, 2014 @@ -3226,7 +3227,17 @@ Sometimes it may be helpful to manually change the order of citations. These fun (org-ref-swap-keys i (- i 1) keys)) (setq keys (mapconcat 'identity keys ",")) ;; and replace the link with the sorted keys - (cl--set-buffer-substring begin end (concat type ":" keys " ")) + (cl--set-buffer-substring + begin end + (concat + type ":" keys + ;; It seems the space at the end can get consumed, so we see if there + ;; is a space, and add it if so. Sometimes there is a comma or period, + ;; then we do not want a space. + (when + (save-excursion + (goto-char end) + (looking-back " ")) " "))) ;; now go forward to key so we can move with the key (re-search-forward key) (goto-char (match-beginning 0))))) @@ -3411,22 +3422,26 @@ Next, we are going to add keywords to the helm interface. This modifies the helm (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) + with width = (with-helm-window (helm-bibtex-window-width)) + for entry in candidates + for entry = (cdr entry) + for entry-key = (helm-bibtex-get-value "=key=" entry) + if (assoc-string "author" entry 'case-fold) + for fields = '("author" "title" "year" "=has-pdf=" "=has-note=" "=type=") + else + for fields = '("editor" "title" "year" "=has-pdf=" "=has-note=" "=type=") + for fields = (--map (helm-bibtex-clean-string + (helm-bibtex-get-value it entry " ")) + fields) + for fields = (-update-at 0 'helm-bibtex-shorten-authors fields) + for fields = (append fields + (list (or (helm-bibtex-get-value "keywords" entry) "" ))) - 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))) + 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 Next, we add some functions to add keywords to a bibtex entry using a helm interface, and a new action to add keywords to entries from helm-bibtex. @@ -3781,7 +3796,7 @@ This is a list of cons cells '((\"description\" . action)). The action function '("Example" . (lambda () (message-box "You did it!"))) t) -;;;###qautoload +;;;###autoload (defun org-ref-cite-click-helm (key) "Open helm for actions on a cite link. subtle points.