1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-29 11:02:33 +00:00

configurable property name for bibtex entry types

* lisp/org-bibtex.el (org-bibtex-type-property-name): Configurable
  property name for bibtex entry types.
  (org-bibtex-headline): Use new configurable property name.
  (org-bibtex-check): Use new configurable property name.
  (org-bibtex-create): Use new configurable property name.
  (org-bibtex-write): Use new configurable property name.
This commit is contained in:
Eric Schulte 2011-09-20 09:20:53 -06:00
parent 94c0f143dd
commit 4fbefd87aa

View File

@ -274,6 +274,11 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
:group 'org-bibtex :group 'org-bibtex
:type '(repeat :tag "Tag" (string))) :type '(repeat :tag "Tag" (string)))
(defcustom org-bibtex-type-property-name "btype"
"Property in which to store bibtex entry type (e.g., article)."
:group 'org-bibtex
:type 'string)
;;; Utility functions ;;; Utility functions
(defun org-bibtex-get (property) (defun org-bibtex-get (property)
@ -305,7 +310,7 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
lsts)))) lsts))))
(let ((notes (buffer-string)) (let ((notes (buffer-string))
(id (org-bibtex-get org-bibtex-key-property)) (id (org-bibtex-get org-bibtex-key-property))
(type (org-bibtex-get "type")) (type (org-bibtex-get org-bibtex-type-property-name))
(tags (when org-bibtex-tags-are-keywords (tags (when org-bibtex-tags-are-keywords
(delq nil (delq nil
(mapcar (mapcar
@ -319,16 +324,20 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
(let ((entry (format (let ((entry (format
"@%s{%s,\n%s\n}\n" type id "@%s{%s,\n%s\n}\n" type id
(mapconcat (mapconcat
(lambda (pair) (format " %s={%s}" (car pair) (cdr pair))) (lambda (pair)
(format " %s={%s}" (car pair) (cdr pair)))
(remove nil (remove nil
(if (and org-bibtex-export-arbitrary-fields (if (and org-bibtex-export-arbitrary-fields
org-bibtex-prefix) org-bibtex-prefix)
(mapcar (mapcar
(lambda (kv) (lambda (kv)
(let ((key (car kv)) (val (cdr kv))) (let ((key (car kv)) (val (cdr kv)))
(when (and (string-match org-bibtex-prefix key) (when (and
(not (string= (string-match org-bibtex-prefix key)
(downcase (concat org-bibtex-prefix "TYPE")) (downcase key)))) (not (string=
(downcase (concat org-bibtex-prefix
org-bibtex-type-property-name))
(downcase key))))
(cons (downcase (replace-regexp-in-string (cons (downcase (replace-regexp-in-string
org-bibtex-prefix "" key)) org-bibtex-prefix "" key))
val)))) val))))
@ -527,7 +536,7 @@ With prefix argument OPTIONAL also prompt for optional fields."
(save-restriction (save-restriction
(org-narrow-to-subtree) (org-narrow-to-subtree)
(let ((type ((lambda (name) (when name (intern (concat ":" name)))) (let ((type ((lambda (name) (when name (intern (concat ":" name))))
(org-bibtex-get "TYPE")))) (org-bibtex-get org-bibtex-type-property-name))))
(when type (org-bibtex-fleshout type optional))))) (when type (org-bibtex-fleshout type optional)))))
(defun org-bibtex-check-all (&optional optional) (defun org-bibtex-check-all (&optional optional)
@ -544,7 +553,8 @@ If nonew is t, add data to the headline of the entry at point."
"Type: " (mapcar (lambda (type) "Type: " (mapcar (lambda (type)
(substring (symbol-name (car type)) 1)) (substring (symbol-name (car type)) 1))
org-bibtex-types) org-bibtex-types)
nil nil (when nonew (org-bibtex-get "TYPE")))) nil nil (when nonew
(org-bibtex-get org-bibtex-type-property-name))))
(type (if (keywordp type) type (intern (concat ":" type)))) (type (if (keywordp type) type (intern (concat ":" type))))
(org-bibtex-treat-headline-as-title (if nonew nil t))) (org-bibtex-treat-headline-as-title (if nonew nil t)))
(unless (assoc type org-bibtex-types) (unless (assoc type org-bibtex-types)
@ -555,7 +565,8 @@ If nonew is t, add data to the headline of the entry at point."
(let ((title (org-bibtex-ask :title))) (let ((title (org-bibtex-ask :title)))
(insert title) (insert title)
(org-bibtex-put "TITLE" title))) (org-bibtex-put "TITLE" title)))
(org-bibtex-put "TYPE" (substring (symbol-name type) 1)) (org-bibtex-put org-bibtex-type-property-name
(substring (symbol-name type) 1))
(org-bibtex-fleshout type arg) (org-bibtex-fleshout type arg)
(mapc (lambda (tag) (org-toggle-tag tag 'on)) org-bibtex-tags))) (mapc (lambda (tag) (org-toggle-tag tag 'on)) org-bibtex-tags)))
@ -600,7 +611,7 @@ This uses `bibtex-parse-entry'."
(org-insert-heading) (org-insert-heading)
(insert (val :title)) (insert (val :title))
(org-bibtex-put "TITLE" (val :title)) (org-bibtex-put "TITLE" (val :title))
(org-bibtex-put "TYPE" (downcase (val :type))) (org-bibtex-put org-bibtex-type-property-name (downcase (val :type)))
(dolist (pair entry) (dolist (pair entry)
(case (car pair) (case (car pair)
(:title nil) (:title nil)
@ -639,8 +650,9 @@ This function relies `org-search-view' to locate results."
(let ((org-agenda-overriding-header "Bib search results:") (let ((org-agenda-overriding-header "Bib search results:")
(org-agenda-search-view-always-boolean t)) (org-agenda-search-view-always-boolean t))
(org-search-view nil (org-search-view nil
(format "%s +{:%sTYPE:}" (format "%s +{:%s%s:}"
string org-bibtex-prefix)))) string org-bibtex-prefix
org-bibtex-type-property-name))))
(provide 'org-bibtex) (provide 'org-bibtex)