org-bibtex: org-bibtex-yank, and misc robustifying

This commit is contained in:
Eric Schulte 2011-04-23 18:26:22 -06:00
parent 5a07ae6f11
commit a1b9878623
1 changed files with 13 additions and 3 deletions

View File

@ -404,7 +404,7 @@ With optional argument OPTIONAL, also prompt for optional fields."
(goto-char p)
(bibtex-url)))
(recenter 0)) ; Move entry start to beginning of window
;; return t to indicate that the search is done.
;; return t to indicate that the search is done.
t))
;; Finally add the link search function to the right hook.
@ -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