update of packages
This commit is contained in:
@@ -158,7 +158,7 @@ Set this to nil to turn that off, which increase performance."
|
||||
("Smartcite" "like parencite in a footnote, and footcite in the body with capitalization")
|
||||
("cite*" "similar to cite, but prints the year or title")
|
||||
("parencite*" "similar to parencite, but prints the year or title")
|
||||
("supercite" "superscripted numeric citation (only in numberic styles)")
|
||||
("supercite" "superscripted numeric citation (only in numeric styles)")
|
||||
|
||||
("autocite" "handles some punctuation nuances")
|
||||
("Autocite" "handles some punctuation nuances with punctuation")
|
||||
@@ -296,7 +296,7 @@ Set this to nil to turn that off, which increase performance."
|
||||
(3 (let ((citation-references (split-string path ";"))
|
||||
(these-results '(:version 3)))
|
||||
;; if the first ref doesn't match a key, it must be a global prefix
|
||||
;; this pops the referenc off.
|
||||
;; this pops the reference off.
|
||||
(when (null (string-match org-ref-citation-key-re (cl-first citation-references)))
|
||||
(setq these-results (append these-results (list :prefix (cl-first citation-references)))
|
||||
citation-references (cdr citation-references)))
|
||||
@@ -543,6 +543,7 @@ PATH has the citations in it."
|
||||
(bibtex-copy-entry-as-kill)
|
||||
(kill-new (pop bibtex-entry-kill-ring))))
|
||||
"Copy bibtex" :column "Copy")
|
||||
("a" org-ref-add-pdf-at-point "add pdf to library" :column "Copy")
|
||||
("k" (kill-new (car (org-ref-get-bibtex-key-and-file))) "Copy key" :column "Copy")
|
||||
("f" (kill-new (bibtex-completion-apa-format-reference
|
||||
(org-ref-get-bibtex-key-under-cursor)))
|
||||
@@ -930,16 +931,20 @@ arg COMMON, edit the common prefixes instead."
|
||||
(setq prefix (concat
|
||||
(read-string "prenote: "
|
||||
(string-trim
|
||||
(plist-get
|
||||
(nth index (plist-get data :references))
|
||||
:prefix)))
|
||||
(or
|
||||
(plist-get
|
||||
(nth index (plist-get data :references))
|
||||
:prefix)
|
||||
"")))
|
||||
" ")
|
||||
suffix (concat " "
|
||||
(read-string "postnote: "
|
||||
(string-trim
|
||||
(plist-get
|
||||
(nth index (plist-get data :references))
|
||||
:suffix))))
|
||||
(or
|
||||
(plist-get
|
||||
(nth index (plist-get data :references))
|
||||
:suffix)
|
||||
""))))
|
||||
delta (- (length (plist-get
|
||||
(nth index (plist-get data :references))
|
||||
:prefix))
|
||||
@@ -955,8 +960,8 @@ arg COMMON, edit the common prefixes instead."
|
||||
nil suffix))))
|
||||
|
||||
|
||||
(setf (buffer-substring (org-element-property :begin cite) (org-element-property :end cite))
|
||||
(format "[[%s:%s]]" type (org-ref-interpret-cite-data data)))
|
||||
(cl--set-buffer-substring (org-element-property :begin cite) (org-element-property :end cite)
|
||||
(format "[[%s:%s]]" type (org-ref-interpret-cite-data data)))
|
||||
|
||||
;; This doesn't exactly save the point. I need a fancier calculation for
|
||||
;; that I think that accounts for the change due to the prefix change. e.g.
|
||||
@@ -995,41 +1000,79 @@ arg COMMON, edit the common prefixes instead."
|
||||
(defun org-ref-get-bibtex-key-under-cursor ()
|
||||
"Return key under the cursor in org-mode.
|
||||
If not on a key, but on a cite, prompt for key."
|
||||
(if-let ((key (get-text-property (point) 'cite-key)))
|
||||
;; Point is on a key, so we get it directly
|
||||
key
|
||||
;; point is not on a key, but may still be on a cite link
|
||||
(let ((el (org-element-context))
|
||||
data
|
||||
keys)
|
||||
(cond
|
||||
;; on a cite-link type
|
||||
((and
|
||||
(eq (org-element-type el) 'link)
|
||||
(assoc (org-element-property :type el) org-ref-cite-types))
|
||||
|
||||
(goto-char (org-element-property :begin el))
|
||||
(setq data (org-ref-parse-cite-path (org-element-property :path el))
|
||||
keys (cl-loop for ref in (plist-get data :references)
|
||||
collect (plist-get ref :key)))
|
||||
(cond
|
||||
(org-ref-activate-cite-links
|
||||
(if-let ((key (get-text-property (point) 'cite-key)))
|
||||
;; Point is on a key, so we get it directly
|
||||
key
|
||||
;; point is not on a key, but may still be on a cite link
|
||||
(let ((el (org-element-context))
|
||||
(cp (point))
|
||||
data
|
||||
keys)
|
||||
(cond
|
||||
((= 1 (length keys))
|
||||
(search-forward (car keys))
|
||||
(goto-char (match-beginning 0)))
|
||||
;; multiple keys
|
||||
(t
|
||||
(setq key (completing-read "Key: " keys))
|
||||
(search-forward key)
|
||||
(goto-char (match-beginning 0))))
|
||||
(get-text-property (point) 'cite-key))
|
||||
;; on a cite-link type
|
||||
((and
|
||||
(eq (org-element-type el) 'link)
|
||||
(assoc (org-element-property :type el) org-ref-cite-types))
|
||||
|
||||
;; somewhere else, but looking at a cite-type see issue #908. links in
|
||||
;; places like keywords are not parsed as links, but they seem to get
|
||||
;; activated, so we can just get onto the key, and then open it.
|
||||
((assoc (thing-at-point 'word) org-ref-cite-types)
|
||||
(save-excursion
|
||||
(when (re-search-forward ":" (line-end-position) t)
|
||||
(get-text-property (point) 'cite-key))))))))
|
||||
(goto-char (org-element-property :begin el))
|
||||
(setq data (org-ref-parse-cite-path (org-element-property :path el))
|
||||
keys (cl-loop for ref in (plist-get data :references)
|
||||
collect (plist-get ref :key)))
|
||||
(cond
|
||||
((= 1 (length keys))
|
||||
(search-forward (car keys))
|
||||
(goto-char (match-beginning 0)))
|
||||
;; multiple keys
|
||||
(t
|
||||
(setq key (completing-read "Key: " keys))
|
||||
(search-forward key)
|
||||
(goto-char (match-beginning 0))))
|
||||
(prog1
|
||||
(get-text-property (point) 'cite-key)
|
||||
(goto-char cp)))
|
||||
|
||||
;; somewhere else, but looking at a cite-type see issue #908. links in
|
||||
;; places like keywords are not parsed as links, but they seem to get
|
||||
;; activated, so we can just get onto the key, and then open it.
|
||||
((assoc (thing-at-point 'word) org-ref-cite-types)
|
||||
(save-excursion
|
||||
(when (re-search-forward ":" (line-end-position) t)
|
||||
(prog1
|
||||
(get-text-property (point) 'cite-key)
|
||||
(goto-char cp)))))))))
|
||||
|
||||
;; org-ref-activate-cite-links is nil so font-lock does not put
|
||||
;; text-properties on keys. We temporarily activate this
|
||||
|
||||
(t
|
||||
(let ((el (org-element-context))
|
||||
(cp (point))
|
||||
(org-ref-activate-cite-links t) ;; temporary
|
||||
data
|
||||
keys
|
||||
)
|
||||
(and
|
||||
(eq (org-element-type el) 'link)
|
||||
(assoc (org-element-property :type el) org-ref-cite-types))
|
||||
(save-excursion
|
||||
;; We activate just this one link
|
||||
(org-ref-cite-activate
|
||||
(org-element-property :begin el)
|
||||
(org-element-property :end el)
|
||||
(org-element-property :path el)
|
||||
nil))
|
||||
;; Now we have to handle some cases.
|
||||
(cond
|
||||
;; on a key, return a key
|
||||
((get-text-property (point) 'cite-key)
|
||||
(get-text-property (point) 'cite-key))
|
||||
;; not on a key, but on a cite. this is lazy, but we just search forward
|
||||
;; to the first key
|
||||
(t
|
||||
(search-forward ":")
|
||||
(get-text-property (point) 'cite-key)))))))
|
||||
|
||||
|
||||
;; ** Shift-arrow sorting of keys in a cite link
|
||||
@@ -1097,7 +1140,8 @@ If not on a key, but on a cite, prompt for key."
|
||||
(link-string (org-element-property :path object))
|
||||
(data (org-ref-parse-cite-path link-string))
|
||||
(references (plist-get data :references))
|
||||
(bibtex-completion-bibliography (org-ref-find-bibliography)))
|
||||
(bibtex-completion-bibliography (org-ref-find-bibliography))
|
||||
current-point)
|
||||
|
||||
(setq references (cl-sort (cl-loop for ref in references collect
|
||||
(append ref (list :year (bibtex-completion-get-value
|
||||
@@ -1107,11 +1151,12 @@ If not on a key, but on a cite, prompt for key."
|
||||
(lambda (x y)
|
||||
(< (string-to-number (plist-get x :year))
|
||||
(string-to-number (plist-get y :year))))))
|
||||
(setq data (plist-put data :references references))
|
||||
(save-excursion
|
||||
(goto-char begin)
|
||||
(re-search-forward link-string)
|
||||
(replace-match (org-ref-interpret-cite-data data)))))
|
||||
(setq data (plist-put data :references references)
|
||||
current-point (point))
|
||||
(goto-char begin)
|
||||
(re-search-forward link-string)
|
||||
(replace-match (org-ref-interpret-cite-data data))
|
||||
(goto-char current-point)))
|
||||
|
||||
|
||||
;;** C-arrow navigation of cite keys
|
||||
@@ -1369,10 +1414,10 @@ Here is an example use:
|
||||
(plist-put data :prefix (cl-first prefix-suffix))
|
||||
(plist-put data :suffix (cl-second prefix-suffix)))
|
||||
(plist-put data :version 3)
|
||||
(setf (buffer-substring (org-element-property :begin cite)
|
||||
(org-element-property :end cite))
|
||||
(format "[[%s:%s]]" (org-element-property :type cite)
|
||||
(org-ref-interpret-cite-data data))))))
|
||||
(cl--set-buffer-substring (org-element-property :begin cite)
|
||||
(org-element-property :end cite)
|
||||
(format "[[%s:%s]]" (org-element-property :type cite)
|
||||
(org-ref-interpret-cite-data data))))))
|
||||
|
||||
|
||||
(provide 'org-ref-citation-links)
|
||||
|
||||
Reference in New Issue
Block a user