auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. d8c6f94eaa98cbcbf62fd


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. d8c6f94eaa98cbcbf62fd915726544135c5faa04
Date: Wed, 31 Oct 2018 17:27:49 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  d8c6f94eaa98cbcbf62fd915726544135c5faa04 (commit)
      from  36943732d87a2a9bac9a144541b0936c7ba5883d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d8c6f94eaa98cbcbf62fd915726544135c5faa04
Author: Arash Esbati <address@hidden>
Date:   Wed Oct 31 22:27:17 2018 +0100

    Improve style/fancyvrb.el
    
    * style/fancyvrb.el (LaTeX-fancyvrb-arg-define-macro): Refactor
    code. Cater for starred version of user defined macros.  Add
    missing `,' in backquote constructs.
    (LaTeX-fancyvrb-arg-define-environment): Refactor code.
    ("fancyvrb"): Add \Verb* macro incl. fontification.

diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 3b33350..cc673f9 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -1,6 +1,6 @@
 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 2.8.
 
-;; Copyright (C) 2013, 2014, 2016, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2016--2018 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Mosè Giordano <address@hidden>
@@ -193,21 +193,27 @@ CLEANUP is non-nil, do not insert any arguments in the 
buffer and
 update only various AUCTeX variables for verbatim macros.  If
 RECUSTOM is non-nil, delete macros from the variable
 `TeX-symbol-list' before adding the new ones."
