(require 'bibtex)
(require 'json)
+(require 'map)
(require 'oc)
(require 'seq)
(defun org-cite-basic--key-completion-table ()
"Return completion table for cite keys, as a hash table.
-In this hash table, keys are a strings with author, date, and title of the
-reference. Values are the cite key."
- (let ((cache-key (mapcar #'car org-cite-basic--bibliography-cache)))
- (if (gethash cache-key org-cite-basic--completion-cache)
- org-cite-basic--completion-cache
+
+In this hash table, keys are a strings with author, date, and
+title of the reference. Values are the cite keys.
+
+Return nil if there are no bibliography files or no entries."
+ ;; Populate bibliography cache.
+ (let ((entries (org-cite-basic--parse-bibliography)))
+ (cond
+ ((null entries) nil) ;no bibliography files
+ ((gethash entries org-cite-basic--completion-cache)
+ org-cite-basic--completion-cache)
+ (t
(clrhash org-cite-basic--completion-cache)
(dolist (key (org-cite-basic--all-keys))
(let ((completion
org-cite-basic-column-separator
(org-cite-basic--get-field 'title key nil t))))
(puthash completion key org-cite-basic--completion-cache)))
- (puthash cache-key t org-cite-basic--completion-cache)
- org-cite-basic--completion-cache)))
+ (unless (map-empty-p org-cite-basic--completion-cache) ;no key
+ (puthash entries t org-cite-basic--completion-cache)
+ org-cite-basic--completion-cache)))))
(defun org-cite-basic--complete-key (&optional multiple)
"Prompt for a reference key and return a citation reference string.
-When optional argument MULTIPLE is non-nil, prompt for multiple keys, until one
-of them is nil. Then return the list of reference strings selected.
+When optional argument MULTIPLE is non-nil, prompt for multiple
+keys, until one of them is nil. Then return the list of
+reference strings selected.
Raise an error when no bibliography is set in the buffer."
(let* ((table
(build-prompt
(lambda ()
(if keys
- (format "Key (\"\" to exit) %s: "
+ (format "Key (empty input exits) %s: "
(mapconcat #'identity (reverse keys) ";"))
- "Key (\"\" to exit): "))))
+ "Key (empty input exits): "))))
(let ((key (funcall prompt (funcall build-prompt))))
(while (org-string-nw-p key)
(push (gethash key table) keys)
(with-temp-buffer
(save-excursion (insert output))
(when (search-forward "\\begin{document}" nil t)
- ;; Ensure that \citeprocitem is defined for citeproc-el
+ (goto-char (match-beginning 0))
+ ;; Ensure that \citeprocitem is defined for citeproc-el.
(insert "\\makeatletter\n\\newcommand{\\citeprocitem}[2]{\\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\\hyper@linkend}\n\\makeatother\n\n")
;; Ensure there is a \usepackage{hanging} somewhere or add one.
- (goto-char (match-beginning 0))
(let ((re (rx "\\usepackage" (opt "[" (*? nonl) "]") "{hanging}")))
(unless (re-search-backward re nil t)
(insert "\\usepackage[notquote]{hanging}\n"))))
On a citation reference:
- - on the prefix or right before th \"@\" character, insert a new reference
+ - on the prefix or right before the \"@\" character, insert a new reference
before the current one,
- on the suffix, insert it after the reference,
- otherwise, update the cite key, preserving both affixes.
;;;; TAB key with modifiers
(org-defkey org-mode-map (kbd "TAB") #'org-cycle)
-(org-defkey org-mode-map (kbd "C-c C-TAB") #'org-force-cycle-archived)
+(org-defkey org-mode-map (kbd "C-c C-<tab>") #'org-force-cycle-archived)
;; Override text-mode binding to expose `complete-symbol' for
;; pcomplete functionality.
(org-defkey org-mode-map (kbd "M-TAB") nil)
date)
(unwind-protect
(progn
- (vc-call print-log file buf nil nil 1)
+ (vc-call print-log (list file) buf nil nil 1)
(with-current-buffer buf
(vc-exec-after
(lambda ()
(defun org-git-version ()
"The Git version of Org mode.
Inserted by installing Org or when a release is made."
- (let ((org-git-version "release_9.5.1-15-gdb4805"))
+ (let ((org-git-version "release_9.5.1-25-g9ca3bc"))
org-git-version))
\f
(provide 'org-version)
(setq
new
(if nump
- (let ((msg (format "Priority %s-%s, SPC to remove: "
- (number-to-string org-priority-highest)
- (number-to-string org-priority-lowest))))
- (if (< 9 org-priority-lowest)
- (string-to-number (read-string msg))
- (message msg)
- (string-to-number (char-to-string (read-char-exclusive)))))
+ (let* ((msg (format "Priority %s-%s, SPC to remove: "
+ (number-to-string org-priority-highest)
+ (number-to-string org-priority-lowest)))
+ (s (if (< 9 org-priority-lowest)
+ (read-string msg)
+ (message msg)
+ (char-to-string (read-char-exclusive)))))
+ (if (equal s " ") ?\s (string-to-number s)))
(progn (message "Priority %c-%c, SPC to remove: "
org-priority-highest org-priority-lowest)
(save-match-data
(let ((file (org-export-output-file-name ".tex" subtreep)))
(org-export-to-file 'beamer file
async subtreep visible-only body-only ext-plist
- (lambda (file) (org-latex-compile file)))))
+ #'org-latex-compile)))
;;;###autoload
(defun org-beamer-select-environment ()
(org-export-to-file 'icalendar outfile
async subtreep visible-only body-only
'(:ascii-charset utf-8 :ascii-links-to-notes nil)
- (lambda (file)
- (run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
+ '(lambda (file)
+ (run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
;;;###autoload
(defun org-icalendar-export-agenda-files (&optional async)
(org-koma-letter-special-contents))
(org-export-to-file 'koma-letter file
async subtreep visible-only body-only ext-plist
- (lambda (file) (org-latex-compile file)))))
+ #'org-latex-compile)))
(provide 'ox-koma-letter)
(let ((outfile (org-export-output-file-name ".man" subtreep)))
(org-export-to-file 'man outfile
async subtreep visible-only body-only ext-plist
- (lambda (file) (org-latex-compile file)))))
+ #'org-latex-compile)))
(defun org-man-compile (file)
"Compile a Groff file.
(org-export-coding-system org-texinfo-coding-system))
(org-export-to-file 'texinfo outfile
async subtreep visible-only body-only ext-plist
- (lambda (file) (org-texinfo-compile file)))))
+ #'org-texinfo-compile)))
;;;###autoload
(defun org-texinfo-publish-to-texinfo (plist filename pub-dir)
(&optional async subtreep visible-only body-only ext-plist)
(interactive)
(org-export-to-buffer \\='latex \"*Org LATEX Export*\"
- async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
+ async subtreep visible-only body-only ext-plist
+ #'LaTeX-mode))
+
+When expressed as an anonymous function, using `lambda',
+POST-PROCESS needs to be quoted.
This function returns BUFFER."
(declare (indent 2))
(let ((outfile (org-export-output-file-name \".tex\" subtreep)))
(org-export-to-file \\='latex outfile
async subtreep visible-only body-only ext-plist
- (lambda (file) (org-latex-compile file)))
+ #'org-latex-compile)))
+
+When expressed as an anonymous function, using `lambda',
+POST-PROCESS needs to be quoted.
The function returns either a file name returned by POST-PROCESS,
or FILE."