mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-02-08 21:38:10 +00:00
Merged BibTeX code from org.el and org-bibtex.el.
org-bibtex.el is now a core module.
This commit is contained in:
parent
434b72d7a6
commit
dc0fe33f67
@ -11,7 +11,6 @@ LISP (emacs-lisp code)
|
||||
======================
|
||||
|
||||
org-annotate-file.el --- Annotate a file with org syntax
|
||||
org-bibtex.el --- Org links to BibTeX entries
|
||||
org-bookmark.el --- Org links to bookmarks
|
||||
org-depend.el --- TODO dependencies for Org-mode
|
||||
org-elisp-symbol.el --- Org links to emacs-lisp symbols
|
||||
|
@ -1,5 +1,11 @@
|
||||
2008-04-03 Carsten Dominik <dominik@science.uva.nl>
|
||||
|
||||
* lisp/org.el (org-modules): Add entry for org-bibtex.el.
|
||||
|
||||
* lisp/org-bibtex.el (org-create-file-search-in-bibtex): New file,
|
||||
a combination of the BibTeX that used to be in org.el, and the
|
||||
org-bibtex.el extension written by Bastien Guerry.
|
||||
|
||||
* lisp/org-exp.el (org-export-html-handle-js-options): New function.
|
||||
(org-export-html-infojs-setup): New option.
|
||||
(org-export-as-html): Call `org-export-html-handle-js-options'.
|
||||
|
2
Makefile
2
Makefile
@ -64,7 +64,7 @@ LISPF = org.el \
|
||||
org-compat.el org-macs.el \
|
||||
org-table.el org-exp.el org-remember.el org-agenda.el\
|
||||
org-publish.el org-mouse.el org-export-latex.el \
|
||||
org-bbdb.el org-gnus.el org-info.el org-irc.el \
|
||||
org-bbdb.el org-bibtex.el org-gnus.el org-info.el org-irc.el \
|
||||
org-mac-message.el org-mhe.el org-rmail.el org-vm.el org-wl.el
|
||||
LISPFILES0 = $(LISPF:%=lisp/%)
|
||||
LISPFILES = $(LISPFILES0) lisp/org-install.el
|
||||
|
@ -1,33 +1,39 @@
|
||||
;;; org-bibtex.el --- Org links to BibTeX entries
|
||||
;;
|
||||
;; Copyright 2007 Bastien Guerry
|
||||
;; Copyright 2007, 2008 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: bzg AT altern DOT org
|
||||
;; Version: 0.2
|
||||
;; Author: Bastien Guerry <bzg at altern dot org>
|
||||
;; Carsten Dominik <carsten dot dominik at gmail dot com>
|
||||
;; Keywords: org, wp, remember
|
||||
;; URL: http://www.cognition.ens.fr/~guerry/u/org-bibtex.el
|
||||
;; Version: 6.00pre-2
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
|
||||
;; 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 this program; if not, write to the Free Software
|
||||
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; The Org mode already lets you store/insert links to BibTeX entries.
|
||||
;; 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
|
||||
;; by reference key. And it constucts a nice description tag for
|
||||
;; the link that contains the author name, the year and a short title.
|
||||
;;
|
||||
;; But what if you want to insert the author or the title of a BibTeX
|
||||
;; item in a *remember* buffer? This library lets you deal with this
|
||||
;; by adding more properties to the BibTeX link.
|
||||
;; It also stores detailed information about the entry so that
|
||||
;; remember templates can access and enter this information easily.
|
||||
;;
|
||||
;; The available properties for each entry are listed here:
|
||||
;;
|
||||
@ -70,19 +76,25 @@
|
||||
;;
|
||||
;;; History:
|
||||
;;
|
||||
;; This piece of code was inspired by a request of Austin Frank:
|
||||
;; http://article.gmane.org/gmane.emacs.orgmode/4112
|
||||
;; The link creation part has been part of Org-mode for a long time.
|
||||
;;
|
||||
;; Creating better remember template information was inspired by a request
|
||||
;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
|
||||
;; and then imlemented by Bastien Guerry.
|
||||
;;
|
||||
;; Put this file into your load-path and the following into your ~/.emacs:
|
||||
;; (require 'org-bibtex)
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(provide 'org-bibtex)
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defvar description nil) ; dynamically scoped in org.el
|
||||
(defvar description nil) ; dynamically scoped from org.el
|
||||
|
||||
(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))
|
||||
|
||||
(org-add-link-type "bibtex" 'org-bibtex-open)
|
||||
(add-hook 'org-store-link-functions 'org-bibtex-store-link)
|
||||
@ -108,8 +120,7 @@
|
||||
(defun org-bibtex-store-link ()
|
||||
"Store a link to a BibTeX entry."
|
||||
(when (eq major-mode 'bibtex-mode)
|
||||
(let* ((search (run-hook-with-args-until-success
|
||||
'org-create-file-search-functions))
|
||||
(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 {...}
|
||||
@ -143,12 +154,51 @@
|
||||
:link link
|
||||
:description 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 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]*"
|
||||
(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)
|
||||
(save-excursion (set-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)
|
||||
|
||||
(provide 'org-bibtex)
|
||||
|
||||
|
||||
;;;;##########################################################################
|
||||
;;;; User Options, Variables
|
||||
;;;;##########################################################################
|
||||
|
||||
|
||||
;;; org-bibtex.el ends here
|
63
lisp/org.el
63
lisp/org.el
@ -139,7 +139,7 @@ With prefix arg HERE, insert it at point."
|
||||
(when (featurep 'org)
|
||||
(org-load-modules-maybe 'force)))
|
||||
|
||||
(defcustom org-modules '(org-bbdb org-gnus org-info org-irc org-mhe org-rmail org-vm org-wl)
|
||||
(defcustom org-modules '(org-bbdb org-bibtex org-gnus org-info org-irc org-mhe org-rmail org-vm org-wl)
|
||||
"Modules that should always be loaded together with org.el.
|
||||
If a description starts with <C>, the file is not part of emacs
|
||||
and loading it will require that you have downloaded and properly installed
|
||||
@ -156,6 +156,7 @@ to add the symbol `xyz', and the package must have a call to
|
||||
:type
|
||||
'(set :greedy t
|
||||
(const :tag " bbdb: Links to BBDB entries" org-bbdb)
|
||||
(const :tag " bibtex: Links to BibTeX entries" org-bibtex)
|
||||
(const :tag " gnus: Links to GNUS folders/messages" org-gnus)
|
||||
(const :tag " info: Links to Info nodes" org-info)
|
||||
(const :tag " irc: Links to IRC/ERC chat sessions" org-irc)
|
||||
@ -167,7 +168,6 @@ to add the symbol `xyz', and the package must have a call to
|
||||
(const :tag " mouse: Additional mouse support" org-mouse)
|
||||
|
||||
(const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file)
|
||||
(const :tag "C bibtex: Org links to BibTeX entries" org-bibtex)
|
||||
(const :tag "C bookmark: Org links to bookmarks" org-bookmark)
|
||||
(const :tag "C depend: TODO dependencies for Org-mode" org-depend)
|
||||
(const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol)
|
||||
@ -2680,10 +2680,6 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
|
||||
|
||||
;; Various packages
|
||||
;; FIXME: get the argument lists for the UNKNOWN stuff
|
||||
(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 calendar-absolute-from-iso "cal-iso" (&optional date))
|
||||
(declare-function calendar-forward-day "cal-move" (arg))
|
||||
(declare-function calendar-goto-date "cal-move" (date))
|
||||
@ -7673,61 +7669,6 @@ onto the ring."
|
||||
(t (error "This should not happen"))))
|
||||
|
||||
|
||||
;;; BibTeX links
|
||||
|
||||
;; Use the custom search meachnism to construct and use search strings for
|
||||
;; file links to BibTeX database entries.
|
||||
|
||||
(defun org-create-file-search-in-bibtex ()
|
||||
"Create the search string and description for a BibTeX database entry."
|
||||
(when (eq major-mode 'bibtex-mode)
|
||||
;; yes, we want to construct this search string.
|
||||
;; 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 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]*"
|
||||
(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)
|
||||
(save-excursion (set-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 functions to the right hooks.
|
||||
(add-hook 'org-create-file-search-functions 'org-create-file-search-in-bibtex)
|
||||
(add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex)
|
||||
|
||||
;; end of Bibtex link setup
|
||||
|
||||
;;; Following file links
|
||||
|
||||
(defun org-open-file (path &optional in-emacs line search)
|
||||
|
Loading…
x
Reference in New Issue
Block a user