org-bibtex.el 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. ;;; org-bibtex.el --- Org links to BibTeX entries
  2. ;;
  3. ;; Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
  4. ;;
  5. ;; Author: Bastien Guerry <bzg at altern dot org>
  6. ;; Carsten Dominik <carsten dot dominik at gmail dot com>
  7. ;; Eric Schulte <schulte dot eric at gmail dot com>
  8. ;; Keywords: org, wp, remember
  9. ;; Version: 7.5
  10. ;;
  11. ;; This file is part of GNU Emacs.
  12. ;;
  13. ;; GNU Emacs is free software: you can redistribute it and/or modify
  14. ;; it under the terms of the GNU General Public License as published by
  15. ;; the Free Software Foundation, either version 3 of the License, or
  16. ;; (at your option) any later version.
  17. ;; GNU Emacs is distributed in the hope that it will be useful,
  18. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;; GNU General Public License for more details.
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  23. ;;
  24. ;;; Commentary:
  25. ;;
  26. ;; This file implements links to database entries in BibTeX files.
  27. ;; Instead of defining a special link prefix, it uses the normal file
  28. ;; links combined with a custom search mechanism to find entries
  29. ;; by reference key. And it constructs a nice description tag for
  30. ;; the link that contains the author name, the year and a short title.
  31. ;;
  32. ;; It also stores detailed information about the entry so that
  33. ;; remember templates can access and enter this information easily.
  34. ;;
  35. ;; The available properties for each entry are listed here:
  36. ;;
  37. ;; :author :publisher :volume :pages
  38. ;; :editor :url :number :journal
  39. ;; :title :year :series :address
  40. ;; :booktitle :month :annote :abstract
  41. ;; :key :btype
  42. ;;
  43. ;; Here is an example of a remember template that use some of this
  44. ;; information (:author :year :title :journal :pages):
  45. ;;
  46. ;; (setq org-remember-templates
  47. ;; '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n \
  48. ;; In %:journal, %:pages.")))
  49. ;;
  50. ;; Let's say you want to remember this BibTeX entry:
  51. ;;
  52. ;; @Article{dolev83,
  53. ;; author = {Danny Dolev and Andrew C. Yao},
  54. ;; title = {On the security of public-key protocols},
  55. ;; journal = {IEEE Transaction on Information Theory},
  56. ;; year = 1983,
  57. ;; volume = 2,
  58. ;; number = 29,
  59. ;; pages = {198--208},
  60. ;; month = {Mars}
  61. ;; }
  62. ;;
  63. ;; M-x `org-remember' on this entry will produce this buffer:
  64. ;;
  65. ;; =====================================================================
  66. ;; * READ <== [point here]
  67. ;;
  68. ;; [[file:file.bib::dolev83][Dolev & Yao 1983: security of public key protocols]]
  69. ;;
  70. ;; Danny Dolev and Andrew C. Yao (1983): On the security of public-key protocols
  71. ;; In IEEE Transaction on Information Theory, 198--208.
  72. ;; =====================================================================
  73. ;;
  74. ;; Additionally, the following functions are now available for storing
  75. ;; bibtex entries within Org-mode documents.
  76. ;;
  77. ;; - Run `org-bibtex' to export the current file to a .bib.
  78. ;;
  79. ;; - Run `org-bibtex-check' or `org-bibtex-check-all' to check and
  80. ;; fill in missing field of either the current, or all headlines
  81. ;;
  82. ;; - Run `org-bibtex-create' to add a bibtex entry
  83. ;;
  84. ;; - Use `org-bibtex-read' to read a bibtex entry after `point' or in
  85. ;; the active region, then call `org-bibtex-write' in a .org file to
  86. ;; insert a heading for the read bibtex entry
  87. ;;
  88. ;; - All Bibtex information is taken from the document compiled by
  89. ;; Andrew Roberts from the Bibtex manual, available at
  90. ;; http://www.andy-roberts.net/misc/latex/sessions/bibtex/bibentries.pdf
  91. ;;
  92. ;;; History:
  93. ;;
  94. ;; The link creation part has been part of Org-mode for a long time.
  95. ;;
  96. ;; Creating better remember template information was inspired by a request
  97. ;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
  98. ;; and then implemented by Bastien Guerry.
  99. ;;
  100. ;; Eric Schulte eventually added the functions for translating between
  101. ;; Org-mode headlines and Bibtex entries, and for fleshing out the Bibtex
  102. ;; fields of existing Org-mode headlines.
  103. ;;
  104. ;; Org-mode loads this module by default - if this is not what you want,
  105. ;; configure the variable `org-modules'.
  106. ;;; Code:
  107. (require 'org)
  108. (require 'bibtex)
  109. (defvar description nil) ; dynamically scoped from org.el
  110. (declare-function bibtex-beginning-of-entry "bibtex" ())
  111. (declare-function bibtex-generate-autokey "bibtex" ())
  112. (declare-function bibtex-parse-entry "bibtex" (&optional content))
  113. (declare-function bibtex-url "bibtex" (&optional pos no-browse))
  114. ;;; Bibtex data
  115. (defvar org-bibtex-types
  116. '((:article
  117. (:description . "An article from a journal or magazine")
  118. (:required :author :title :journal :year)
  119. (:optional :volume :number :pages :month :note))
  120. (:book
  121. (:description . "A book with an explicit publisher")
  122. (:required (:editor :author) :title :publisher :year)
  123. (:optional (:volume :number) :series :address :edition :month :note))
  124. (:booklet
  125. (:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
  126. (:required :title)
  127. (:optional :author :howpublished :address :month :year :note))
  128. (:conference
  129. (:description . "")
  130. (:required :author :title :booktitle :year)
  131. (:optional :editor :pages :organization :publisher :address :month :note))
  132. (:inbook
  133. (:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
  134. (:required (:author :editor) :title (:chapter :pages) :publisher :year)
  135. (:optional (:volume :number) :series :type :address :edition :month :note))
  136. (:incollection
  137. (:description . "A part of a book having its own title.")
  138. (:required :author :title :booktitle :publisher :year)
  139. (:optional :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note))
  140. (:inproceedings
  141. (:description . "An article in a conference proceedings")
  142. (:required :author :title :booktitle :year)
  143. (:optional :editor (:volume :number) :series :pages :address :month :organization :publisher :note))
  144. (:manual
  145. (:description . "Technical documentation.")
  146. (:required :title)
  147. (:optional :author :organization :address :edition :month :year :note))
  148. (:mastersthesis
  149. (:description . "A Master’s thesis.")
  150. (:required :author :title :school :year)
  151. (:optional :type :address :month :note))
  152. (:misc
  153. (:description . "Use this type when nothing else fits.")
  154. (:required)
  155. (:optional :author :title :howpublished :month :year :note))
  156. (:phdthesis
  157. (:description . "A PhD thesis.")
  158. (:required :author :title :school :year)
  159. (:optional :type :address :month :note))
  160. (:proceedings
  161. (:description . "The proceedings of a conference.")
  162. (:required :title :year)
  163. (:optional :editor (:volume :number) :series :address :month :organization :publisher :note))
  164. (:techreport
  165. (:description . "A report published by a school or other institution.")
  166. (:required :author :title :institution :year)
  167. (:optional :type :address :month :note))
  168. (:unpublished
  169. (:description . "A document having an author and title, but not formally published.")
  170. (:required :author :title :note)
  171. (:optional :month :year)))
  172. "Bibtex entry types with required and optional parameters.")
  173. (defvar org-bibtex-fields
  174. '((:address . "Usually the address of the publisher or other type of institution. For major publishing houses, van Leunen recommends omitting the information entirely. For small publishers, on the other hand, you can help the reader by giving the complete address.")
  175. (:annote . "An annotation. It is not used by the standard bibliography styles, but may be used by others that produce an annotated bibliography.")
  176. (:author . "The name(s) of the author(s), in the format described in the LaTeX book. Remember, all names are separated with the and keyword, and not commas.")
  177. (:booktitle . "Title of a book, part of which is being cited. See the LaTeX book for how to type titles. For book entries, use the title field instead.")
  178. (:chapter . "A chapter (or section or whatever) number.")
  179. (:crossref . "The database key of the entry being cross referenced.")
  180. (:edition . "The edition of a book for example, 'Second'. This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary.")
  181. (:editor . "Name(s) of editor(s), typed as indicated in the LaTeX book. If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears.")
  182. (:howpublished . "How something strange has been published. The first word should be capitalized.")
  183. (:institution . "The sponsoring institution of a technical report.")
  184. (:journal . "A journal name.")
  185. (:key . "Used for alphabetizing, cross-referencing, and creating a label when the author information is missing. This field should not be confused with the key that appears in the \cite command and at the beginning of the database entry.")
  186. (:month . "The month in which the work was published or, for an unpublished work, in which it was written. You should use the standard three-letter abbreviation,")
  187. (:note . "Any additional information that can help the reader. The first word should be capitalized.")
  188. (:number . "Any additional information that can help the reader. The first word should be capitalized.")
  189. (:organization . "The organization that sponsors a conference or that publishes a manual.")
  190. (:pages . "One or more page numbers or range of numbers, such as 42-111 or 7,41,73-97 or 43+ (the ‘+’ in this last example indicates pages following that don’t form simple range). BibTEX requires double dashes for page ranges (--).")
  191. (:publisher . "The publisher’s name.")
  192. (:school . "The name of the school where a thesis was written.")
  193. (:series . "The name of a series or set of books. When citing an entire book, the the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
  194. (:title . "The work’s title, typed as explained in the LaTeX book.")
  195. (:type . "The type of a technical report for example, 'Research Note'.")
  196. (:volume . "The volume of a journal or multi-volume book.")
  197. (:year . "The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'"))
  198. "Bibtex fields with descriptions.")
  199. (defvar *org-bibtex-entries* nil
  200. "List to hold parsed bibtex entries.")
  201. (defcustom org-bibtex-autogen-keys nil
  202. "Set to a truthy value to use `bibtex-generate-autokey' to generate keys."
  203. :group 'org-bibtex
  204. :type 'boolean)
  205. (defcustom org-bibtex-prefix nil
  206. "Optional prefix for all bibtex property names.
  207. For example setting to 'BIB_' would allow interoperability with fireforg."
  208. :group 'org-bibtex
  209. :type 'string)
  210. ;;; Utility functions
  211. (defun org-bibtex-get (property)
  212. (or (org-entry-get (point) (upcase property))
  213. (org-entry-get (point) (concat org-bibtex-prefix (upcase property)))))
  214. (defun org-bibtex-put (property value)
  215. (let ((prop (upcase (if (keywordp property)
  216. (substring (symbol-name property) 1)
  217. property))))
  218. (org-set-property
  219. (concat (unless (string= "CUSTOM_ID" prop) org-bibtex-prefix) prop)
  220. value)))
  221. (defun org-bibtex-headline ()
  222. "Return a bibtex entry of the given headline as a string."
  223. (flet ((get (key lst) (cdr (assoc key lst)))
  224. (to-k (string) (intern (concat ":" string)))
  225. (from-k (key) (substring (symbol-name key) 1))
  226. (flatten (&rest lsts)
  227. (apply #'append (mapcar
  228. (lambda (e)
  229. (if (listp e) (apply #'flatten e) (list e)))
  230. lsts))))
  231. (let ((notes (buffer-string))
  232. (id (org-bibtex-get "custom_id"))
  233. (type (org-bibtex-get "type")))
  234. (when type
  235. (let ((entry (format
  236. "@%s{%s,\n%s\n}\n" type id
  237. (mapconcat
  238. (lambda (pair) (format " %s={%s}" (car pair) (cdr pair)))
  239. (remove nil
  240. (mapcar
  241. (lambda (field)
  242. (let ((value (or (org-bibtex-get (from-k field))
  243. (and (equal :title field)
  244. (org-get-heading)))))
  245. (when value (cons (from-k field) value))))
  246. (flatten
  247. (get :required (get (to-k type) org-bibtex-types))
  248. (get :optional (get (to-k type) org-bibtex-types)))))
  249. ",\n"))))
  250. (with-temp-buffer
  251. (insert entry)
  252. (bibtex-reformat) (buffer-string)))))))
  253. (defun org-bibtex-ask (field)
  254. (unless (assoc field org-bibtex-fields)
  255. (error "field:%s is not known" field))
  256. (save-window-excursion
  257. (with-temp-buffer
  258. (setf (buffer-name) (format "*Bibtex Help %s*" field))
  259. (insert (cdr (assoc field org-bibtex-fields)))
  260. (fill-paragraph)
  261. (pop-to-buffer (current-buffer))
  262. ((lambda (result) (when (> (length result) 0) result))
  263. (read-from-minibuffer (format "%s " field))))))
  264. (defun org-bibtex-autokey ()
  265. "Generate an autokey for the current headline"
  266. (org-bibtex-put "CUSTOM_ID"
  267. (if org-bibtex-autogen-keys
  268. (let ((entry (org-bibtex-headline)))
  269. (with-temp-buffer
  270. (insert entry)
  271. (bibtex-generate-autokey)))
  272. (read-from-minibuffer "id: "))))
  273. (defun org-bibtex-fleshout (type &optional optional)
  274. "Fleshout the current heading, ensuring that all required fields are present.
  275. With optional argument OPTIONAL, also prompt for optional fields."
  276. (flet ((get (key lst) (cdr (assoc key lst)))
  277. (name (keyword) (upcase (substring (symbol-name keyword) 1))))
  278. (dolist (field (append
  279. (remove :title (get :required (get type org-bibtex-types)))
  280. (when optional (get :optional (get type org-bibtex-types)))))
  281. (when (consp field) ; or'd pair of fields e.g., (:editor :author)
  282. (let ((present (first (remove nil
  283. (mapcar
  284. (lambda (f) (when (org-bibtex-get (name f)) f))
  285. field)))))
  286. (setf field (or present
  287. (intern (org-icompleting-read
  288. "Field: " (mapcar #'symbol-name field)))))))
  289. (let ((name (name field)))
  290. (unless (org-bibtex-get name)
  291. (let ((prop (org-bibtex-ask field)))
  292. (when prop (org-bibtex-put name prop)))))))
  293. (when (and type (assoc type org-bibtex-types)
  294. (not (org-bibtex-get "CUSTOM_ID")))
  295. (org-bibtex-autokey)))
  296. ;;; Bibtex link functions
  297. (org-add-link-type "bibtex" 'org-bibtex-open)
  298. (add-hook 'org-store-link-functions 'org-bibtex-store-link)
  299. (defun org-bibtex-open (path)
  300. "Visit the bibliography entry on PATH."
  301. (let* ((search (when (string-match "::\\(.+\\)\\'" path)
  302. (match-string 1 path)))
  303. (path (substring path 0 (match-beginning 0))))
  304. (org-open-file path t nil search)))
  305. (defun org-bibtex-store-link ()
  306. "Store a link to a BibTeX entry."
  307. (when (eq major-mode 'bibtex-mode)
  308. (let* ((search (org-create-file-search-in-bibtex))
  309. (link (concat "file:" (abbreviate-file-name buffer-file-name)
  310. "::" search))
  311. (entry (mapcar ; repair strings enclosed in "..." or {...}
  312. (lambda(c)
  313. (if (string-match
  314. "^\\(?:{\\|\"\\)\\(.*\\)\\(?:}\\|\"\\)$" (cdr c))
  315. (cons (car c) (match-string 1 (cdr c))) c))
  316. (save-excursion
  317. (bibtex-beginning-of-entry)
  318. (bibtex-parse-entry)))))
  319. (org-store-link-props
  320. :key (cdr (assoc "=key=" entry))
  321. :author (or (cdr (assoc "author" entry)) "[no author]")
  322. :editor (or (cdr (assoc "editor" entry)) "[no editor]")
  323. :title (or (cdr (assoc "title" entry)) "[no title]")
  324. :booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
  325. :journal (or (cdr (assoc "journal" entry)) "[no journal]")
  326. :publisher (or (cdr (assoc "publisher" entry)) "[no publisher]")
  327. :pages (or (cdr (assoc "pages" entry)) "[no pages]")
  328. :url (or (cdr (assoc "url" entry)) "[no url]")
  329. :year (or (cdr (assoc "year" entry)) "[no year]")
  330. :month (or (cdr (assoc "month" entry)) "[no month]")
  331. :address (or (cdr (assoc "address" entry)) "[no address]")
  332. :volume (or (cdr (assoc "volume" entry)) "[no volume]")
  333. :number (or (cdr (assoc "number" entry)) "[no number]")
  334. :annote (or (cdr (assoc "annote" entry)) "[no annotation]")
  335. :series (or (cdr (assoc "series" entry)) "[no series]")
  336. :abstract (or (cdr (assoc "abstract" entry)) "[no abstract]")
  337. :btype (or (cdr (assoc "=type=" entry)) "[no type]")
  338. :type "bibtex"
  339. :link link
  340. :description description))))
  341. (defun org-create-file-search-in-bibtex ()
  342. "Create the search string and description for a BibTeX database entry."
  343. ;; Make a good description for this entry, using names, year and the title
  344. ;; Put it into the `description' variable which is dynamically scoped.
  345. (let ((bibtex-autokey-names 1)
  346. (bibtex-autokey-names-stretch 1)
  347. (bibtex-autokey-name-case-convert-function 'identity)
  348. (bibtex-autokey-name-separator " & ")
  349. (bibtex-autokey-additional-names " et al.")
  350. (bibtex-autokey-year-length 4)
  351. (bibtex-autokey-name-year-separator " ")
  352. (bibtex-autokey-titlewords 3)
  353. (bibtex-autokey-titleword-separator " ")
  354. (bibtex-autokey-titleword-case-convert-function 'identity)
  355. (bibtex-autokey-titleword-length 'infty)
  356. (bibtex-autokey-year-title-separator ": "))
  357. (setq description (bibtex-generate-autokey)))
  358. ;; Now parse the entry, get the key and return it.
  359. (save-excursion
  360. (bibtex-beginning-of-entry)
  361. (cdr (assoc "=key=" (bibtex-parse-entry)))))
  362. (defun org-execute-file-search-in-bibtex (s)
  363. "Find the link search string S as a key for a database entry."
  364. (when (eq major-mode 'bibtex-mode)
  365. ;; Yes, we want to do the search in this file.
  366. ;; We construct a regexp that searches for "@entrytype{" followed by the key
  367. (goto-char (point-min))
  368. (and (re-search-forward (concat "@[a-zA-Z]+[ \t\n]*{[ \t\n]*"
  369. (regexp-quote s) "[ \t\n]*,") nil t)
  370. (goto-char (match-beginning 0)))
  371. (if (and (match-beginning 0) (equal current-prefix-arg '(16)))
  372. ;; Use double prefix to indicate that any web link should be browsed
  373. (let ((b (current-buffer)) (p (point)))
  374. ;; Restore the window configuration because we just use the web link
  375. (set-window-configuration org-window-config-before-follow-link)
  376. (with-current-buffer b
  377. (goto-char p)
  378. (bibtex-url)))
  379. (recenter 0)) ; Move entry start to beginning of window
  380. ;; return t to indicate that the search is done.
  381. t))
  382. ;; Finally add the link search function to the right hook.
  383. (add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex)
  384. ;;; Bibtex <-> Org-mode headline translation functions
  385. (defun org-bibtex ()
  386. "Export each headline in the current file to a bibtex entry.
  387. Headlines are exported using `org-bibtex-export-headline'."
  388. (interactive)
  389. (let ((bibtex-entries (remove nil (org-map-entries #'org-bibtex-headline))))
  390. (with-temp-file (concat (file-name-sans-extension (buffer-file-name)) ".bib")
  391. (insert (mapconcat #'identity bibtex-entries "\n")))))
  392. (defun org-bibtex-check (&optional optional)
  393. "Check the current headline for required fields.
  394. With prefix argument OPTIONAL also prompt for optional fields."
  395. (interactive "P")
  396. (save-restriction
  397. (org-narrow-to-subtree)
  398. (let ((type ((lambda (name) (when name (intern (concat ":" name))))
  399. (org-bibtex-get "TYPE"))))
  400. (when type (org-bibtex-fleshout type optional)))))
  401. (defun org-bibtex-check-all (&optional optional)
  402. "Check all headlines in the current file.
  403. With prefix argument OPTIONAL also prompt for optional fields."
  404. (interactive) (org-map-entries (lambda () (org-bibtex-check optional))))
  405. (defun org-bibtex-create (type)
  406. "Create a new entry at the given level."
  407. (interactive
  408. (list (org-icompleting-read
  409. "Type:"
  410. (mapcar (lambda (type) (symbol-name (car type))) org-bibtex-types))))
  411. (let ((type (if (keywordp type) type (intern type))))
  412. (unless (assoc type org-bibtex-types)
  413. (error "type:%s is not known" type))
  414. (org-insert-heading)
  415. (let ((title (org-bibtex-ask :title)))
  416. (insert title) (org-bibtex-put "TITLE" title))
  417. (org-bibtex-put "TYPE" (substring (symbol-name type) 1))
  418. (org-bibtex-fleshout type)))
  419. (defun org-bibtex-read ()
  420. "Read a bibtex entry and save to `*org-bibtex-entries*'.
  421. This uses `bibtex-parse-entry'."
  422. (interactive)
  423. (flet ((keyword (str) (intern (concat ":" (downcase str))))
  424. (clean-space (str) (replace-regexp-in-string
  425. "[[:space:]\n\r]+" " " str))
  426. (strip-delim (str) ; strip enclosing "..." and {...}
  427. (dolist (pair '((34 . 34) (123 . 125)))
  428. (when (and (= (aref str 0) (car pair))
  429. (= (aref str (1- (length str))) (cdr pair)))
  430. (setf str (subseq str 1 (1- (length str)))))) str))
  431. (push (mapcar
  432. (lambda (pair)
  433. (cons (let ((field (keyword (car pair))))
  434. (case field
  435. (:=type= :type)
  436. (:=key= :key)
  437. (otherwise field)))
  438. (clean-space (strip-delim (cdr pair)))))
  439. (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
  440. *org-bibtex-entries*)))
  441. (defun org-bibtex-write ()
  442. "Insert a heading built from the first element of `*org-bibtex-entries*'."
  443. (interactive)
  444. (when (= (length *org-bibtex-entries*) 0)
  445. (error "No entries in `*org-bibtex-entries*'."))
  446. (let ((entry (pop *org-bibtex-entries*)))
  447. (flet ((get (field) (cdr (assoc field entry))))
  448. (org-insert-heading)
  449. (insert (get :title))
  450. (org-bibtex-put "TITLE" (get :title))
  451. (org-bibtex-put "TYPE" (downcase (get :type)))
  452. (dolist (pair entry)
  453. (case (car pair)
  454. (:title nil)
  455. (:type nil)
  456. (:key (org-bibtex-put "CUSTOM_ID" (cdr pair)))
  457. (otherwise (org-bibtex-put (car pair) (cdr pair))))))))
  458. (provide 'org-bibtex)
  459. ;; arch-tag: 83987d5a-01b8-41c7-85bc-77700f1285f5
  460. ;;; org-bibtex.el ends here