branch: externals/matlab-mode
commit d49fa62458208140c67970e9c2ec7f5591f40b1c
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    matlab-ts-mode: organize faces, add M-x matlab-ts-describe-faces
---
 NEWS.org                               |  19 +-
 matlab-mode.el                         |   2 +-
 matlab-sections.el                     |  12 +-
 matlab-ts-mode.el                      | 322 ++++++++++++++++++++++++++-------
 matlab.el                              |   2 +-
 tests/test-matlab-ts-describe-faces.el |  98 ++++++++++
 6 files changed, 380 insertions(+), 75 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index c2227b044e..b9b7843a5b 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -3,9 +3,23 @@
 
 # Copyright (C) 2025 Free Software Foundation, Inc.
 
+* Release 7.4.0 Nov 26, 2025
+
+1. Place the =matlab-*-face= definitions in customize matlab-ts-faces group.
+
+2. Add =M-x matlab-ts-describe-faces= along with menu item
+
+   : MATLAB -> Describe faces
+
+   that will bring up a help buffer containing the faces used by 
matlab-ts-mode.  From there you can
+   customize them. This differs from viewing the matlab-ts-faces group in that 
it contains both
+   matlab-*-faces plus other built-in faces such as font-lock-type-face. This 
help buffer also
+   contain more information on when the faces are used.
+
 * Release 7.3.4 Nov 25, 2025
 
-1. Adds the source and build instructions for the 
libtree-sitter-matlab.SLIB_EXT binaries
+1. Add the source and build instructions for the 
libtree-sitter-matlab.SLIB_EXT binaries
+   found in [[file:matlab-ts-bin][./matlab-ts-bin]] and used by =M-x 
matlab-ts-grammar-install=.
 
 * Release 7.3.3 Nov 23, 2025
 
@@ -362,4 +376,5 @@ prior to sourceforge no longer exist.
 See older history 
