[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master fe3ef154: Support verbatim shorthands defined with fancyvrb packa
From: |
Arash Esbati |
Subject: |
master fe3ef154: Support verbatim shorthands defined with fancyvrb package |
Date: |
Fri, 18 Aug 2023 07:40:29 -0400 (EDT) |
branch: master
commit fe3ef154cd31227b34c3085ec8f7b375f0a56169
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Support verbatim shorthands defined with fancyvrb package
* style/fancyvrb.el ("fancyvrb"): Process characters defined in
`LaTeX-fancyvrb-chars'.
* tex-style.el (LaTeX-fancyvrb-chars): New variable containing
characters defined by \DefineShortVerb toggling verb mode.
---
style/fancyvrb.el | 23 +++++++++++++++++++++++
tex-style.el | 26 +++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 56f5172b..530b0621 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -806,6 +806,14 @@ a list of strings."
(add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb")
(add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb*")
+ ;; Ispell: Add entries to `ispell-tex-skip-alist':
+ (when LaTeX-fancyvrb-chars
+ (TeX-ispell-skip-setcar
+ (mapcar (lambda (char)
+ (let ((str (char-to-string char)))
+ (cons str str)))
+ LaTeX-fancyvrb-chars)))
+
;; Fontification
(when (and (fboundp 'font-latex-add-keywords)
(fboundp 'font-latex-set-syntactic-keywords)
@@ -838,6 +846,21 @@ a list of strings."
(when (member "fvextra" (TeX-style-list))
(LaTeX-fancyvrb-add-syntactic-keywords-extra 'brace
"SaveVerb"))
+
+ ;; Use `font-latex-syntactic-keywords-extra' instead of
+ ;; `font-latex-add-to-syntax-alist' so we can catch a backslash
+ ;; within the shortverb delimiters and make things like |xyz\|
+ ;; work correctly:
+ (when LaTeX-fancyvrb-chars
+ (dolist (c LaTeX-fancyvrb-chars)
+ (let ((s (char-to-string c)))
+ (add-to-list 'font-latex-syntactic-keywords-extra
+ `(,(concat "\\(" s "\\)"
+ ".*?"
+ "\\(" (regexp-quote TeX-esc) "*\\)"
+ "\\(" s "\\)")
+ (1 "\"") (2 ".") (3 "\""))))))
+
;; Tell font-lock about the update
(font-latex-set-syntactic-keywords)))
TeX-dialect)
diff --git a/tex-style.el b/tex-style.el
index d273ea08..615f49a1 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -1,6 +1,6 @@
;;; tex-style.el --- Customizable variables for AUCTeX style files -*-
lexical-binding: t; -*-
-;; Copyright (C) 2005-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2023 Free Software Foundation, Inc.
;; Author: Reiner Steib <Reiner.Steib@gmx.de>
;; Keywords: tex, wp, convenience
@@ -283,6 +283,30 @@ is initialized to ?x."
"Default prefix to labels in environments of exam class."
:type 'string)
+;; style/fancyvrb.el
+
+(defcustom LaTeX-fancyvrb-chars nil
+ "List of characters toggling verbatim mode.
+When your document uses the fancyvrb package and you have a
+\\DefineShortVerb{\\|} in your file to write verbatim text as
+|text|, then set this variable to the list (?|). Then AUCTeX
+fontifies |text| as verbatim.
+
+Preferably, you should do this buffer-locally using a file
+variable near the end of your document like so:
+
+ %% Local Variables:
+ %% LaTeX-fancyvrb-chars: (?|)
+ %% End:
+
+When you customize this variable to a non-nil value, then it
+becomes the default value meaning that verbatim fontification is
+always performed for the characters in the list, no matter if
+your document actually defines shortverb chars using
+\\DefineShortVerb."
+ :type '(repeat character))
+(put 'LaTeX-fancyvrb-chars 'safe-local-variable #'listp)
+
;; style/fontspec.el
(defcustom LaTeX-fontspec-arg-font-search t
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master fe3ef154: Support verbatim shorthands defined with fancyvrb package,
Arash Esbati <=