branch: externals/auctex
commit b474c139fa080f0693fcee5e084fe92f5daa84f0
Author: Arash Esbati <[email protected]>
Commit: Arash Esbati <[email protected]>
Improve fontification of '*' and '+' between arguments
* font-latex.el (font-latex-match-command-with-arguments): Fontify
asterisk or plus sign between arguments correctly. (Bug#79878)
* style/paracol.el ("paracol"): Adjust accordingly.
---
font-latex.el | 18 ++++++++++++++++--
style/paracol.el | 12 +++---------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/font-latex.el b/font-latex.el
index 3da68ba4b3..7873a4a568 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1617,8 +1617,7 @@ Returns nil if none of KEYWORDS is found."
;; Check for starred macro if first spec is an asterisk or a
;; plus sign in case of \defaultfontfeatures+ provided by
;; fontspec.sty
- (when (or (eq (car spec-list) ?*)
- (eq (car spec-list) ?+))
+ (when (memql (car spec-list) '(?* ?+))
(setq spec-list (cdr spec-list))
(skip-chars-forward "*+" (1+ (point))))
;; Add current point to match data and use keyword face for
@@ -1669,6 +1668,21 @@ Returns nil if none of KEYWORDS is found."
(when (and match-beg (= match-beg (point)))
(setq error-indicator-pos match-beg))
(throw 'break nil))))
+ ;; Asterisk or plus sign between arguments (sigh!):
+ ((and (memql spec '(?* ?+))
+ (= (char-after) spec))
+ (setq match-beg (point))
+ (if (= (char-after) spec)
+ (progn
+ (nconc match-data
+ (list (point)
+ (progn
+ (skip-chars-forward "*+")
+ (point))))
+ (nconc font-latex-matched-faces
+ (list 'font-lock-keyword-face))
+ (setq end (max end (point))))
+ (throw 'break nil)))
;; Optional arguments: [...] and others
((eq (char-after) spec)
(setq match-beg (point))
diff --git a/style/paracol.el b/style/paracol.el
index ea036e6a00..a2682a268e 100644
--- a/style/paracol.el
+++ b/style/paracol.el
@@ -55,7 +55,7 @@
If OPTIONAL is non-nil, insert the result in square brackets."
(let ((col (TeX-read-string
(TeX-argument-prompt optional nil "Column"))))
- (when (and col (not (string= col "")))
+ (when (and col (not (string-empty-p col)))
(save-excursion
(backward-char 1)
(TeX-argument-insert col optional)))))
@@ -130,7 +130,7 @@ If XCOLOR is non-nil, store the returned value in the
variable
;; \switchcolumn[col]
;; \switchcolumn[col]*[text]
'("switchcolumn" [ "Column" ] )
- '("switchcolumn*" [ TeX-arg-paracol-switchcolumn* ] )
+ '("switchcolumn*" [ TeX-arg-paracol-switchcolumn* ])
'("thecolumn")
'("definecolumnpreamble" "Column" t)
'("ensurevspace" TeX-arg-length)
@@ -304,13 +304,7 @@ If XCOLOR is non-nil, store the returned value in the
variable
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("switchcolumn" "*["))
- ;; FIXME: Syntax is
- ;; \switchcolumn[num]*[text].
- ;; font-latex.el doesn't handle the case
- ;; where `*' comes after the first `['.
- ;; Therefore, we use this compromise to
- ;; get something fontified at least.
+ (font-latex-add-keywords '(("switchcolumn" "[*["))
'textual)
(font-latex-add-keywords '(("flushpage" "*["))
'warning)