forked from mirrors/org-mode
org-bibtex: org-bibtex-yank, and misc robustifying
This commit is contained in:
parent
5a07ae6f11
commit
a1b9878623
|
@ -458,7 +458,7 @@ This uses `bibtex-parse-entry'."
|
|||
(clean-space (str) (replace-regexp-in-string
|
||||
"[[:space:]\n\r]+" " " str))
|
||||
(strip-delim (str) ; strip enclosing "..." and {...}
|
||||
(dolist (pair '((34 . 34) (123 . 125)))
|
||||
(dolist (pair '((34 . 34) (123 . 125) (123 . 125)))
|
||||
(when (and (= (aref str 0) (car pair))
|
||||
(= (aref str (1- (length str))) (cdr pair)))
|
||||
(setf str (subseq str 1 (1- (length str)))))) str))
|
||||
|
@ -478,7 +478,8 @@ This uses `bibtex-parse-entry'."
|
|||
(interactive)
|
||||
(when (= (length *org-bibtex-entries*) 0)
|
||||
(error "No entries in `*org-bibtex-entries*'."))
|
||||
(let ((entry (pop *org-bibtex-entries*)))
|
||||
(let ((entry (pop *org-bibtex-entries*))
|
||||
(org-special-properties nil)) ; avoids errors with `org-entry-put'
|
||||
(flet ((get (field) (cdr (assoc field entry))))
|
||||
(org-insert-heading)
|
||||
(insert (get :title))
|
||||
|
@ -491,6 +492,15 @@ This uses `bibtex-parse-entry'."
|
|||
(:key (org-bibtex-put "CUSTOM_ID" (cdr pair)))
|
||||
(otherwise (org-bibtex-put (car pair) (cdr pair))))))))
|
||||
|
||||
(defun org-bibtex-yank ()
|
||||
"If kill ring holds a bibtex entry yank it as an Org-mode headline."
|
||||
(interactive)
|
||||
(let (entry)
|
||||
(with-temp-buffer (yank 1) (setf entry (org-bibtex-read)))
|
||||
(if entry
|
||||
(org-bibtex-write)
|
||||
(error "yanked text does not appear to contain a bibtex entry"))))
|
||||
|
||||
(provide 'org-bibtex)
|
||||
|
||||
;; arch-tag: 83987d5a-01b8-41c7-85bc-77700f1285f5
|
||||
|
|
Loading…
Reference in a new issue