-  (let ((new-mac (unless cleanup
-                  (if recustom
+  ;; This part is only relevant when called by user:
+  (unless cleanup
+    (let ((new-mac (if recustom
                       (completing-read
                        (TeX-argument-prompt optional nil "Verbatim macro: \\" 
t)
                        (mapcar #'car (apply #'append 
LaTeX-fancyvrb-macro-list)))
                     (TeX-read-string
-                     (TeX-argument-prompt optional nil "New verbatim macro: 
\\" t)))))
-       (base-mac (unless cleanup
-                   (completing-read (TeX-argument-prompt optional nil "Based 
on macro")
-                                    LaTeX-fancyvrb-base-macros)))
-       (rec-flag (if recustom "Rec" "C")))
-    ;; We are (re-)defining a macro: Insert user queried input and use
-    ;; `LaTeX-add-fancyvrb-macros' on the input
-    (unless cleanup
-      (TeX-argument-insert new-mac optional TeX-esc)
+                     (TeX-argument-prompt optional nil "New verbatim macro: 
\\" t))))
+         (base-mac (completing-read (TeX-argument-prompt optional nil "Based 
on macro")
+                                    LaTeX-fancyvrb-base-macros))
+         (rec-flag (if recustom "Rec" "C")))
+      ;; We are (re-)defining a macro: Insert user queried input and
+      ;; use `LaTeX-add-fancyvrb-macros' on the input.  Do not enclose
+      ;; the first argument in braces as this will improve
+      ;; fontification.  Otherwise, the part between 2 closing braces
+      ;; get fontified, i.e.:
+      ;; \CustomVerbatimCommand{\foo}{Verb}{}
+      ;;                            ^     ^
+      (let ((TeX-arg-opening-brace "")
+           (TeX-arg-closing-brace ""))
+       (TeX-argument-insert new-mac optional TeX-esc))
       (TeX-argument-insert base-mac optional)
       (TeX-argument-insert
        (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) 
optional)
@@ -268,13 +274,21 @@ RECUSTOM is non-nil, delete macros from the variable
            ;; Anything else is considered as verbatim typesetting macro:
            (t
             (TeX-add-symbols
-             `(mac-name
+             `(,mac-name
+               [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+               TeX-arg-verb)
+             ;; Defined macros have a starred version where the
+             ;; `showspaces' key is set to true
+             `(,(concat mac-name "*")
                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
                TeX-arg-verb))
-            (add-to-list 'LaTeX-verbatim-macros-with-delims-local mac-name t)
+            (add-to-list 'LaTeX-verbatim-macros-with-delims-local
+                         mac-name t)
+            (add-to-list 'LaTeX-verbatim-macros-with-delims-local
+                         (concat mac-name "*") t)
             (when (and (fboundp 'font-latex-add-keywords)
                        (fboundp 'font-latex-update-font-lock))
-              (font-latex-add-keywords `((,mac-name "["))
+              (font-latex-add-keywords `((,mac-name "*["))
                                        'textual))))))
   ;; Update font-lock:
   (when (and (fboundp 'font-latex-add-keywords)
@@ -287,70 +301,70 @@ RECUSTOM is non-nil, delete macros from the variable
 If OPTIONAL is non-nil, insert the arguments in brackets.  If
 CLEANUP is non-nil, do not insert any arguments in the buffer and
 update only various AUCTeX variables for verbatim environments."
-  (let ((new-env (unless cleanup
-                  (TeX-read-string
-                   (TeX-argument-prompt optional nil "New verbatim 
environment"))))
-       (base-env (unless cleanup
-                   (completing-read (TeX-argument-prompt optional nil "Based 
on environment")
-                                    LaTeX-fancyvrb-base-environments))))
-    ;; We are defining a new env: First insert the arguments and the
-    ;; run `LaTeX-add-fancyvrb-environments' on '(new-env base-env).
-    ;; If base-env is SaveVerbatim, run
-    ;; `LaTeX-add-fancyvrb-saveverbatims' on new-env as well.
-    (unless cleanup
-      (TeX-argument-insert (car new-env) optional)
+  (unless cleanup
+    (let ((new-env (TeX-read-string
+                   (TeX-argument-prompt optional nil "New verbatim 
environment")))
+         (base-env (completing-read
+                    (TeX-argument-prompt optional nil "Based on environment")
+                    LaTeX-fancyvrb-base-environments)))
+      ;; We are defining a new env: First insert the arguments and then
+      ;; run `LaTeX-add-fancyvrb-environments' on '(new-env base-env).
+      ;; If base-env is SaveVerbatim, run
+      ;; `LaTeX-add-fancyvrb-saveverbatims' on new-env as well.
+      (TeX-argument-insert new-env optional)
       (TeX-argument-insert base-env optional)
       (TeX-argument-insert
        (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) 
optional)
       (LaTeX-add-fancyvrb-environments `(,new-env ,base-env))
       (when (string= base-env "SaveVerbatim")
-       (LaTeX-add-fancyvrb-saveverbatims new-env)))
-    ;;
-    ;; Now run the procdure:
-    (dolist (elt (LaTeX-fancyvrb-environment-list))
-      (let ((env (car elt))
-           (type (cadr elt)))
-       (cond ((string= type "VerbatimOut")
-              (LaTeX-add-environments
-               `(,env (lambda (env)
-                        (let ((options (TeX-read-key-val t 
LaTeX-fancyvrb-key-val-options-local))
-                              (file (TeX-read-string "Output file: ")))
-                          (LaTeX-insert-environment
-                           env
-                           (concat
-                            (unless (zerop (length options))
-                              (concat LaTeX-optop options LaTeX-optcl))
-                            (concat TeX-grop file TeX-grcl))))))))
-             ((string= type "SaveVerbatim")
-              (TeX-auto-add-regexp `(,(concat "\\\\begin{"
-                                              env
-                                              "}"
-                                              
LaTeX-fancyvrb-key-val-skip-regexp
-                                              "{\\([^}]+\\)}")
-                                     1 LaTeX-auto-fancyvrb-saveverbatim)))
-             (t
-              ;; Regular verbatim environments have a starred
-              ;; version; so add them here; the non-starred additions
-              ;; to `LaTeX-verbatim-environments-local' and
-              ;; `LaTeX-indent-environment-list' are done outside
-              ;; (cond ...):
-              (LaTeX-add-environments
-               `(,env LaTeX-env-args
-                      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local 
]))
-              (LaTeX-add-environments
-               `(,(concat env "*") LaTeX-env-args
-                 [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]))
-              (add-to-list 'LaTeX-verbatim-environments-local (concat env "*"))
-              (add-to-list 'LaTeX-indent-environment-list
-                           `(,(concat env "*") current-indentation) t)))
-       ;; These apply for all environments defined:
-       (add-to-list 'LaTeX-verbatim-environments-local env)
-       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation) 
t)))
-    ;; Update font-lock:
-    (when (and (fboundp 'font-latex-add-keywords)
-              (fboundp 'font-latex-update-font-lock)
-              (eq TeX-install-font-lock 'font-latex-setup))
-      (font-latex-update-font-lock t))))
+       (LaTeX-add-fancyvrb-saveverbatims new-env))))
+  ;;
+  ;; Now run the procdure:
+  (dolist (elt (LaTeX-fancyvrb-environment-list))
+    (let ((env (car elt))
+         (type (cadr elt)))
+      (cond ((string= type "VerbatimOut")
+            (LaTeX-add-environments
+             `(,env (lambda (env)
+                      (let ((options (TeX-read-key-val
+                                      t LaTeX-fancyvrb-key-val-options-local))
+                            (file (TeX-read-string "Output file: ")))
+                        (LaTeX-insert-environment
+                         env
+                         (concat
+                          (unless (zerop (length options))
+                            (concat LaTeX-optop options LaTeX-optcl))
+                          (concat TeX-grop file TeX-grcl))))))))
+           ((string= type "SaveVerbatim")
+            (TeX-auto-add-regexp `(,(concat "\\\\begin{"
+                                            env
+                                            "}"
+                                            LaTeX-fancyvrb-key-val-skip-regexp
+                                            "{\\([^}]+\\)}")
+                                   1 LaTeX-auto-fancyvrb-saveverbatim)))
+           (t
+            ;; Regular verbatim environments have a starred
+            ;; version; so add them here; the non-starred additions
+            ;; to `LaTeX-verbatim-environments-local' and
+            ;; `LaTeX-indent-environment-list' are done outside
+            ;; (cond ...):
+            (LaTeX-add-environments
+             `(,env LaTeX-env-args
+                    [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]))
+            (LaTeX-add-environments
+             `(,(concat env "*") LaTeX-env-args
+               [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]))
+            (add-to-list 'LaTeX-verbatim-environments-local (concat env "*"))
+            (add-to-list 'LaTeX-indent-environment-list
+                         `(,(concat env "*") current-indentation) t)))
+      ;; These apply for all environments defined:
+      (add-to-list 'LaTeX-verbatim-environments-local env)
+      (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation) 
t)))
+  ;; Update font-lock:
+  (when (and (fboundp 'font-latex-add-keywords)
+            (fboundp 'font-latex-update-font-lock)
+            (eq TeX-install-font-lock 'font-latex-setup))
+    (font-latex-update-font-lock t)))
 
 (defun LaTeX-fancyvrb-arg-file-relative (optional)
   "Query and insert a file name relative to current master file.
@@ -380,6 +394,8 @@ If OPTIONAL is non-nil, insert the file name in brackets."
     "VerbatimFootnotes"
     ;; Improved verbatim commands
     '("Verb" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] 
TeX-arg-verb)
+    ;; \Verb also has a starred version:
+    '("Verb*" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] 
TeX-arg-verb)
     '("DefineShortVerb" (TeX-arg-eval
                         TeX-read-string
                         (TeX-argument-prompt optional nil "Character")
@@ -503,13 +519,14 @@ If OPTIONAL is non-nil, insert the file name in brackets."
    (add-to-list 'LaTeX-indent-environment-list '("SaveVerbatim" 
current-indentation) t)
    (add-to-list 'LaTeX-indent-environment-list '("VerbatimOut" 
current-indentation) t)
    (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb")
+   (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb*")
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
              (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("CustomVerbatimCommand"       "{{{")
-                               ("RecustomVerbatimCommand"     "{{{")
+     (font-latex-add-keywords '(("CustomVerbatimCommand"       "|{\\{{")
+                               ("RecustomVerbatimCommand"     "|{\\{{")
                                ("DefineVerbatimEnvironment"   "{{{")
                                ("RecustomVerbatimEnvironment" "{{{")
                                ("DefineShortVerb"   "{")
@@ -520,8 +537,7 @@ If OPTIONAL is non-nil, insert the file name in brackets."
                                ("BVerbatimInput" "[{")
                                ("LVerbatimInput" "[{"))
                              'reference)
-     (font-latex-add-keywords '(("Verb" "[") ; The second argument should
-                                       ; actually be verbatim.
+     (font-latex-add-keywords '(("Verb" "*[") ; The second argument is 
verbatim.
                                ("SaveVerb"     "[{")
                                ("UseVerb"      "{")
                                ("UseVerbatim"  "{")

-----------------------------------------------------------------------

Summary of changes:
 style/fancyvrb.el | 172 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 94 insertions(+), 78 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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