branch: master
commit 256f4c1309ce687d25676616dc81a8ec472b8bd8
Author: Arash Esbati <[email protected]>
Commit: Arash Esbati <[email protected]>

    Add new style/diagbox.el
    
    * Makefile.in (STYLESRC): Add new style.
    
    * style/diagbox.el: New file.
---
 Makefile.in      |  3 +-
 style/diagbox.el | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/Makefile.in b/Makefile.in
index 93405c56..c4143fcb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -198,7 +198,8 @@ STYLESRC = style/prosper.el \
           style/amsaddr.el   style/parskip.el   style/catchfilebetweentags.el \
           style/physics.el   style/soul.el      style/algpseudocodex.el \
           style/wasysym.el   style/refcount.el  style/simpleicons.el \
-          style/changebar.el style/amsrefs.el   style/standalone.el
+          style/changebar.el style/amsrefs.el   style/standalone.el \
+          style/diagbox.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/style/diagbox.el b/style/diagbox.el
new file mode 100644
index 00000000..d73ece7a
--- /dev/null
+++ b/style/diagbox.el
@@ -0,0 +1,91 @@
+;;; geometry.el --- AUCTeX style for `diagbox.sty' (v2.3)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <[email protected]>
+;; Maintainer: [email protected]
+;; Created: 2024-05-30
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `diagbox.sty' (v2.3) from 2020/02/09.
+;; `diagbox.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(defvar LaTeX-diagbox-key-val-options
+  `(("width")
+    ("height" ("\\line"))
+    ("dir" ("NW" "NE" "SW" "SE"))
+    ("innerwidth")
+    ("innerleftsep")
+    ("innerrightsep")
+    ("outerleftsep")
+    ("outerrightsep")
+    ("leftsep")
+    ("rightsep")
+    ("trim" ("l" "r" "lr" "rl"))
+    ("font" ,(mapcar (lambda (x) (concat TeX-esc x))
+                     (append LaTeX-font-size LaTeX-font-shape
+                             LaTeX-font-series)))
+    ("linewidth"))
+  "Key=val options for the \\diagbox macro.")
+
+(defun LaTeX-diagbox-key-val-options ()
+  "Return updated key=val options for the \\diagbox macro."
+  (append
+   `(("linecolor" ,(cond ((fboundp 'LaTeX-xcolor-definecolor-list)
+                          (mapcar #'car (LaTeX-xcolor-definecolor-list)))
+                         ((fboundp 'LaTeX-color-definecolor-list)
+                          (mapcar #'car (LaTeX-color-definecolor-list))))))
+   LaTeX-diagbox-key-val-options))
+
+(TeX-add-style-hook
+ "diagbox"
+ (lambda ()
+   (TeX-add-symbols
+    '("diagbox"
+      [TeX-arg-key-val (LaTeX-diagbox-key-val-options)]
+      (TeX-arg-conditional (y-or-n-p "With 2 arguments? ")
+          (2)
+        (3))))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("diagbox" "[{{"))
+                              ;; Fontify only 2 args and not 3 since the
+                              ;; last one is somehow optional
+                              'textual)))
+ TeX-dialect)
+
+(defvar LaTeX-diagbox-package-options nil
+  "Package options for the diagbox package.")
+
+;;; diagbox.el ends here

Reply via email to