emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex e8b451297a 33/39: Improve query of optional note


From: Tassilo Horn
Subject: [elpa] externals/auctex e8b451297a 33/39: Improve query of optional notes for natbib cite macros
Date: Thu, 20 Jul 2023 04:21:51 -0400 (EDT)

branch: externals/auctex
commit e8b451297a922515ef5ba277e8b936669a1013a8
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Improve query of optional notes for natbib cite macros
    
    * style/natbib.el (LaTeX-arg-natbib-notes): Change the function to
    read and insert only the post-note of a \cite macro, the pre-note
    is queried inside the hook.
    
    * style/revtex4-2.el ("revtex4-2"): Adjust the hook to the change
    of `LaTeX-arg-natbib-notes'.
    Use `function-noarg' as keyword class.
    Add missing call of `font-latex-set-syntactic-keywords'.
---
 style/natbib.el    | 31 +++++++++++++++----------------
 style/revtex4-2.el | 25 +++++++++++++++++--------
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/style/natbib.el b/style/natbib.el
index 3cac59606d..b7eb9838fc 100644
--- a/style/natbib.el
+++ b/style/natbib.el
@@ -74,7 +74,9 @@
            ;; Pre and post notes
            (list
             (car cmd)
-            '(TeX-arg-conditional TeX-arg-cite-note-p 
([LaTeX-arg-natbib-notes]) nil)
+            '(TeX-arg-conditional TeX-arg-cite-note-p
+                 (["Pre-note"] LaTeX-arg-natbib-notes)
+               nil)
             #'TeX-arg-cite))))
        citecmds))
 
@@ -173,21 +175,18 @@
      (reftex-set-cite-format 'natbib)))
  TeX-dialect)
 
-(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."
-  (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))))
+(defun LaTeX-arg-natbib-notes (_optional)
+  "Prompt for the post-note argument of a natbib citation command.
+OPTIONAL is ignored."
+  (let ((post (TeX-read-string
+               (TeX-argument-prompt t nil "Post-note")))
+        (TeX-arg-opening-brace LaTeX-optop)
+        (TeX-arg-closing-brace LaTeX-optcl))
+    ;; Pre-note is given, Post-note is empty: Make sure that we insert
+    ;; an extra pair of `[]', otherwise pre becomes post
+    (if (and (string-empty-p post) (= (preceding-char) ?\]))
+        (insert LaTeX-optop LaTeX-optcl)
+      (TeX-argument-insert post t))))
 
 (defvar LaTeX-natbib-package-options '("numbers" "super" "authoryear"
                                        "round" "square" "angle" "curly"
diff --git a/style/revtex4-2.el b/style/revtex4-2.el
index 26a5eff5d2..13020afbaa 100644
--- a/style/revtex4-2.el
+++ b/style/revtex4-2.el
@@ -1,6 +1,6 @@
 ;;; revtex4-2.el --- AUCTeX style for `revtex4-2.cls' (v4.2c)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2020--2023 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -38,6 +38,8 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
+(declare-function font-latex-set-syntactic-keywords
+                  "font-latex")
 (defvar LaTeX-natbib-package-options)
 (defvar LaTeX-url-package-options)
 
@@ -132,10 +134,14 @@ provided by REVTeX class."
 
     ;; VIII.1. Citing a reference
     '("onlinecite"
-      (TeX-arg-conditional TeX-arg-cite-note-p ([LaTeX-arg-natbib-notes]) nil)
+      (TeX-arg-conditional TeX-arg-cite-note-p
+          (["Pre-note"] LaTeX-arg-natbib-notes)
+        nil)
       TeX-arg-cite)
     '("textcite"
-      (TeX-arg-conditional TeX-arg-cite-note-p ([LaTeX-arg-natbib-notes]) nil)
+      (TeX-arg-conditional TeX-arg-cite-note-p
+          (["Pre-note"] LaTeX-arg-natbib-notes)
+        nil)
       TeX-arg-cite)
 
     ;; IX.2 video environment
@@ -192,13 +198,14 @@ provided by REVTeX class."
               (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("fbox"          "*[{")
                                 ("keywords"      "{")
-                                ("preprint"      "")
-                                ("onecolumngrid" "")
-                                ("twocolumngrid" "")
-                                ("squeezetable"  "")
                                 ("printtables"   "*")
                                 ("printfigures"  "*"))
                               'function)
+     (font-latex-add-keywords '("preprint"
+                                "onecolumngrid"
+                                "twocolumngrid"
+                                "squeezetable")
+                              'function-noarg)
      (font-latex-add-keywords '(("affiliation"    "{")
                                 ("noaffiliation"  "")
                                 ("collaboration"  "{")
@@ -211,7 +218,9 @@ provided by REVTeX class."
                                 ("setfloatlink" ""))
                               'reference)
      (font-latex-add-keywords '(("appendix*" ""))
-                              'warning)))
+                              'warning)
+     ;; Tell font-lock about the update
+     (font-latex-set-syntactic-keywords)))
  TeX-dialect)
 
 (defvar LaTeX-revtex4-2-class-options



reply via email to

[Prev in Thread] Current Thread [Next in Thread]