[[https://github.com/mathworks/Emacs-MATLAB-Mode/blob/2ff6f96294353f3f17757a2522a64c427929ff01/ChangeLog][ChangeLog]],
 
[[https://github.com/mathworks/Emacs-MATLAB-Mode/blob/528a4fc79426adc7cf9a484d231dec7defd9c5f4/ChangeLog.old1][ChangeLog.old1]],
 
[[https://github.com/mathworks/Emacs-MATLAB-Mode/blob/528a4fc79426adc7cf9a484d231dec7defd9c5f4/ChangeLog.old2][ChangeLog.old2]],
 and older 
[[https://github.com/mathworks/Emacs-MATLAB-Mode/blob/b7e170ee37a23b6852e461772de1c4e98
 [...]
 
 # LocalWords:  showall ELPA MELPA fontification fontify sexp SPC LSP builtins 
MLint flycheck lsp
-# LocalWords:  netshell emacsinit imenu matlabls netsell sourceforge MMM YYYY 
emacsrunregion
+# LocalWords:  netshell emacsinit imenu matlabls netsell sourceforge MMM YYYY 
emacsrunregion libtree
+# LocalWords:  SLIB abi ce da utils fcf
diff --git a/matlab-mode.el b/matlab-mode.el
index c1f93abad4..59fd156f05 100644
--- a/matlab-mode.el
+++ b/matlab-mode.el
@@ -1,6 +1,6 @@
 ;;; matlab-mode.el --- Major mode for MATLAB(R) dot-m files -*- 
lexical-binding: t -*-
 
-;; Version: 7.3.4
+;; Version: 7.4.0
 ;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 
diff --git a/matlab-sections.el b/matlab-sections.el
index b476cb1ad9..24a08b1d71 100644
--- a/matlab-sections.el
+++ b/matlab-sections.el
@@ -46,19 +46,19 @@
   "MATLAB \"%% code sections\"."
   :group 'matlab)
 
-(defface matlab-sections-highlight-face
-  '((t :weight extra-bold))
-  "Default face for highlighting the current section in 
matlab-sections-minor-mode."
-  :group 'matlab-sections)
-
 (defface matlab-sections-section-break-face
   '((t :inherit font-lock-comment-face
        :overline t
        :height 1.25))
-  "Face for \"%% code section\" headings in matlab-sections-minor-mode.
+  "Face for \"%% code section\" headings in `matlab-sections-minor-mode'.
 This is the face used when demarcating code sections in MATLAB script files."
   :group 'matlab-sections)
 
+(defface matlab-sections-highlight-face
+  '((t :weight extra-bold))
+  "Default face for highlighting the current section in 
`matlab-sections-minor-mode'."
+  :group 'matlab-sections)
+
 (defcustom matlab-sections-highlight-section t
   "Non-nil tells matlab-sections-minor-mode to highlight the current section."
   :type 'boolean
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 22b992f392..8ccf8ca5a8 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -1,6 +1,6 @@
 ;;; matlab-ts-mode.el --- MATLAB(R) Tree-Sitter Mode -*- lexical-binding: t -*-
 
-;; Version: 7.3.4
+;; Version: 7.4.0
 ;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -52,10 +52,77 @@
   :prefix "matlab-ts-mode-"
   :group 'languages)
 
+(defcustom matlab-ts-mode-font-lock-level 3
+  "*Level of font lock for MATLAB code.
+The \"Standard\" level plus either MLint flycheck or the MATLAB Language
+Server gives all syntactic faces along with error indicators.
+
+The \"Standard plus parse errors\" can result in too much use of the
+`font-lock-warning-face' when there are syntax errors and is thus
+not recommended."
+  :type '(choice (const :tag "Minimal" 1)
+                 (const :tag "Low" 2)
+                 (const :tag "Standard" 3)
+                 (const :tag "Standard plus parse errors" 4)))
+
+(defcustom matlab-ts-mode-on-save-fixes
+  '(matlab-ts-mode-on-save-fix-name)
+  "*List of function symbols which offer to fix *.m files on save.
+During save these functions are called and will prompt to fix issues in
+*.m files.  Each function gets no arguments, and returns nothing.  They
+can move point, but it will be restored for them."
+  :type '(repeat (choice :tag "Function: "
+                         (matlab-ts-mode-on-save-fix-name))))
+
+(defcustom matlab-ts-mode-highlight-comment-markers t
+  "*Highlight triple-x, to-do, and fix-me comment markers?
+See \\[matlab-ts-mode-comment-marker-help]."
+  :type 'boolean)
+
+(defcustom matlab-ts-mode-enable-mlint-flycheck t
+  "*Enable MLint code analyzer via flycheck.
+This requires that you install the flycheck package
+https://www.flycheck.org can be installed by adding
+to your ~/.emacs
+  (require \\='package)
+  (add-to-list \\='package-archives
+               \\='(\"MELPA Stable\" . \"https://stable.melpa.org/packages/\";) 
t)
+Then restart Emacs and run
+  \\[package-install] RET flycheck RET
+You can also install via use-package or other methods."
+  :type 'boolean)
+
+(defcustom matlab-ts-mode-electric-ends t
+  "*If t, insert end keywords to complete statements and insert % for doc 
comments.
+For example, if you type
+   classdef foo<RET>
+an end statement will be inserted resulting in:
+   classdef foo<RET>
+       ^                  <== point here
+   end
+Insertion of end keywords works well when the code is
+indented.  If you are editing code that is not indented,
+you may wish to turn this off.
+
+This will also add \"% \" for documentation comments.  For example,
+   function foo
+   % help for foo<RET>
+   %
+     ^                  <== \"% \" is inserted and point is here
+   end"
+  :type 'boolean)
+
+(defgroup matlab-ts-faces nil
+  "Faces used by `matlab-ts-mode'."
+  :group 'matlab-ts)
+
 (defface matlab-ts-mode-pragma-face
   '((t :inherit font-lock-comment-face
        :bold t))
-  "*Face to use for pragma %# lines.")
+  "*Face to use for comment lines which start with %#.
+These include lines like
+  %#ok          // pragmas used by the MATLAB Code Analyzer, mlint
+  %#function    // pragmas used by the MATLAB Compiler")
 
 (defface matlab-ts-mode-string-delimiter-face
   '((t :inherit font-lock-string-face
@@ -66,7 +133,7 @@
   '((t :inherit font-lock-comment-face
        :overline t
        :bold t))
-  "*Face for \"%% code section\" headings when NOT in 
matlab-sections-minor-mode.")
+  "*Face for \"%% code section\" headings.")
 
 (defface matlab-ts-mode-comment-to-do-marker-face
   '((((class color) (background light))
@@ -117,13 +184,23 @@ Guidelines:
 (defface matlab-ts-mode-end-number-face
   '((t :inherit matlab-ts-mode-number-face
        :slant italic))
-  "*Face used for \"end\" when used as an array or cell dimension number 
index.")
+  "*Face used for \"end\" when used as an array or cell dimension number index.
+For example:
+  mat1 = [1:10;
+          2:2:20];
+  mat2 = mat1(2:end, end:end);")
 
 (defface matlab-function-signature-face
   '((t :inherit font-lock-type-face
        :weight bold
        :slant italic))
-  "*Face used for classdef abstract method function signature declarations.")
+  "*Face used for classdef abstract method function signature declarations.
+In this example, fcn1 will get this face:
+  classdef MyClass
+      methods(Abstract)
+          a = fcn1(obj);
+      end
+  end")
 
 (defface matlab-ts-mode-variable-override-builtin-face
   '((t :inherit font-lock-variable-name-face
@@ -133,64 +210,13 @@ For example, it is valid to override the disp command:
   disp = 1:10;
 and then trying to use disp to display results will not work.")
 
-(defcustom matlab-ts-mode-font-lock-level 3
-  "*Level of font lock for MATLAB code.
-The \"Standard\" level plus either MLint flycheck or the MATLAB Language
-Server gives all syntactic faces along with error indicators.
-
-The \"Standard plus parse errors\" can result in too much use of the
-`font-lock-warning-face' when there are syntax errors."
-  :type '(choice (const :tag "Minimal" 1)
-                 (const :tag "Low" 2)
-                 (const :tag "Standard" 3)
-                 (const :tag "Standard plus parse errors" 4)))
-
-(defcustom matlab-ts-mode-on-save-fixes
-  '(matlab-ts-mode-on-save-fix-name)
-  "*List of function symbols which offer to fix *.m files on save.
-During save these functions are called and will prompt to fix issues in
-*.m files.  Each function gets no arguments, and returns nothing.  They
-can move point, but it will be restored for them."
-  :type '(repeat (choice :tag "Function: "
-                         (matlab-ts-mode-on-save-fix-name))))
-
-(defcustom matlab-ts-mode-highlight-comment-markers t
-  "*Highlight triple-x, to-do, and fix-me comment markers?
-See \\[matlab-ts-mode-comment-marker-help]."
-  :type 'boolean)
-
-(defcustom matlab-ts-mode-enable-mlint-flycheck t
-  "*Enable MLint code analyzer via flycheck.
-This requires that you install the flycheck package
-https://www.flycheck.org can be installed by adding
-to your ~/.emacs
-  (require \\='package)
-  (add-to-list \\='package-archives
-               \\='(\"MELPA Stable\" . \"https://stable.melpa.org/packages/\";) 
t)
-Then restart Emacs and run
-  \\[package-install] RET flycheck RET
-You can also install via use-package or other methods."
-  :type 'boolean)
-
-(defcustom matlab-ts-mode-electric-ends t
-  "*If t, insert end keywords to complete statements and insert % for doc 
comments.
-For example, if you type
-   classdef foo<RET>
-an end statement will be inserted resulting in:
-   classdef foo<RET>
-       ^                  <== point here
-   end
-Insertion of end keywords works well when the code is
-indented.  If you are editing code that is not indented,
-you may wish to turn this off.
-
-This will also add \"% \" for documentation comments.  For example,
-   function foo
-   % help for foo<RET>
-   %
-     ^                  <== \"% \" is inserted and point is here
-   end"
-  :type 'boolean)
+(defface matlab-ts-region-face
+  '((t :inherit region))
+  "*Face used to highlight a region of text when prompting for input.
+For example, if the function name and *.m file name are different
+the function name will be highlighted and you will see prompt
+   Function name and file names are different.  Fix?
+when saving.")
 
 ;;; Global variables used in multiple code ";;; sections"
 
@@ -3242,7 +3268,7 @@ Returns t if tree-sitter NODE defines an outline heading."
         ans)
     (condition-case nil
         (progn
-          (overlay-put mo 'face 'matlab-region-face)
+          (overlay-put mo 'face 'matlab-ts-region-face)
           (setq ans (y-or-n-p prompt))
           (delete-overlay mo))
       (quit (delete-overlay mo)
@@ -3892,6 +3918,170 @@ and this buffer is returned."
         (pop-to-buffer (current-buffer) 'other-window)))
     parse-errors-buf))
 
+(defun matlab-ts--face-section (heading)
+  "Insert stylized section HEADING into current buffer."
+  (insert "\n" (propertize (concat "[" heading "]") 'face 'custom-group-tag) 
"\n"))
+
+(defun matlab-ts--face-button (face sample &optional extra-doc)
+  "Insert FACE doc in current buffer and make it a button.
+SAMPLE is text that is inserted with FACE property.
+EXTRA-DOC is extra doc info to add to the face documentation."
+
+  (let ((face-str (symbol-name face))
+        (face-doc (replace-regexp-in-string (rx bos "*") "" 
(face-documentation face))))
+
+    (insert "\n")
+
+    (insert "* ")
+    (insert-text-button face-str 'action (lambda (_button)
+                                           (customize-face face)))
+    (insert "\n")
+
+    (insert "  " (mapconcat #'identity (split-string face-doc "\n") "\n  "))
+    (insert "\n")
+    (when extra-doc
+      (insert "  " (mapconcat #'identity (split-string extra-doc "\n") "\n  "))
+      (insert "\n"))
+
+    (insert "  Sample:\n")
+    (insert "    " (propertize
+                    (mapconcat #'identity (split-string (string-trim sample) 
"\n") "\n    ")
+                    'face face))
+    (insert "\n")))
+
+(defun matlab-ts-describe-faces ()
+  "Describe the faces used by matlab-ts-mode."
+  (interactive)
+  (with-help-window "*matlab-ts-mode faces*"
+    (with-current-buffer "*matlab-ts-mode faces*"
+      (setq-local revert-buffer-function (lambda (&rest _)))
+
+      (insert "The following faces are used by matlab-ts-mode when displaying 
code.
+A face includes the font, style, color, etc.\n")
+      
+      (matlab-ts--face-section "Comments")
+      (matlab-ts--face-button 'font-lock-doc-face
+                              "% documentation comment for function's and 
classdef's\n")
+      (matlab-ts--face-button 'font-lock-comment-face
+                              "% a single line comment\n")
+      (matlab-ts--face-button 'matlab-ts-mode-pragma-face
+                              (concat "%#ok<*AGROW>\n"
+                                      "%#function myFcn\n"))
+      (matlab-ts--face-button 'matlab-ts-mode-comment-to-do-marker-face
+                              (mapconcat #'identity 
matlab-ts-mode--comment-markers " "))
+
+      (matlab-ts--face-section "Sections")
+      (matlab-ts--face-button 'matlab-ts-mode-comment-heading-face
+                              "%% My Code Section\n")
+      (matlab-ts--face-button 'matlab-sections-highlight-face
+                              "code\n")
+
+      (matlab-ts--face-section "Operators")
+      (matlab-ts--face-button 'matlab-ts-mode-operator-face
+                              "* / + -\n")
+
+      (matlab-ts--face-section "Brackets")
+      (matlab-ts--face-button 'font-lock-bracket-face
+                              "( ) [ ] { }\n")
+      
+      (matlab-ts--face-section "Delimiters")
+      (matlab-ts--face-button 'font-lock-delimiter-face
+                              ". , : ;\n")
+
+      (matlab-ts--face-section "Strings")
+      (matlab-ts--face-button 'font-lock-string-face
+                              "string")
+      (matlab-ts--face-button 'matlab-ts-mode-string-delimiter-face
+                              "\" \\'")
+      (matlab-ts--face-button 'font-lock-escape-face
+                              "\\n \\t %d %f %g\n"
+                              (concat "This includes escape sequences (\\n, 
etc.) and fprintf "
+                                      "format specs (%d, etc.) within 
strings."))
+
+      (matlab-ts--face-section "Functions")
+      (matlab-ts--face-button 'font-lock-function-name-face
+                              "myFunction"
+                              (concat "Face used in function definitions.\n"
+                                      "For example myFunction will get this 
face:\n"
+                                      "    function out1 = myFunction(in1)\n"
+                                      "        out1 = in1 * 2;\n"
+                                      "    end\n"))
+      (matlab-ts--face-button 'font-lock-function-call-face
+                              "myFunction"
+                              (concat "\n"
+                                      "For example myFunction will get this 
face:\n"
+                                      "    x = myFunction(4);\n"
+                                      "This is used for both functions and 
matrices because\n"
+                                      "id1(2) can refer to either a function 
named id1 or\n"
+                                      "a matrix named id1.\n"))
+      (matlab-ts--face-button 'matlab-function-signature-face
+                              "fcn1")
+
+      (matlab-ts--face-section "Command Dual")
+      (matlab-ts--face-button 'matlab-ts-mode-command-arg-face
+                              "argument")
+
+      (matlab-ts--face-section "System Command")
+      (matlab-ts--face-button 'matlab-ts-mode-system-command-face
+                              "! ls *.m *.txt")
+
+      (matlab-ts--face-section "Builtins")
+      
+      (matlab-ts--face-button 'font-lock-builtin-face
+                              "disp"
+                              (concat "This includes any builtin identifier, 
function, etc.\n"
+                                      "provided by MATLAB and add-on 
products"))
+
+      (matlab-ts--face-section "Classdef")
+      (matlab-ts--face-button 'matlab-ts-mode-property-face
+                              "prop1")
+
+      (matlab-ts--face-section "Variables")
+      (matlab-ts--face-button 'matlab-ts-mode-variable-override-builtin-face
+                              "disp")
+
+      (matlab-ts--face-button 'font-lock-variable-name-face
+                              "var1"
+                              (concat "Face used in variable assignment, 
function inputs, and "
+                                      "function outputs\n"
+                                      "Example: this face will be used on var1 
in: var1 = 1;\n"
+                                      "Example: this face will be used on in1 
and out1 in: "
+                                      " function out1 = fcnName(in1)"))
+
+      (matlab-ts--face-section "Keywords")
+      (matlab-ts--face-button 'font-lock-keyword-face
+                              "if else elseif end")
+       
+      (matlab-ts--face-section "Code")
+      (matlab-ts--face-button 'default
+                              "sample"
+                              (concat "Face used in code\n"
+                                      "Example: this face will be used on 
thing1 and thing2 in: "
+                                      "x = thing1 + thing2;\n"
+                                      "where thing1 or thing2 can be variables 
or functions"))
+
+      (matlab-ts--face-section "Type Functions")
+      (matlab-ts--face-button 'font-lock-type-face
+                              "int8 int16")
+                               
+      (matlab-ts--face-section "Numbers")
+      (matlab-ts--face-button 'matlab-ts-mode-number-face
+                              "1234")
+      (matlab-ts--face-button 'matlab-ts-mode-end-number-face
+                              "end")
+
+      (matlab-ts--face-section "Prompting")
+      (matlab-ts--face-button 'matlab-ts-region-face
+                              "myFunction")
+
+      (matlab-ts--face-section "Syntax Errors")
+      (matlab-ts--face-button 'font-lock-warning-face
+                              "a*/*b"
+                              (concat "Used when 
`matlab-ts-mode-font-lock-level' is set to "
+                                      "show syntax errors"))
+      
+      )))
+
 ;;; Our M-q matlab-ts-mode-prog-fill-reindent-defun
 
 (defun matlab-ts-mode-prog-fill-reindent-defun (&optional justify)
@@ -4109,6 +4299,8 @@ See `comment-dwim' for more capabilities."]
 
     "----"
     ["Check setup" matlab-ts-mode-check-setup]
+    ["Describe faces" matlab-ts-describe-faces
+     :help "Describe faces (color, font, etc.) used by matlab-ts-mode."]
     ("Customize"
      ["Customize matlab-ts-mode" (lambda ()
                                    (interactive)
@@ -4364,4 +4556,4 @@ matlab-language-server-lsp-mode.org\n"
 ;; LocalWords:  funcall mfile elec foo'bar mapcar lsp noerror alnum featurep 
grep'ing mapconcat wie
 ;; LocalWords:  Keymap keymap netshell gud ebstop mlgud ebclear ebstatus mlg 
mlgud's subjob reindent
 ;; LocalWords:  DWIM dwim parens caar cdar utils fooenum mcode CRLF cmddual 
lang nconc listify kbd
-;; LocalWords:  matlabls vscode buf dolist sp ppss bobp sexps
+;; LocalWords:  matlabls vscode buf dolist sp ppss bobp sexps pragmas
diff --git a/matlab.el b/matlab.el
index 3c391e906b..79a369f1b4 100644
--- a/matlab.el
+++ b/matlab.el
@@ -1,6 +1,6 @@
 ;;; matlab.el --- major mode for MATLAB(R) dot-m files -*- lexical-binding: t 
-*-
 
-;; Version: 7.3.4
+;; Version: 7.4.0
 ;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 
diff --git a/tests/test-matlab-ts-describe-faces.el 
b/tests/test-matlab-ts-describe-faces.el
new file mode 100644
index 0000000000..bf38a7e0cd
--- /dev/null
+++ b/tests/test-matlab-ts-describe-faces.el
@@ -0,0 +1,98 @@
+;;; test-matlab-ts-describe-faces.el --- -*- lexical-binding: t -*-
+
+;; Copyright (C) 2025 Free Software Foundation, Inc.
+;;
+;; This file 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 of the License,
+;; or (at your option) any later version.
+;;
+;; This file 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 this file.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
+;;; Code:
+
+(require 'subr-x)
+
+(require 't-utils)
+
+(ert-deftest test-matlab-ts-describe-faces ()
+  "Verify `matlab-ts-describe-face' has all faces used by matlab-ts-mode.el.
+The faces used in maltab-ts-mode.el and matlab-sections.el must be described in
+`matlab-ts-describe-face'."
+
+  (let* ((me (symbol-file 'test-matlab-ts-describe-faces))
+         (my-dir (file-name-directory me))
+         (proj-root-dir (file-name-directory (directory-file-name my-dir)))
+         (matlab-ts-mode-el (concat proj-root-dir "matlab-ts-mode.el"))
+         (matlab-sections-el (concat proj-root-dir "matlab-sections.el"))
+         (errors '()))
+    (with-temp-buffer
+      (insert-file-contents-literally matlab-ts-mode-el)
+      (insert-file-contents-literally matlab-sections-el)
+
+      (let ((face-re "\\([-a-z]+[a-z]-face\\)")
+            (described-faces-ht (make-hash-table :test 'equal))
+            (used-faces-ht (make-hash-table :test 'equal)))
+
+        ;; Populate described-faces-ht with string key FACE and value t for 
all faces mentioned in
+        ;;    (defun matlab-ts-describe-faces ()
+        ;;     ...
+        ;;    )
+        ;; then delete the function from the temp buffer
+        (goto-char (point-min))
+        (re-search-forward "^(defun matlab-ts-describe-faces ()")
+        (beginning-of-line)
+        (let* ((start-pt (point))
+               (end-pt (save-excursion
+                         (forward-sexp)
+                         (point))))
+          (while (re-search-forward face-re end-pt t)
+            (let ((face (match-string 1)))
+              (puthash face t described-faces-ht)))
+          (delete-region start-pt end-pt))
+
+        ;; Eliminate all the (defface ...) statements because these can 
reference other faces
+        (goto-char (point-min))
+        (while (re-search-forward "^(defface " nil t)
+          (beginning-of-line)
+          (let* ((start-pt (point))
+                 (end-pt (save-excursion
+                           (forward-sexp)
+                           (point))))
+            (delete-region start-pt end-pt)))
+        
+        ;; Populate used-faces-ht with string key FACE and value t for all 
faces mentioned elsewhere
+        ;; in matlab-ts-mode.el and matlab-sections.el (the content of the 
current temp buffer)
+        (goto-char (point-min))
+        (while (re-search-forward face-re nil t)
+          (let ((face (match-string 1)))
+            (when (not (string= face "customize-face"))
+              (puthash face t used-faces-ht))))
+
+        (let ((errors '()))
+          
+          (dolist (face (hash-table-keys used-faces-ht))
+            (when (not (gethash face described-faces-ht))
+              (push (concat face " is not described in 
matlab-ts-describe-faces")
+                    errors)))
+
+          (dolist (described-face (hash-table-keys described-faces-ht))
+            (when (not (gethash described-face used-faces-ht))
+              (push (concat described-face " is described in 
matlab-ts-describe-faces but not used")
+                    errors)))
+        
+          )))
+    (should (eq errors '()))))
+
+
+(provide 'test-matlab-ts-describe-faces)
+;;; test-matlab-ts-describe-faces.el ends here

Reply via email to