org-mode/lisp/ol-bibtex.el

767 lines
32 KiB
EmacsLisp
Raw Normal View History

;;; ol-bibtex.el --- Links to BibTeX entries -*- lexical-binding: t; -*-
;;
2021-01-01 19:55:31 +00:00
;; Copyright (C) 2007-2021 Free Software Foundation, Inc.
;;
;; Authors: Bastien Guerry <bzg@gnu.org>
2012-04-01 22:53:28 +00:00
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Eric Schulte <schulte dot eric at gmail dot com>
;; Keywords: org, wp, capture
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This file implements links to database entries in BibTeX files.
;; Instead of defining a special link prefix, it uses the normal file
;; links combined with a custom search mechanism to find entries
2008-12-16 14:31:29 +00:00
;; by reference key. And it constructs a nice description tag for
;; the link that contains the author name, the year and a short title.
;;
;; It also stores detailed information about the entry so that
;; capture templates can access and enter this information easily.
;;
;; The available properties for each entry are listed here:
;;
;; :author :publisher :volume :pages
;; :editor :url :number :journal
;; :title :year :series :address
;; :booktitle :month :annote :abstract
;; :key :btype
2008-04-24 08:29:47 +00:00
;;
;; Here is an example of a capture template that use some of this
;; information (:author :year :title :journal :pages):
2008-04-24 08:29:47 +00:00
;;
;; (setq org-capture-templates
;; '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n \
;; In %:journal, %:pages.")))
2008-04-24 08:29:47 +00:00
;;
;; Let's say you want to capture this BibTeX entry:
2008-04-24 08:29:47 +00:00
;;
;; @Article{dolev83,
;; author = {Danny Dolev and Andrew C. Yao},
;; title = {On the security of public-key protocols},
;; journal = {IEEE Transaction on Information Theory},
;; year = 1983,
;; volume = 2,
;; number = 29,
;; pages = {198--208},
;; month = {Mars}
;; }
2008-04-24 08:29:47 +00:00
;;
;; M-x `org-capture' on this entry will produce this buffer:
2008-04-24 08:29:47 +00:00
;;
;; =====================================================================
;; * READ <== [point here]
2008-04-24 08:29:47 +00:00
;;
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;; [[file:file.bib::dolev83][Dolev & Yao 1983: security of public key protocols]]
2008-04-24 08:29:47 +00:00
;;
;; Danny Dolev and Andrew C. Yao (1983): On the security of public-key protocols
;; In IEEE Transaction on Information Theory, 198--208.
;; =====================================================================
;;
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;; Additionally, the following functions are now available for storing
;; bibtex entries within Org documents.
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;
;; - Run `org-bibtex' to export the current file to a .bib.
;;
;; - Run `org-bibtex-check' or `org-bibtex-check-all' to check and
;; fill in missing field of either the current, or all headlines
;;
;; - Run `org-bibtex-create' to add a bibtex entry
;;
;; - Use `org-bibtex-read' to read a bibtex entry after `point' or in
;; the active region, then call `org-bibtex-write' in a .org file to
;; insert a heading for the read bibtex entry
;;
;; - All Bibtex information is taken from the document compiled by
;; Andrew Roberts from the Bibtex manual, available at
2021-03-21 18:55:14 +00:00
;; https://www.andy-roberts.net/res/writing/latex/bibentries.pdf
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;
;;; History:
2008-04-24 08:29:47 +00:00
;;
;; The link creation part has been part of Org for a long time.
2008-04-24 08:29:47 +00:00
;;
;; Creating better capture template information was inspired by a request
;; of Austin Frank: https://orgmode.org/list/m0myu03vbx.fsf@gmail.com
2009-11-12 12:39:29 +00:00
;; and then implemented by Bastien Guerry.
;;
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;; Eric Schulte eventually added the functions for translating between
;; Org headlines and Bibtex entries, and for fleshing out the Bibtex
;; fields of existing Org headlines.
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;
;; Org mode loads this module by default - if this is not what you want,
;; configure the variable `org-modules'.
;;; Code:
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(require 'bibtex)
(require 'cl-lib)
2012-08-13 03:59:44 +00:00
(require 'org-compat)
(require 'org-macs)
(require 'ol)
(defvar org-agenda-overriding-header)
(defvar org-agenda-search-view-always-boolean)
(defvar org-bibtex-description nil) ; dynamically scoped from org.el
(defvar org-id-locations)
(defvar org-property-end-re)
(defvar org-special-properties)
(defvar org-window-config-before-follow-link)
(declare-function bibtex-beginning-of-entry "bibtex" ())
(declare-function bibtex-generate-autokey "bibtex" ())
(declare-function bibtex-parse-entry "bibtex" (&optional content))
(declare-function bibtex-url "bibtex" (&optional pos no-browse))
(declare-function org-back-to-heading "org" (&optional invisible-ok))
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
(declare-function org-entry-properties "org" (&optional pom which))
(declare-function org-get-tags "org" (&optional pos local))
(declare-function org-heading-components "org" ())
(declare-function org-insert-heading "org" (&optional arg invisible-ok top))
(declare-function org-map-entries "org" (func &optional match scope &rest skip))
(declare-function org-narrow-to-subtree "org" ())
(declare-function org-set-property "org" (property value))
(declare-function org-toggle-tag "org" (tag &optional onoff))
(declare-function org-search-view "org-agenda" (&optional todo-only string edit-at))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;; Bibtex data
(defvar org-bibtex-types
'((:article
(:description . "An article from a journal or magazine")
(:required :author :title :journal :year)
(:optional :volume :number :pages :month :note))
(:book
(:description . "A book with an explicit publisher")
(:required (:editor :author) :title :publisher :year)
(:optional (:volume :number) :series :address :edition :month :note))
(:booklet
(:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
(:required :title)
(:optional :author :howpublished :address :month :year :note))
(:conference
(:description . "")
(:required :author :title :booktitle :year)
(:optional :editor :pages :organization :publisher :address :month :note))
(:inbook
(:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
(:required (:author :editor) :title (:chapter :pages) :publisher :year)
(:optional :crossref (:volume :number) :series :type :address :edition :month :note))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:incollection
(:description . "A part of a book having its own title.")
(:required :author :title :booktitle :publisher :year)
(:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:inproceedings
(:description . "An article in a conference proceedings")
(:required :author :title :booktitle :year)
(:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:manual
(:description . "Technical documentation.")
(:required :title)
(:optional :author :organization :address :edition :month :year :note))
(:mastersthesis
(:description . "A Masters thesis.")
(:required :author :title :school :year)
(:optional :type :address :month :note))
(:misc
(:description . "Use this type when nothing else fits.")
(:required)
(:optional :author :title :howpublished :month :year :note))
(:phdthesis
(:description . "A PhD thesis.")
(:required :author :title :school :year)
(:optional :type :address :month :note))
(:proceedings
(:description . "The proceedings of a conference.")
(:required :title :year)
(:optional :editor (:volume :number) :series :address :month :organization :publisher :note))
(:techreport
(:description . "A report published by a school or other institution.")
(:required :author :title :institution :year)
(:optional :type :address :month :note))
(:unpublished
(:description . "A document having an author and title, but not formally published.")
(:required :author :title :note)
(:optional :month :year)))
"Bibtex entry types with required and optional parameters.")
(defvar org-bibtex-fields
'((: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.")
(:annote . "An annotation. It is not used by the standard bibliography styles, but may be used by others that produce an annotated bibliography.")
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(: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.")
(: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.")
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:chapter . "A chapter (or section or whatever) number.")
(:crossref . "The database key of the entry being cross referenced.")
(: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.")
(: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.")
(:howpublished . "How something strange has been published. The first word should be capitalized.")
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:institution . "The sponsoring institution of a technical report.")
(:journal . "A journal name.")
(: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.")
(: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,")
(:note . "Any additional information that can help the reader. The first word should be capitalized.")
(:number . "Any additional information that can help the reader. The first word should be capitalized.")
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:organization . "The organization that sponsors a conference or that publishes a manual.")
(: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 dont form simple range). BibTEX requires double dashes for page ranges (--).")
(:publisher . "The publishers name.")
(:school . "The name of the school where a thesis was written.")
(:series . "The name of a series or set of books. When citing an entire book, 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.")
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:title . "The works title, typed as explained in the LaTeX book.")
(:type . "The type of a technical report for example, 'Research Note'.")
(:volume . "The volume of a journal or multi-volume book.")
(: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)'"))
"Bibtex fields with descriptions.")
(defvar org-bibtex-entries nil
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
"List to hold parsed bibtex entries.")
(defcustom org-bibtex-autogen-keys nil
"Set to a truth value to use `bibtex-generate-autokey' to generate keys."
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
:type 'boolean)
(defcustom org-bibtex-prefix nil
"Optional prefix for all bibtex property names.
For example setting to `BIB_' would allow interoperability with fireforg."
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type '(choice
(const nil)
(string)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defcustom org-bibtex-treat-headline-as-title t
"Treat headline text as title if title property is absent.
If an entry is missing a title property, use the headline text as
the property. If this value is t, `org-bibtex-check' will ignore
a missing title field."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type 'boolean)
(defcustom org-bibtex-headline-format-function
(lambda (entry) (cdr (assq :title entry)))
"Function returning the headline text for `org-bibtex-write'.
It should take a single argument, the bibtex entry (an alist as
returned by `org-bibtex-read'). The default value simply returns
the entry title."
:group 'org-bibtex
:version "26.1"
:package-version '(Org . "9.1")
:type 'function)
(defcustom org-bibtex-export-arbitrary-fields nil
"When converting to bibtex allow fields not defined in `org-bibtex-fields'.
This only has effect if `org-bibtex-prefix' is defined, so as to
ensure that other org-properties, such as CATEGORY or LOGGING are
not placed in the exported bibtex entry."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type 'boolean)
(defcustom org-bibtex-key-property "CUSTOM_ID"
"Property that holds the bibtex key.
By default, this is CUSTOM_ID, which enables easy linking to
bibtex headlines from within an org file. This can be set to ID
to enable global links, but only with great caution, as global
IDs must be unique."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type 'string)
(defcustom org-bibtex-tags nil
"List of tag(s) that should be added to new bib entries."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type '(repeat :tag "Tag" (string)))
(defcustom org-bibtex-tags-are-keywords nil
"Convert the value of the keywords field to tags and vice versa.
When non-nil, comma-separated entries in a bibtex entry's keywords
field will be converted to Org tags. Note: spaces will be escaped
with underscores, and characters that are not permitted in Org
tags will be removed.
When non-nil, local tags in an Org entry will be exported as
a comma-separated string of keywords when exported to bibtex.
If `org-bibtex-inherit-tags' is non-nil, inherited tags will also
be exported as keywords. Tags defined in `org-bibtex-tags' or
`org-bibtex-no-export-tags' will not be exported."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type 'boolean)
(defcustom org-bibtex-no-export-tags nil
"List of tag(s) that should not be converted to keywords.
This variable is relevant only if `org-bibtex-tags-are-keywords'
is non-nil."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type '(repeat :tag "Tag" (string)))
(defcustom org-bibtex-inherit-tags nil
"Controls whether inherited tags are converted to bibtex keywords.
It is relevant only if `org-bibtex-tags-are-keywords' is non-nil.
Tag inheritance itself is controlled by `org-use-tag-inheritance'
and `org-tags-exclude-from-inheritance'."
:group 'org-bibtex
Change :version in defcustoms from "25.2" to "26.1" * lisp/ob-J.el (org-babel-J-command): * lisp/ob-core.el (org-babel-hash-show-time): * lisp/ob-exp.el (org-babel-exp-inline-code-template): * lisp/ob-lisp.el (org-babel-lisp-eval-fn): * lisp/org-agenda.el (org-agenda-view-columns-initially): * lisp/org-attach.el (org-attach-commit): (org-attach-archive-delete): (org-attach-annex-auto-get): * lisp/org-bibtex.el (org-bibtex-inherit-tags): * lisp/org-clock.el (org-clock-into-drawer): * lisp/org-colview.el (org-columns-summary-types): * lisp/org-faces.el (org-block): * lisp/org-src.el (org-src-block-faces): * lisp/org-table.el (org-table-copy-increment): (org-table-formula-create-columns): (org-table-convert-region-max-lines): * lisp/org-timer.el (org-timer-default-timer): * lisp/org.el (org-export-backends): (org-show-context-detail): (org-cycle-hook): (org-occur-case-fold-search): (org-preview-latex-default-process): (org-preview-latex-process-alist): (org-preview-latex-image-directory): (org-latex-default-packages-alist): (org-sparse-tree-default-date-type): (org-structure-template-alist): (org-effort-durations): (org-agenda-ignore-properties): Change :version from "25.2" to "26.1". (customize-package-emacs-version-alist): Fix associations between Org and Emacs releases. * lisp/ox-ascii.el (org-ascii-list-margin): * lisp/ox-beamer.el (org-beamer-subtitle-format): * lisp/ox-html.el (org-html-format-headline-function): (org-html-format-inlinetask-function): (org-html-viewport): * lisp/ox-latex.el (org-latex-caption-above): (org-latex-prefer-user-labels): (org-latex-subtitle-format): (org-latex-hyperref-template): (org-latex-footnote-defined-format): (org-latex-images-centered): (org-latex-default-figure-position): (org-latex-text-markup-alist): (org-latex-format-inlinetask-function): (org-latex-custom-lang-environments): (org-latex-compiler-file-string): (org-latex-compiler): (org-latex-bib-compiler): (org-latex-logfiles-extensions): (org-latex-known-warnings): * lisp/ox-md.el (org-md-footnotes-section): (org-md-footnote-format): * lisp/ox-odt.el (org-odt-format-headline-function): (org-odt-format-inlinetask-function): (org-odt-inline-image-rules): * lisp/ox-texinfo.el (org-texinfo-format-headline-function): * lisp/ox.el (org-export-with-creator): (org-export-with-title): (org-export-with-broken-links): (org-export-copy-to-kill-ring): Change :version from "25.2" to "26.1". It looks like the goal is to sync Org 9.0.* (maint) with the Emacs master branch (what will be version 26.1): https://lists.gnu.org/archive/html/emacs-orgmode/2017-01/msg00558.html
2017-01-26 04:39:18 +00:00
:version "26.1"
:package-version '(Org . "8.3")
:type 'boolean)
(defcustom org-bibtex-type-property-name "btype"
"Property in which to store bibtex entry type (e.g., article)."
:group 'org-bibtex
2012-04-03 11:21:04 +00:00
:version "24.1"
:type 'string)
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;; Utility functions
(defun org-bibtex-get (property)
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(let ((it (let ((org-special-properties
(delete "FILE" (copy-sequence org-special-properties))))
(or
(org-entry-get (point) (upcase property))
(org-entry-get (point) (concat org-bibtex-prefix
(upcase property)))))))
(when it (org-trim it))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-put (property value)
(let ((prop (upcase (if (keywordp property)
(substring (symbol-name property) 1)
property))))
(org-set-property
(concat (unless (string= org-bibtex-key-property prop) org-bibtex-prefix)
prop)
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
value)))
(defun org-bibtex-headline ()
"Return a bibtex entry of the given headline as a string."
(letrec ((val (lambda (key lst) (cdr (assoc key lst))))
(to (lambda (string) (intern (concat ":" string))))
(from (lambda (key) (substring (symbol-name key) 1)))
(flatten (lambda (&rest lsts)
(apply #'append (mapcar
(lambda (e)
(if (listp e) (apply flatten e) (list e)))
lsts))))
(id (org-bibtex-get org-bibtex-key-property))
(type (org-bibtex-get org-bibtex-type-property-name))
(tags (when org-bibtex-tags-are-keywords
(delq nil
(mapcar
(lambda (tag)
(unless (member tag
(append org-bibtex-tags
org-bibtex-no-export-tags))
tag))
(if org-bibtex-inherit-tags (org-get-tags)
(org-get-tags nil t)))))))
(when type
(let ((entry (format
"@%s{%s,\n%s\n}\n" type id
(mapconcat
(lambda (pair)
(format " %s={%s}" (car pair) (cdr pair)))
(remove nil
(if (and org-bibtex-export-arbitrary-fields
org-bibtex-prefix)
(mapcar
(lambda (kv)
(let ((key (car kv)) (val0 (cdr kv)))
(when (and
(string-match org-bibtex-prefix key)
(not (string=
(downcase (concat org-bibtex-prefix
org-bibtex-type-property-name))
(downcase key))))
(cons (downcase (replace-regexp-in-string
org-bibtex-prefix "" key))
val0))))
(org-entry-properties nil 'standard))
(mapcar
(lambda (field)
(let ((value (or (org-bibtex-get (funcall from field))
(and (eq :title field)
(nth 4 (org-heading-components))))))
(when value (cons (funcall from field) value))))
(funcall flatten
(funcall val :required (funcall val (funcall to type) org-bibtex-types))
(funcall val :optional (funcall val (funcall to type) org-bibtex-types))))))
",\n"))))
(with-temp-buffer
(insert entry)
(when tags
(bibtex-beginning-of-entry)
(if (re-search-forward "keywords.*=.*{\\(.*\\)}" nil t)
(progn (goto-char (match-end 1)) (insert ", "))
(search-forward ",\n" nil t)
(insert " keywords={},\n")
(search-backward "}," nil t))
(insert (mapconcat #'identity tags ", ")))
(buffer-string))))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-ask (field)
(unless (assoc field org-bibtex-fields)
2012-08-13 03:59:44 +00:00
(error "Field:%s is not known" field))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(save-window-excursion
(let* ((name (substring (symbol-name field) 1))
(buf-name (format "*Bibtex Help %s*" name)))
(with-output-to-temp-buffer buf-name
(princ (cdr (assoc field org-bibtex-fields))))
(with-current-buffer buf-name (visual-line-mode 1))
(org-fit-window-to-buffer (get-buffer-window buf-name))
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(let ((result (read-from-minibuffer (format "%s: " name))))
(when (> (length result) 0) result)))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-autokey ()
"Generate an autokey for the current headline."
(org-bibtex-put org-bibtex-key-property
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(if org-bibtex-autogen-keys
(let* ((entry (org-bibtex-headline))
(key
(with-temp-buffer
(insert entry)
(bibtex-generate-autokey))))
;; test for duplicate IDs if using global ID
(when (and
(equal org-bibtex-key-property "ID")
(featurep 'org-id)
(hash-table-p org-id-locations)
(gethash key org-id-locations))
(warn "Another entry has the same ID"))
key)
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(read-from-minibuffer "id: "))))
(defun org-bibtex-fleshout (type &optional optional)
"Fleshout current heading, ensuring all required fields are present.
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
With optional argument OPTIONAL, also prompt for optional fields."
(let ((val (lambda (key lst) (cdr (assoc key lst))))
(keyword (lambda (name) (intern (concat ":" (downcase name)))))
(name (lambda (keyword) (substring (symbol-name keyword) 1))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(dolist (field (append
(if org-bibtex-treat-headline-as-title
(remove :title (funcall val :required (funcall val type org-bibtex-types)))
(funcall val :required (funcall val type org-bibtex-types)))
(when optional (funcall val :optional (funcall val type org-bibtex-types)))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(when (consp field) ; or'd pair of fields e.g., (:editor :author)
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(let ((present (nth 0 (remove
nil
(mapcar
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(lambda (f)
(when (org-bibtex-get (funcall name f)) f))
field)))))
(setf field (or present (funcall keyword
(completing-read
"Field: " (mapcar name field)))))))
(let ((name (funcall name field)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(unless (org-bibtex-get name)
(let ((prop (org-bibtex-ask field)))
(when prop (org-bibtex-put name prop)))))))
(when (and type (assoc type org-bibtex-types)
(not (org-bibtex-get org-bibtex-key-property)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(org-bibtex-autokey)))
;;; Bibtex link functions
(org-link-set-parameters "bibtex"
:follow #'org-bibtex-open
:store #'org-bibtex-store-link)
(defun org-bibtex-open (path arg)
"Visit the bibliography entry on PATH.
ARG, when non-nil, is a universal prefix argument. See
`org-open-file' for details."
(org-link-open-as-file path arg))
(defun org-bibtex-store-link ()
"Store a link to a BibTeX entry."
(when (eq major-mode 'bibtex-mode)
(let* ((search (org-create-file-search-in-bibtex))
(link (concat "file:" (abbreviate-file-name buffer-file-name)
"::" search))
(entry (mapcar ; repair strings enclosed in "..." or {...}
(lambda(c)
(if (string-match
"^\\(?:{\\|\"\\)\\(.*\\)\\(?:}\\|\"\\)$" (cdr c))
(cons (car c) (match-string 1 (cdr c))) c))
(save-excursion
(bibtex-beginning-of-entry)
(bibtex-parse-entry)))))
Move link-related core functions out of "org.el" * contrib/lisp/org-wl.el (org-wl-store-link-message): * lisp/Makefile (clean-install): * lisp/ob-core.el (org-link-bracket-re): (org-babel-open-src-block-result): (org-babel-read-element): (org-babel-read-link): (org-babel-result-end): * lisp/ob-tangle.el (org-link-bracket-re): (org-babel-tangle-single-block): (org-link-analytic-bracket-re): (org-babel-detangle): (org-babel-tangle-jump-to-org): * lisp/ol.el: * lisp/org-agenda.el (org-agenda-get-some-entry-text): (org-diary): (org-agenda-format-item): (org-agenda-open-link): (org-agenda-switch-to): (org-agenda-to-appt): * lisp/org-bbdb.el (org-bbdb-store-link): * lisp/org-bibtex.el (org-bibtex-store-link): * lisp/org-capture.el (org-capture-fill-template): * lisp/org-clock.el (org-clocktable-write-default): (org-clock-get-table-data): * lisp/org-compat.el (org-doi-server-url): (org-email-link-description-format): (org-make-link-description-function): (org-from-is-user-regexp): (org-descriptive-links): (org-url-hexify-p): (org-context-in-file-links): (org-keep-stored-link-after-insertion): (org-display-internal-link-with-indirect-buffer): (org-confirm-shell-link-function): (org-confirm-shell-link-not-regexp): (org-confirm-elisp-link-function): (org-confirm-elisp-link-not-regexp): (org-file-complete-link): (org-email-link-description): (org-make-link-string): (org-store-link-props): (org-add-link-props): (org-make-link-regexps): (org-angle-link-re): (org-plain-link-re): (org-bracket-link-regexp): (org-bracket-link-analytic-regexp): (org-any-link-re): * lisp/org-docview.el (org-docview-store-link): (org-docview-complete-link): * lisp/org-element.el (org-element-link-parser): * lisp/org-eshell.el (org-eshell-store-link): * lisp/org-eww.el (org-eww-store-link): (org-eww-copy-for-org-mode): * lisp/org-footnote.el (org-footnote-next-reference-or-definition): * lisp/org-gnus.el (org-gnus-article-link): (org-gnus-store-link): * lisp/org-id.el (org-id-store-link): * lisp/org-info.el (org-info-store-link): * lisp/org-irc.el (org-irc-erc-store-link): * lisp/org-mhe.el (org-mhe-store-link): * lisp/org-pcomplete.el (pcomplete/org-mode/searchhead): * lisp/org-protocol.el (org-protocol-do-capture): * lisp/org-rmail.el (org-rmail-store-link): * lisp/org-w3m.el (org-w3m-store-link): (org-w3m-copy-for-org-mode):
2018-11-26 23:04:41 +00:00
(org-link-store-props
:key (cdr (assoc "=key=" entry))
:author (or (cdr (assoc "author" entry)) "[no author]")
:editor (or (cdr (assoc "editor" entry)) "[no editor]")
:title (or (cdr (assoc "title" entry)) "[no title]")
:booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
:journal (or (cdr (assoc "journal" entry)) "[no journal]")
:publisher (or (cdr (assoc "publisher" entry)) "[no publisher]")
:pages (or (cdr (assoc "pages" entry)) "[no pages]")
:url (or (cdr (assoc "url" entry)) "[no url]")
:year (or (cdr (assoc "year" entry)) "[no year]")
:month (or (cdr (assoc "month" entry)) "[no month]")
:address (or (cdr (assoc "address" entry)) "[no address]")
:volume (or (cdr (assoc "volume" entry)) "[no volume]")
:number (or (cdr (assoc "number" entry)) "[no number]")
:annote (or (cdr (assoc "annote" entry)) "[no annotation]")
:series (or (cdr (assoc "series" entry)) "[no series]")
:abstract (or (cdr (assoc "abstract" entry)) "[no abstract]")
:btype (or (cdr (assoc "=type=" entry)) "[no type]")
:type "bibtex"
:link link
:description org-bibtex-description))))
(defun org-create-file-search-in-bibtex ()
"Create the search string and description for a BibTeX database entry."
;; Make a good description for this entry, using names, year and the title
;; Put it into the `description' variable which is dynamically scoped.
(let ((bibtex-autokey-names 1)
(bibtex-autokey-names-stretch 1)
(bibtex-autokey-name-case-convert-function 'identity)
(bibtex-autokey-name-separator " & ")
(bibtex-autokey-additional-names " et al.")
(bibtex-autokey-year-length 4)
(bibtex-autokey-name-year-separator " ")
(bibtex-autokey-titlewords 3)
(bibtex-autokey-titleword-separator " ")
(bibtex-autokey-titleword-case-convert-function 'identity)
(bibtex-autokey-titleword-length 'infty)
(bibtex-autokey-year-title-separator ": "))
(setq org-bibtex-description (bibtex-generate-autokey)))
;; Now parse the entry, get the key and return it.
(save-excursion
(bibtex-beginning-of-entry)
(cdr (assoc "=key=" (bibtex-parse-entry)))))
(defun org-execute-file-search-in-bibtex (s)
"Find the link search string S as a key for a database entry."
(when (eq major-mode 'bibtex-mode)
;; Yes, we want to do the search in this file.
;; We construct a regexp that searches for "@entrytype{" followed by the key
(goto-char (point-min))
(and (re-search-forward (concat "@[a-zA-Z]+[ \t\n]*{[ \t\n]*"
Tiny formatting fixes * lisp/ox.el (org-export-table-dimensions): * lisp/ox-texinfo.el (org-texinfo-template): * lisp/ox-md.el (org-md-link): * lisp/ox-icalendar.el (org-icalendar-use-UTC-date-time-p): * lisp/ox-ascii.el (org-ascii-fixed-width): * lisp/org.el (org-context): * lisp/org-table.el (org-table-eval-formula) (org-table-export): * lisp/org-refile.el: * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): * lisp/org-num.el (org-num): * lisp/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org-macro.el (org-macro): * lisp/org-lint.el (org-lint): * lisp/org-keys.el (org-keys): * lisp/org-duration.el: * lisp/org-clock.el (org-clock-get-last-clock-out-time) (org-clock-update-mode-line, org-find-open-clocks): * lisp/org-agenda.el (org-diary) (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item) (org-agenda-highlight-todo, org-cmp-alpha) (org-agenda-filter-by-category): * lisp/ol.el (org-link-expand-abbrev, ol): * lisp/ol-docview.el (ol-docview): * lisp/ol-bibtex.el (org-execute-file-search-in-bibtex) (org-bibtex, org-bibtex-read): * lisp/ol-bbdb.el (org-bbdb-anniversary-description): * lisp/ob-tangle.el (org-babel-tangle-jump-to-org): * lisp/ob-table.el (org-babel-table-truncate-at-newline): * lisp/ob-stan.el: * lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar): * lisp/ob-sql.el: * lisp/ob-shen.el: * lisp/ob-shell.el (org-babel-prep-session:shell) (org-babel-prep-session:shell): * lisp/ob-sed.el (org-babel-execute:sed) (org-babel-execute:sed): * lisp/ob-screen.el: * lisp/ob-sass.el: * lisp/ob-ruby.el (org-babel-prep-session:ruby) (org-babel-prep-session:ruby): * lisp/ob-ref.el (org-babel-ref-resolve, ob-ref): * lisp/ob-python.el (org-babel-prep-session:python) (org-babel-prep-session:python): * lisp/ob-plantuml.el: * lisp/ob-picolisp.el: * lisp/ob-perl.el: * lisp/ob-org.el: * lisp/ob-octave.el (org-babel-prep-session:octave) (org-babel-prep-session:octave) (org-babel-octave-evaluate-session): * lisp/ob-ocaml.el: * lisp/ob-mscgen.el (org-babel-execute:mscgen) (org-babel-execute:mscgen): * lisp/ob-maxima.el: (ob-maxima): * lisp/ob-matlab.el: * lisp/ob-makefile.el: * lisp/ob-lua.el (org-babel-prep-session:lua) (org-babel-prep-session:lua): * lisp/ob-lisp.el: * lisp/ob-ledger.el: * lisp/ob-latex.el (org-babel-expand-body:latex) (org-babel-expand-body:latex, ob-latex): * lisp/ob-js.el: * lisp/ob-java.el: * lisp/ob-io.el (org-babel-prep-session:io) (org-babel-prep-session:io): * lisp/ob-hledger.el: * lisp/ob-haskell.el: * lisp/ob-groovy.el (org-babel-groovy-wrapper-method) (org-babel-groovy-evaluate): * lisp/ob-gnuplot.el: * lisp/ob-fortran.el (org-babel-expand-body:fortran) (org-babel-expand-body:fortran): * lisp/ob-forth.el (org-babel-forth-session-execute): * lisp/ob-exp.el (ob-exp): * lisp/ob-eval.el: * lisp/ob-emacs-lisp.el: * lisp/ob-ebnf.el: * lisp/ob-dot.el: * lisp/ob-ditaa.el: * lisp/ob-css.el: * lisp/ob-core.el (org-babel-put-rownames): * lisp/ob-coq.el: * lisp/ob-comint.el: * lisp/ob-calc.el: * lisp/ob-awk.el: * lisp/ob-asymptote.el: * lisp/ob-abc.el: * lisp/ob-R.el (org-babel-prep-session:R): Formatting fixes.
2020-02-18 21:57:37 +00:00
(regexp-quote s) "[ \t\n]*,")
nil t)
(goto-char (match-beginning 0)))
(if (and (match-beginning 0) (equal current-prefix-arg '(16)))
;; Use double prefix to indicate that any web link should be browsed
(let ((b (current-buffer)) (p (point)))
;; Restore the window configuration because we just use the web link
(set-window-configuration org-window-config-before-follow-link)
(with-current-buffer b
(goto-char p)
(bibtex-url)))
(recenter 0)) ; Move entry start to beginning of window
;; return t to indicate that the search is done.
t))
;; Finally add the link search function to the right hook.
(add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex)
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
;;; Bibtex <-> Org headline translation functions
(defun org-bibtex (filename)
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
"Export each headline in the current file to a bibtex entry.
Headlines are exported using `org-bibtex-headline'."
(interactive
(list (read-file-name
"Bibtex file: " nil nil nil
(let ((file (buffer-file-name (buffer-base-buffer))))
(and file
(file-name-nondirectory
(concat (file-name-sans-extension file) ".bib")))))))
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(let ((error-point
(catch 'bib
(let ((bibtex-entries
(remove nil (org-map-entries
(lambda ()
(condition-case nil
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(org-bibtex-headline)
(error (throw 'bib (point)))))))))
(with-temp-file filename
(insert (mapconcat #'identity bibtex-entries "\n")))
(message "Successfully exported %d BibTeX entries to %s"
Tiny formatting fixes * lisp/ox.el (org-export-table-dimensions): * lisp/ox-texinfo.el (org-texinfo-template): * lisp/ox-md.el (org-md-link): * lisp/ox-icalendar.el (org-icalendar-use-UTC-date-time-p): * lisp/ox-ascii.el (org-ascii-fixed-width): * lisp/org.el (org-context): * lisp/org-table.el (org-table-eval-formula) (org-table-export): * lisp/org-refile.el: * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): * lisp/org-num.el (org-num): * lisp/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org-macro.el (org-macro): * lisp/org-lint.el (org-lint): * lisp/org-keys.el (org-keys): * lisp/org-duration.el: * lisp/org-clock.el (org-clock-get-last-clock-out-time) (org-clock-update-mode-line, org-find-open-clocks): * lisp/org-agenda.el (org-diary) (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item) (org-agenda-highlight-todo, org-cmp-alpha) (org-agenda-filter-by-category): * lisp/ol.el (org-link-expand-abbrev, ol): * lisp/ol-docview.el (ol-docview): * lisp/ol-bibtex.el (org-execute-file-search-in-bibtex) (org-bibtex, org-bibtex-read): * lisp/ol-bbdb.el (org-bbdb-anniversary-description): * lisp/ob-tangle.el (org-babel-tangle-jump-to-org): * lisp/ob-table.el (org-babel-table-truncate-at-newline): * lisp/ob-stan.el: * lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar): * lisp/ob-sql.el: * lisp/ob-shen.el: * lisp/ob-shell.el (org-babel-prep-session:shell) (org-babel-prep-session:shell): * lisp/ob-sed.el (org-babel-execute:sed) (org-babel-execute:sed): * lisp/ob-screen.el: * lisp/ob-sass.el: * lisp/ob-ruby.el (org-babel-prep-session:ruby) (org-babel-prep-session:ruby): * lisp/ob-ref.el (org-babel-ref-resolve, ob-ref): * lisp/ob-python.el (org-babel-prep-session:python) (org-babel-prep-session:python): * lisp/ob-plantuml.el: * lisp/ob-picolisp.el: * lisp/ob-perl.el: * lisp/ob-org.el: * lisp/ob-octave.el (org-babel-prep-session:octave) (org-babel-prep-session:octave) (org-babel-octave-evaluate-session): * lisp/ob-ocaml.el: * lisp/ob-mscgen.el (org-babel-execute:mscgen) (org-babel-execute:mscgen): * lisp/ob-maxima.el: (ob-maxima): * lisp/ob-matlab.el: * lisp/ob-makefile.el: * lisp/ob-lua.el (org-babel-prep-session:lua) (org-babel-prep-session:lua): * lisp/ob-lisp.el: * lisp/ob-ledger.el: * lisp/ob-latex.el (org-babel-expand-body:latex) (org-babel-expand-body:latex, ob-latex): * lisp/ob-js.el: * lisp/ob-java.el: * lisp/ob-io.el (org-babel-prep-session:io) (org-babel-prep-session:io): * lisp/ob-hledger.el: * lisp/ob-haskell.el: * lisp/ob-groovy.el (org-babel-groovy-wrapper-method) (org-babel-groovy-evaluate): * lisp/ob-gnuplot.el: * lisp/ob-fortran.el (org-babel-expand-body:fortran) (org-babel-expand-body:fortran): * lisp/ob-forth.el (org-babel-forth-session-execute): * lisp/ob-exp.el (ob-exp): * lisp/ob-eval.el: * lisp/ob-emacs-lisp.el: * lisp/ob-ebnf.el: * lisp/ob-dot.el: * lisp/ob-ditaa.el: * lisp/ob-css.el: * lisp/ob-core.el (org-babel-put-rownames): * lisp/ob-coq.el: * lisp/ob-comint.el: * lisp/ob-calc.el: * lisp/ob-awk.el: * lisp/ob-asymptote.el: * lisp/ob-abc.el: * lisp/ob-R.el (org-babel-prep-session:R): Formatting fixes.
2020-02-18 21:57:37 +00:00
(length bibtex-entries) filename)
nil))))
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(when error-point
(goto-char error-point)
(message "Bibtex error at %S" (nth 4 (org-heading-components))))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-check (&optional optional)
"Check the current headline for required fields.
With prefix argument OPTIONAL also prompt for optional fields."
(interactive "P")
(save-restriction
(org-narrow-to-subtree)
Backport changes from Emacs revs 115081 and 115082 2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca> Address some byte-compiler warnings. * ob-abc.el (org-babel-expand-body:abc): Use dolist. (org-babel-execute:abc): Fix regexp quoting. * ob-calc.el (org--var-syms): Rename from `var-syms'. * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding. * ob-table.el (sbe): Move debug declaration. * org-clock.el (org--msg-extra): Rename from `msg-extra'. * org.el (org-version): Avoid var name starting with _. (org-inhibit-startup, org-called-with-limited-levels) (org-link-search-inhibit-query, org-time-was-given) (org-end-time-was-given, org-def, org-defdecode, org-with-time): * org-colview.el (org-agenda-overriding-columns-format): * org-agenda.el (org-agenda-multi, org-depend-tag-blocked) (org-agenda-show-log-scoped): * ob-python.el (py-which-bufname, python-shell-buffer-name): * ob-haskell.el (org-export-copy-to-kill-ring): * ob-exp.el (org-link-search-inhibit-query): * ob-R.el (ess-eval-visibly-p): * ob-core.el (org-src-window-setup): Declare before use. (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'. * ox-odt.el (org-odt-hfy-face-to-css): * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode): * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex) (org-bibtex-check): * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string) (org-babel-tangle-single-block, org-babel-tangle-comment-links): * ob-table.el (sbe): * ob-sqlite.el (org-babel-sqlite-expand-vars): * ob-sql.el (org-babel-sql-expand-vars): * ob-shen.el (org-babel-execute:shen): * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate): * ob-scala.el (org-babel-scala-evaluate): * ob-ruby.el (org-babel-ruby-table-or-string) (org-babel-ruby-evaluate): * ob-python.el (org-babel-python-table-or-string) (org-babel-python-evaluate-external-process) (org-babel-python-evaluate-session): * ob-picolisp.el (org-babel-execute:picolisp): * ob-perl.el (org-babel-perl-evaluate): * ob-maxima.el (org-babel-execute:maxima): * ob-lisp.el (org-babel-execute:lisp): * ob-java.el (org-babel-execute:java): * ob-io.el (org-babel-io-evaluate): * ob-haskell.el (org-babel-execute:haskell): * ob-fortran.el (org-babel-execute:fortran): * ob-exp.el (org-babel-exp-code): * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): * ob-ditaa.el (org-babel-execute:ditaa): * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash) (org-babel-parse-header-arguments, org-babel-reassemble-table) (org-babel-goto-src-block-head, org-babel-mark-block) (org-babel-expand-noweb-references, org-babel-script-escape) (org-babel-process-file-name): * ob-clojure.el (org-babel-execute:clojure): * ob-calc.el (org-babel-execute:calc): * ob-awk.el (org-babel-execute:awk): * ob-abc.el (org-babel-execute:abc): * ob-R.el (org-babel-expand-body:R): * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...). 2013-11-12 Glenn Morris <rgm@gnu.org> * ox-html.el (org-html-scripts): Add 2013 to copyright years. (org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
(let ((type (let ((name (org-bibtex-get org-bibtex-type-property-name)))
(when name (intern (concat ":" name))))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(when type (org-bibtex-fleshout type optional)))))
(defun org-bibtex-check-all (&optional optional)
"Check all headlines in the current file.
With prefix argument OPTIONAL also prompt for optional fields."
(interactive) (org-map-entries (lambda () (org-bibtex-check optional))))
(defun org-bibtex-create (&optional arg nonew)
"Create a new entry at the given level.
With a prefix arg, query for optional fields as well.
If nonew is t, add data to the headline of the entry at point."
(interactive "P")
(let* ((type (completing-read
"Type: " (mapcar (lambda (type)
(substring (symbol-name (car type)) 1))
org-bibtex-types)
nil nil (when nonew
(org-bibtex-get org-bibtex-type-property-name))))
(type (if (keywordp type) type (intern (concat ":" type))))
(org-bibtex-treat-headline-as-title (if nonew nil t)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(unless (assoc type org-bibtex-types)
2012-08-13 03:59:44 +00:00
(error "Type:%s is not known" type))
(if nonew
(org-back-to-heading)
(org-insert-heading)
(let ((title (org-bibtex-ask :title)))
(insert title)
(org-bibtex-put "TITLE" title)))
(org-bibtex-put org-bibtex-type-property-name
(substring (symbol-name type) 1))
(org-bibtex-fleshout type arg)
(dolist (tag org-bibtex-tags) (org-toggle-tag tag 'on))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-create-in-current-entry (&optional arg)
"Add bibliographical data to the current entry.
With a prefix arg, query for optional fields."
(interactive "P")
(org-bibtex-create arg t))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-read ()
"Read a bibtex entry and save to `org-bibtex-entries'.
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
This uses `bibtex-parse-entry'."
(interactive)
(let ((keyword (lambda (str) (intern (concat ":" (downcase str)))))
(clean-space (lambda (str) (replace-regexp-in-string
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
"[[:space:]\n\r]+" " " str)))
(strip-delim
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(lambda (str) ; strip enclosing "..." and {...}
(dolist (pair '((34 . 34) (123 . 125)))
(when (and (> (length str) 1)
(= (aref str 0) (car pair))
(= (aref str (1- (length str))) (cdr pair)))
Tiny formatting fixes * lisp/ox.el (org-export-table-dimensions): * lisp/ox-texinfo.el (org-texinfo-template): * lisp/ox-md.el (org-md-link): * lisp/ox-icalendar.el (org-icalendar-use-UTC-date-time-p): * lisp/ox-ascii.el (org-ascii-fixed-width): * lisp/org.el (org-context): * lisp/org-table.el (org-table-eval-formula) (org-table-export): * lisp/org-refile.el: * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): * lisp/org-num.el (org-num): * lisp/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org-macro.el (org-macro): * lisp/org-lint.el (org-lint): * lisp/org-keys.el (org-keys): * lisp/org-duration.el: * lisp/org-clock.el (org-clock-get-last-clock-out-time) (org-clock-update-mode-line, org-find-open-clocks): * lisp/org-agenda.el (org-diary) (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item) (org-agenda-highlight-todo, org-cmp-alpha) (org-agenda-filter-by-category): * lisp/ol.el (org-link-expand-abbrev, ol): * lisp/ol-docview.el (ol-docview): * lisp/ol-bibtex.el (org-execute-file-search-in-bibtex) (org-bibtex, org-bibtex-read): * lisp/ol-bbdb.el (org-bbdb-anniversary-description): * lisp/ob-tangle.el (org-babel-tangle-jump-to-org): * lisp/ob-table.el (org-babel-table-truncate-at-newline): * lisp/ob-stan.el: * lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar): * lisp/ob-sql.el: * lisp/ob-shen.el: * lisp/ob-shell.el (org-babel-prep-session:shell) (org-babel-prep-session:shell): * lisp/ob-sed.el (org-babel-execute:sed) (org-babel-execute:sed): * lisp/ob-screen.el: * lisp/ob-sass.el: * lisp/ob-ruby.el (org-babel-prep-session:ruby) (org-babel-prep-session:ruby): * lisp/ob-ref.el (org-babel-ref-resolve, ob-ref): * lisp/ob-python.el (org-babel-prep-session:python) (org-babel-prep-session:python): * lisp/ob-plantuml.el: * lisp/ob-picolisp.el: * lisp/ob-perl.el: * lisp/ob-org.el: * lisp/ob-octave.el (org-babel-prep-session:octave) (org-babel-prep-session:octave) (org-babel-octave-evaluate-session): * lisp/ob-ocaml.el: * lisp/ob-mscgen.el (org-babel-execute:mscgen) (org-babel-execute:mscgen): * lisp/ob-maxima.el: (ob-maxima): * lisp/ob-matlab.el: * lisp/ob-makefile.el: * lisp/ob-lua.el (org-babel-prep-session:lua) (org-babel-prep-session:lua): * lisp/ob-lisp.el: * lisp/ob-ledger.el: * lisp/ob-latex.el (org-babel-expand-body:latex) (org-babel-expand-body:latex, ob-latex): * lisp/ob-js.el: * lisp/ob-java.el: * lisp/ob-io.el (org-babel-prep-session:io) (org-babel-prep-session:io): * lisp/ob-hledger.el: * lisp/ob-haskell.el: * lisp/ob-groovy.el (org-babel-groovy-wrapper-method) (org-babel-groovy-evaluate): * lisp/ob-gnuplot.el: * lisp/ob-fortran.el (org-babel-expand-body:fortran) (org-babel-expand-body:fortran): * lisp/ob-forth.el (org-babel-forth-session-execute): * lisp/ob-exp.el (ob-exp): * lisp/ob-eval.el: * lisp/ob-emacs-lisp.el: * lisp/ob-ebnf.el: * lisp/ob-dot.el: * lisp/ob-ditaa.el: * lisp/ob-css.el: * lisp/ob-core.el (org-babel-put-rownames): * lisp/ob-coq.el: * lisp/ob-comint.el: * lisp/ob-calc.el: * lisp/ob-awk.el: * lisp/ob-asymptote.el: * lisp/ob-abc.el: * lisp/ob-R.el (org-babel-prep-session:R): Formatting fixes.
2020-02-18 21:57:37 +00:00
(setf str (substring str 1 (1- (length str))))))
str)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(push (mapcar
(lambda (pair)
(cons (let ((field (funcall keyword (car pair))))
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(pcase field
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(:=type= :type)
(:=key= :key)
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(_ field)))
(funcall clean-space (funcall strip-delim (cdr pair)))))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
org-bibtex-entries)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-read-buffer (buffer)
"Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
Return the number of saved entries."
(interactive "bBuffer: ")
(let ((start-length (length org-bibtex-entries)))
(with-current-buffer buffer
(save-excursion
(goto-char (point-max))
(while (not (= (point) (point-min)))
(backward-char 1)
(org-bibtex-read)
(bibtex-beginning-of-entry))))
(let ((added (- (length org-bibtex-entries) start-length)))
(message "Parsed %d entries" added)
added)))
(defun org-bibtex-read-file (file)
"Read FILE with `org-bibtex-read-buffer'."
(interactive "fFile: ")
(org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-write ()
"Insert a heading built from the first element of `org-bibtex-entries'."
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(interactive)
(when (= (length org-bibtex-entries) 0)
(error "No entries in `org-bibtex-entries'"))
(let* ((entry (pop org-bibtex-entries))
(org-special-properties nil) ; avoids errors with `org-entry-put'
(val (lambda (field) (cdr (assoc field entry))))
(togtag (lambda (tag) (org-toggle-tag tag 'on))))
(org-insert-heading)
(insert (funcall org-bibtex-headline-format-function entry))
(org-bibtex-put "TITLE" (funcall val :title))
(org-bibtex-put org-bibtex-type-property-name
(downcase (funcall val :type)))
(dolist (pair entry)
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(pcase (car pair)
(:title nil)
(:type nil)
(:key (org-bibtex-put org-bibtex-key-property (cdr pair)))
(:keywords (if org-bibtex-tags-are-keywords
(dolist (kw (split-string (cdr pair) ", *"))
(funcall
togtag
(replace-regexp-in-string
"[^[:alnum:]_@#%]" ""
(replace-regexp-in-string "[ \t]+" "_" kw))))
(org-bibtex-put (car pair) (cdr pair))))
Silence byte-compiler * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
2016-07-25 14:34:48 +00:00
(_ (org-bibtex-put (car pair) (cdr pair)))))
(mapc togtag org-bibtex-tags)))
org-bibtex: translating between Org-mode headings and Bibtex entries * lisp/org-bibtex.el: Updating Copyright dates, author information, commentary and history notes. (org-bibtex-types): List of bibtex types with descriptions and required and optional fields. (org-bibtex-fields): List of bibtex fields with descriptions. (*org-bibtex-entries*): Special variable to hold parsed bibtex entries. (org-bibtex-autogen-keys): Custom variable controlling whether bibtex keys are automatically generated (org-bibtex-prefix): Custom variable allowing use of optional prefix for bibtex properties in Org-mode headlines. (org-bibtex-get): Helper function for accessing bibtex elements of a property list. (org-bibtex-put): Helper function for inserting bibtex element into a property list. (org-bibtex-headline): Return a bibtex entry of the given headline as a string. (org-bibtex-ask): Prompt the user to fill in the value of a bibtex field. (org-bibtex-autokey): Generate a bibtex key for the current headline. (org-bibtex-fleshout): Fill in missing bibtex properties of the current headline. (org-bibtex): Export the current Org-mode buffer to a bibtex buffer. (org-bibtex-check): Check that all bibtex properties are present in the current headline. (org-bibtex-check-all): Check all headlines in the current buffer. (org-bibtex-create): Create a new bibtex headline at the current level. (org-bibtex-read): Read the current bibtex entry from a bibtex file. (org-bibtex-write): Write the most recently read bibtex entry into an Org-mode file.
2011-04-22 12:19:30 +00:00
(defun org-bibtex-yank ()
"If kill ring holds a bibtex entry yank it as an Org headline."
(interactive)
(let (entry)
(with-temp-buffer (yank 1) (setf entry (org-bibtex-read)))
(if entry
(org-bibtex-write)
2012-08-13 03:59:44 +00:00
(error "Yanked text does not appear to contain a BibTeX entry"))))
(defun org-bibtex-import-from-file (file)
"Read bibtex entries from FILE and insert as Org headlines after point."
(interactive "fFile: ")
(dotimes (_ (org-bibtex-read-file file))
(save-excursion (org-bibtex-write))
(re-search-forward org-property-end-re)
(open-line 1) (forward-char 1)))
(defun org-bibtex-export-to-kill-ring ()
"Export current headline to kill ring as bibtex entry."
(interactive)
(let ((result (org-bibtex-headline)))
(kill-new result) result))
(defun org-bibtex-search (string)
"Search for bibliographical entries in agenda files.
This function relies `org-search-view' to locate results."
(interactive "sSearch string: ")
(let ((org-agenda-overriding-header "Bib search results:")
(org-agenda-search-view-always-boolean t))
(org-search-view nil
(format "%s +{:%s%s:}"
string (or org-bibtex-prefix "")
org-bibtex-type-property-name))))
(provide 'ol-bibtex)
;;; ol-bibtex.el ends here