Re: [AUCTeX-devel] Harmonizing biblatex and natbib styles

2016-11-02 Thread Arash Esbati
Arash Esbati  writes:

> I *touched* natbib.el and updated it to v8.31b of the package (diff is
> attached).
>
> I would like to harmonize the compat mode in biblatex.el and natbib.el
> itself.  The main issue is this comment in natbib.el:
>
> ;; The number in the cdr of the following list indicates how many
> ;; optional note arguments we consider useful.
>   
>
> For instance, \citet takes 2 optional arguments, but natbib.el offers
> only 1 for completion, but adds 2 to fontification.  Reftex OTOH offers
> both when invoked with `C-u C-['.  I do understand the rationale behind
> this decision, but it is not really consistent over the different files.
>
> WDYT, should AUCTeX strictly stick with the way macros are defined or do
> we accept some variations in order to make things more user friendly?  I
> have a preference for `all or nothing'.

Following up myself, I rethought this issue and I decided to leave it as
is.  I think the annoyance factor will be greater over time.  I've
pushed an update to natbib.el catching up to version 8.31b of the
package.

Best, Arash

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Harmonizing biblatex and natbib styles

2016-10-18 Thread Arash Esbati
Hi all,

I *touched* natbib.el and updated it to v8.31b of the package (diff is
attached).

I would like to harmonize the compat mode in biblatex.el and natbib.el
itself.  The main issue is this comment in natbib.el:

;; The number in the cdr of the following list indicates how many
;; optional note arguments we consider useful.
  

For instance, \citet takes 2 optional arguments, but natbib.el offers
only 1 for completion, but adds 2 to fontification.  Reftex OTOH offers
both when invoked with `C-u C-['.  I do understand the rationale behind
this decision, but it is not really consistent over the different files.

WDYT, should AUCTeX strictly stick with the way macros are defined or do
we accept some variations in order to make things more user friendly?  I
have a preference for `all or nothing'.

Best, Arash

diff --git a/style/natbib.el b/style/natbib.el
index d56642c..7887ad8 100644
--- a/style/natbib.el
+++ b/style/natbib.el
@@ -1,6 +1,6 @@
-;;; natbib.el --- Style hook for the natbib package
+;;; natbib.el --- AUCTeX style for `natbib.sty' version 8.31b
 
-;; Copyright (C) 1997, 1998, 2004, 2007, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2004, 2007, 2014, 2016 Free Software Foundation, Inc.
 
 ;; Authors: Berwin Turlach 
 ;;  Carsten Dominik 
@@ -26,86 +26,132 @@
 
 ;;; Code:
 
-(TeX-add-style-hook "natbib"
- (function
-  (lambda ()
-;; 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
-	'(("cite" . 0)
-	  ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1)
-	  ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2)
-	  ("citeauthor" . 0) ("citeauthor*" . 0) ("citefullauthor" . 0)
-	  ("citeyear" . 0) ("citeyearpar" . 0)
-	  ("shortcites" . 0
-
-  ;; Add these symbols
-  (apply
-   'TeX-add-symbols
-   (mapcar
-	(lambda (cmd)
-	  (cond
-	   ((= (cdr cmd) 0)
-	;; No optional arguments
-	(list (car cmd) 'TeX-arg-cite))
-	   ((= (cdr cmd) 1)
-	;; Just one optional argument, the post note
-	(list
-	 (car cmd)
-	 '(TeX-arg-conditional TeX-arg-cite-note-p (["Post-note"]) nil)
-	 'TeX-arg-cite))
-	   ((= (cdr cmd) 2)
-	;; Pre and post notes
-	(list
-	 (car cmd)
-	 '(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"]
-		 "Opening bracket"
-		 "Closing bracket"
-		 "Punctuation between multiple citations"
-		 "style [n]umeric [s]uperscript [a]uthor-year"
-		 "Punctuation between author and year"
-		 "Punctuation between years for common authors")
-   '("citestyle" "Style")
-   '("citeindextrue")
-   '("citeindexfalse")
-   '("citeindextype"))
-
-  ;; Make an entry in TeX-complete-list
-  (add-to-list
-   'TeX-complete-list
-   (list
-	(concat "\\("
-		(mapconcat (lambda (x) (regexp-quote (car x)))
-			   citecmds "\\|")
-		"\\)\\(\\[[^]\n\r\\%]*\\]\\)*{\\([^{}\n\r\\%,]*,\\)*\\([^{}\n\r\\%,]*\\)")
-	4 'LaTeX-bibitem-list "}")))
-
-;; Fontification
-(when (and (fboundp 'font-latex-add-keywords)
-	   (eq TeX-install-font-lock 'font-latex-setup))
-  (font-latex-add-keywords '(("cite" "*[[{")
- ("citet" "*[[{")
- ("citealt" "*[[{")
- ("citep" "*[[{")
- ("citealp" "*[[{")
- ("citeauthor" "*[[{")
- ("citefullauthor" "[[{")
- ("citeyear" "[[{")
- ("citeyearpar" "[[{")
- ("shortcites" "{"))
-			   'reference))
-
-;; Tell RefTeX
-(if (fboundp 'reftex-set-cite-format)
-	(reftex-set-cite-format 'natbib
+(TeX-add-style-hook
+ "natbib"
+ (lambda ()
+   ;; 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
+	   '(("cite" . 0)
+	 ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1)
+	 ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2)
+	 ("citeauthor" . 0) ("citeauthor*" . 0) ("citefullauthor" . 0)
+	 ("citeyear" . 0) ("citeyearpar" . 0)
+	 ("shortcites" . 0)
+	 ;; 2.4 Extended Citation Commands
+	 ("citenum" . 0)
+	 ;; 2.5 Forcing Upper Cased Name
+	 ("Citet" . 1) ("Citet*" . 1) ("Citealt" . 1) ("Citealt*" . 1)
+	 ("Citep" . 2) ("Citep*" . 2) ("Citealp" . 2) ("Citealp*" . 2)
+	 ;; 2.6 Citation Aliasing
+	 ("citetalias" . 1) ("citepalias" . 2
+
+ ;; Add these symbols
+ (apply
+  'TeX-add-symbols
+  (mapcar
+   (lambda (cmd)
+	 (cond
+	  ((= (cdr cmd) 0)
+	   ;; No optional arguments
+	   (list (car cmd) 'TeX-arg-cite))
+