branch: main commit f47a6a7e5e5ba4c237f79194d8746abc2d253ba4 Merge: 99df5e2a d833e0e3 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into externals/auctex --- bib-cite.el | 2 +- multi-prompt.el | 2 +- style/biblatex.el | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ style/bidi.el | 2 +- style/natbib.el | 38 +++++++++++++++++++--------------- 5 files changed, 86 insertions(+), 20 deletions(-) diff --git a/bib-cite.el b/bib-cite.el index 164385a8..0ff47fbe 100644 --- a/bib-cite.el +++ b/bib-cite.el @@ -2,7 +2,7 @@ ;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file. ;; Copyright (C) 1994-1999, 2001, 2003-2005, 2014 -;; Free Software Foundation +;; Free Software Foundation, Inc. ;; Author: Peter S. Galbraith <p...@debian.org> ;; Created: 06 July 1994 diff --git a/multi-prompt.el b/multi-prompt.el index ed88d155..66072c64 100644 --- a/multi-prompt.el +++ b/multi-prompt.el @@ -1,6 +1,6 @@ ;;; multi-prompt.el --- Completing read of multiple strings -;; Copyright (C) 1996, 1997, 2000, 2009, 2014 Free Software Foundation +;; Copyright (C) 1996, 1997, 2000, 2009, 2014 Free Software Foundation, Inc. ;; Author: Per Abrahamsen <abra...@dina.kvl.dk> ;; Maintainer: auctex-devel@gnu.org diff --git a/style/biblatex.el b/style/biblatex.el index 06cd57a7..2b8ba858 100644 --- a/style/biblatex.el +++ b/style/biblatex.el @@ -216,6 +216,21 @@ for citation keys." (TeX-argument-insert (mapconcat 'identity items ",") optional)) (setq noinsert t)))) +(defun LaTeX-arg-biblatex-natbib-notes (optional) + "Prompt for two note arguments of a natbib compat citation command." + (when TeX-arg-cite-note-p + (let ((pre (TeX-read-string + (TeX-argument-prompt optional nil "Prenote"))) + (post (TeX-read-string + (TeX-argument-prompt optional nil "Postnote")))) + (TeX-argument-insert pre optional) + (TeX-argument-insert post optional) + ;; pre is given, post is empty: Make sure that we insert an + ;; extra pair of `[]', otherwise pre becomes post + (when (and pre (not (string= pre "")) + (string= post "")) + (insert LaTeX-optop LaTeX-optcl))))) + (TeX-add-style-hook "biblatex" (lambda () @@ -456,6 +471,53 @@ for citation keys." '("DefineHyphenationExceptions" (TeX-arg-eval completing-read "Language: " LaTeX-biblatex-language-list) t) "NewBibliographyString") + + ;; ยง 3.8.9 natbib Compatibility Commands + (when (or (LaTeX-provided-package-options-member "biblatex" "natbib") + (LaTeX-provided-package-options-member "biblatex" "natbib=true")) + (let ((cmds '(("citet" . 1) ("citet*" . 1) + ("Citet" . 1) ("Citet*" . 1) + ("citep" . 2) ("citep*" . 2) + ("Citep" . 2) ("Citep*" . 2) + ("citealt" . 1) ("citealt*" . 1) + ("Citealt" . 1) ("Citealt*" . 1) + ("citealp" . 2) ("citealp*" . 2) + ("Citealp" . 2) ("Citealp*" . 2)))) + ;; Taken from natbib.el: + (apply + #'TeX-add-symbols + (mapcar + (lambda (cmd) + (cond + ((= (cdr cmd) 1) + ;; Just one optional argument, the post note + (list + (car cmd) + '(TeX-arg-conditional TeX-arg-cite-note-p (["Postnote"]) nil) + 'TeX-arg-cite)) + ((= (cdr cmd) 2) + ;; Pre and post notes + (list + (car cmd) + '(TeX-arg-conditional TeX-arg-cite-note-p + ([LaTeX-arg-biblatex-natbib-notes]) + nil) + 'TeX-arg-cite)))) + cmds)) + + ;; Fontification for compat macros does not go into `font-latex.el': + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("citet" "*[{") + ("Citet" "*[{") + ("citep" "*[[{") + ("Citep" "*[[{") + ("citealt" "*[{") + ("Citealt" "*[{") + ("citealp" "*[[{") + ("Citealp" "*[[{")) + 'biblatex)))) + (LaTeX-add-environments ;;; Bibliography commands ;; Bibliography Sections diff --git a/style/bidi.el b/style/bidi.el index 69beb6a6..095eb144 100755 --- a/style/bidi.el +++ b/style/bidi.el @@ -1,6 +1,6 @@ ;;; bidi.el --- AUCTeX style for the (XeLaTeX) bidi package -;; Copyright (C) Free Software Foundation +;; Copyright (C) 2016 Free Software Foundation, Inc. ;; Author: Uwe Brauer <o...@mat.ucm.es> ;; Created: 2016-03-06 diff --git a/style/natbib.el b/style/natbib.el index a224c5b3..d56642c2 100644 --- a/style/natbib.el +++ b/style/natbib.el @@ -32,7 +32,7 @@ ;; The number in the cdr of the following list indicates how many ;; optional note arguments we consider useful. Prompting for those ;; arguments will still depend upon `TeX-arg-cite-note-p'. - (let ((citecmds + (let ((citecmds '(("cite" . 0) ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1) ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2) @@ -41,11 +41,11 @@ ("shortcites" . 0)))) ;; Add these symbols - (apply + (apply 'TeX-add-symbols (mapcar (lambda (cmd) - (cond + (cond ((= (cdr cmd) 0) ;; No optional arguments (list (car cmd) 'TeX-arg-cite)) @@ -59,14 +59,14 @@ ;; Pre and post notes (list (car cmd) - '(TeX-arg-conditional TeX-arg-cite-note-p (natbib-note-args) nil) + '(TeX-arg-conditional TeX-arg-cite-note-p ([LaTeX-arg-natbib-notes]) nil) 'TeX-arg-cite)))) citecmds)) ;; Add the other symbols (TeX-add-symbols '("citetext" "Text") - '("bibpunct" ["Post note separator"] + '("bibpunct" ["Post note separator"] "Opening bracket" "Closing bracket" "Punctuation between multiple citations" @@ -82,7 +82,7 @@ (add-to-list 'TeX-complete-list (list - (concat "\\\\\\(" + (concat "\\\\\\(" (mapconcat (lambda (x) (regexp-quote (car x))) citecmds "\\|") "\\)\\(\\[[^]\n\r\\%]*\\]\\)*{\\([^{}\n\r\\%,]*,\\)*\\([^{}\n\r\\%,]*\\)") @@ -108,18 +108,22 @@ (reftex-set-cite-format 'natbib)))) LaTeX-dialect) -(defun natbib-note-args (optional &optional _prompt _definition) - "Prompt for two note arguments a natbib citation command." +(defun LaTeX-arg-natbib-notes (optional) + "Prompt for two note arguments a natbib citation command. +If OPTIONAL is non-nil, insert them in brackets, otherwise in +braces." (if TeX-arg-cite-note-p - (let* ((pre (TeX-read-string - (TeX-argument-prompt optional optional "Pre-note"))) - (post (TeX-read-string - (TeX-argument-prompt optional optional "Post-note")))) - (if (not (string= pre "")) (insert "[" pre "]")) - (if (not (string= post "")) - (insert "[" post "]") - ;; Make sure that we have an empty post note if pre is not empty - (if (string= pre "") (insert "[]")))))) + (let ((pre (TeX-read-string + (TeX-argument-prompt optional nil "Pre-note"))) + (post (TeX-read-string + (TeX-argument-prompt optional nil "Post-note")))) + (TeX-argument-insert pre optional) + (TeX-argument-insert post optional) + ;; pre is given, post is empty: Make sure that we insert an + ;; extra pair of `[]', otherwise pre becomes post + (when (and pre (not (string= pre "")) + (string= post "")) + (insert LaTeX-optop LaTeX-optcl))))) (defvar LaTeX-natbib-package-options '("numbers" "super" "authoryear" "round" "square" "angle" "curly"