branch: externals/matlab-mode
commit 8193e3d7ecc6311ccf4610752e6892b7a1737510
Merge: 899ae3c36f 3fac6eb00a
Author: John Ciolfi <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #63 from mathworks/matlab-ts-mode
matlab-mode-7.3.3
---
NEWS.org | 5 +
matlab-mode.el | 2 +-
.../matlab-ts-abi14-20251122-90ce9da/README.org | 10 ++
.../glnxa64/libtree-sitter-matlab.so | Bin 0 -> 436112 bytes
.../maca64/libtree-sitter-matlab.dylib | Bin 0 -> 432536 bytes
.../maci64/libtree-sitter-matlab.dylib | Bin 0 -> 428544 bytes
.../win64/libtree-sitter-matlab.dll | Bin 0 -> 531456 bytes
matlab-ts-grammar-install.el | 146 ++++++++-------------
matlab-ts-mode.el | 10 +-
matlab.el | 2 +-
tests/t-utils.el | 2 +-
11 files changed, 80 insertions(+), 97 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 08893ef018..69a6040766 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -3,6 +3,11 @@
# Copyright (C) 2025 Free Software Foundation, Inc.
+* Release 7.3.3 Nov 23, 2025
+
+1. Update to latest https://github.com/acristoffers/tree-sitter-matlab which
improves
+ matlab-ts-mode: matlab-ts-abi14-20251122-90ce9da
+
* Release 7.3.2 Nov 21, 2025
1. Update to latest https://github.com/acristoffers/tree-sitter-matlab which
improves
diff --git a/matlab-mode.el b/matlab-mode.el
index 5bf4d802a1..4676290714 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.2
+;; Version: 7.3.3
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/README.org
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/README.org
new file mode 100644
index 0000000000..d90057967f
--- /dev/null
+++ b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/README.org
@@ -0,0 +1,10 @@
+# File: matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/README.org
+
+This corresponds to commit
[[https://github.com/acristoffers/tree-sitter-matlab/commit/90ce9daffd5bc1525469f79f36342155ea82795a][90ce9da]]
on the abi/14 branch of
+https://github.com/acristoffers/tree-sitter-matlab
+
+-
matlab-ts-abi14-20251122-90ce9da/glnxa64/libtree-sitter-matlab.so/libtree-sitter-matlab.so
was created on deb11-64
+-
matlab-ts-abi14-20251122-90ce9da/maca64/libtree-sitter-matlab.dylib/libtree-sitter-matlab.dylib
was created on maca13-64
+-
matlab-ts-abi14-20251122-90ce9da/maci64/libtree-sitter-matlab.dylib/libtree-sitter-matlab.dylib
was created on maci14-64
+-
matlab-ts-abi14-20251122-90ce9da/win64/libtree-sitter-matlab.dll/libtree-sitter-matlab.dll
was created on win64
+
diff --git
a/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/glnxa64/libtree-sitter-matlab.so
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/glnxa64/libtree-sitter-matlab.so
new file mode 100644
index 0000000000..2cbb765dab
Binary files /dev/null and
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/glnxa64/libtree-sitter-matlab.so
differ
diff --git
a/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maca64/libtree-sitter-matlab.dylib
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maca64/libtree-sitter-matlab.dylib
new file mode 100644
index 0000000000..83d2d77b52
Binary files /dev/null and
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maca64/libtree-sitter-matlab.dylib
differ
diff --git
a/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maci64/libtree-sitter-matlab.dylib
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maci64/libtree-sitter-matlab.dylib
new file mode 100644
index 0000000000..7d3d51fc80
Binary files /dev/null and
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/maci64/libtree-sitter-matlab.dylib
differ
diff --git
a/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/win64/libtree-sitter-matlab.dll
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/win64/libtree-sitter-matlab.dll
new file mode 100644
index 0000000000..a8e25a209b
Binary files /dev/null and
b/matlab-ts-bin/matlab-ts-abi14-20251122-90ce9da/win64/libtree-sitter-matlab.dll
differ
diff --git a/matlab-ts-grammar-install.el b/matlab-ts-grammar-install.el
index 3fab5de676..c73d99bf5b 100644
--- a/matlab-ts-grammar-install.el
+++ b/matlab-ts-grammar-install.el
@@ -28,6 +28,52 @@
(require 'org-src)
(require 'url)
+(defvar matlab--ts-grammar-release "matlab-ts-abi14-20251122-90ce9da")
+
+(defun matlab--ts-grammar-check-version ()
+ "Validate Emacs and grammar version are okay, error if not."
+ (when (< emacs-major-version 30)
+ (user-error "Unsupported Emacs version, %d" emacs-major-version))
+
+ (let ((ts-abi-ver (treesit-library-abi-version))
+ (release-abi-ver (if (string-match "\\`matlab-ts-abi\\([0-9]+\\)-"
+ matlab--ts-grammar-release)
+ (string-to-number (match-string 1
matlab--ts-grammar-release))
+ (error "Unexpected matlab--ts-grammar-release %s"
+ matlab--ts-grammar-release))))
+ (when (not (= ts-abi-ver release-abi-ver))
+ (user-error "Emacs treesit-library-abi-version is %d and the matlab-ts
grammar version "
+ "is %d, which indicates a new build is required for
matlab-ts"))))
+
+(defun matlab--ts-get-grammar-branch-and-install-dir (prompt)
+ "Get branch and tree-sitter install directory.
+When PROMPT, prompt for these."
+
+ (let* ((branch-default "default")
+ (branch (if prompt
+ (let ((ans ""))
+ (while (string= ans "")
+ (setq ans (string-trim (read-string "Branch: "
branch-default))))
+ ans)
+ branch-default))
+ (dir-default (concat user-emacs-directory "tree-sitter/"))
+ (dir (if prompt
+ (let ((ans ""))
+ (while (string= ans "")
+ (setq ans (read-directory-name "Download directory: "
dir-default)))
+ ans)
+ dir-default)))
+
+ (if (string= dir dir-default)
+ (when (not (file-directory-p dir))
+ (make-directory dir t))
+ (when (not (file-directory-p dir))
+ (user-error "%s is not an existing directory" dir)))
+
+ (setq dir (file-name-as-directory (file-truename dir)))
+
+ (cons branch dir)))
+
(defun matlab--ts-grammar-arch-and-shared-lib ()
"Return ARCH/libtree-sitter-matlab.SLIB_EXT.
ARCH is the same as the MATLAB computer('arch') command result."
@@ -46,62 +92,6 @@ ARCH is the same as the MATLAB computer('arch') command
result."
system-configuration))
result))
-(defun matlab--ts-grammar-download-url (branch prompt-for-version)
- "Get the download tree-sitter-matlab URL for BRANCH.
-When PROMPT-FOR-VERSION is non-nil, prompt for the version to download."
-
- ;; Use GitHub REST API to get the download URL
- (let* ((bin-url (concat
"https://api.github.com/repos/mathworks/Emacs-MATLAB-mode/contents/"
- "matlab-ts-bin?ref=" branch))
- (raw-url-start (concat
"https://raw.githubusercontent.com/mathworks/Emacs-MATLAB-Mode/"
- branch "/matlab-ts-bin"))
-
- (bin-buf (url-retrieve-synchronously bin-url))
- (versions '())
- latest-ver-date-num
- latest-ver
- download-url)
-
- (with-current-buffer bin-buf
- (let* ((response-content
- (let ((result (buffer-string)))
- (goto-char (point-min))
- (if (re-search-forward "^\\(HTTP/[0-9.]* \\([0-9]+\\) .*\\)$"
nil t)
- (let ((response (match-string 1))
- (response-code (match-string 2)))
- (when (not (string= response-code "200"))
- (user-error "Invalid response \"%s\" received from %s"
- response bin-url)))
- (user-error "Unexpected result from %s: %s" bin-url result))
- (cadr (split-string result "\n\n" t))))
- (entries (json-read-from-string response-content)))
- (cl-loop for entry across entries do
- (let ((rel-file (alist-get 'path entry))) ;;
matlab-ts-bin/FILE
- ;; Have YYYYMMDD-SHA1
- (when (string-match
"^matlab-ts-bin/\\(\\([0-9]+\\)-[0-9a-z]+\\)$" rel-file)
- (let ((ver (match-string 1 rel-file))
- (date-num (string-to-number (match-string 2
rel-file))))
- (when (or (not latest-ver)
- (> date-num latest-ver-date-num))
- (setq latest-ver ver
- latest-ver-date-num date-num))
- (push ver versions)))))))
-
- (when (not latest-ver)
- (user-error "Failed to get release versions from %s" bin-url))
-
- (let ((ver-to-download (if prompt-for-version
- (completing-read (concat
- "Version to download ("
latest-ver " is latest): ")
- versions nil t latest-ver)
- latest-ver))
- (arch-slib (matlab--ts-grammar-arch-and-shared-lib)))
-
- (setq download-url (concat raw-url-start "/" ver-to-download "/"
arch-slib)))
-
- (kill-buffer bin-buf)
- download-url))
-
(defun matlab--files-equal-p (file1 file2)
"Return t if the contents of FILE1 and FILE2 are identical, nil otherwise."
(let ((content1 (with-temp-buffer
@@ -163,9 +153,6 @@ With prefix ARG, prompt for
- BRANCH in https://github.com/mathworks/Emacs-MATLAB-Mode. This defaults
to the \"default\" branch.
- - VERSION of the shared library to download. This defaults to the latest
- version.
-
When libtree-sitter-matlab.SLIB-EXT already exists on your system,
- If it is up-to-date, it will not be touched and a message is displayed
@@ -176,35 +163,16 @@ When libtree-sitter-matlab.SLIB-EXT already exists on
your system,
(interactive "P")
- (when (< emacs-major-version 30)
- (user-error "Unsupported Emacs version, %d" emacs-major-version))
-
- (let* ((branch-default "default")
- (branch (if arg
- (let ((ans ""))
- (while (string= ans "")
- (setq ans (string-trim (read-string "Branch: "
branch-default))))
- ans)
- branch-default))
- (dir-default (concat user-emacs-directory "tree-sitter/"))
- (dir (if arg
- (let ((ans ""))
- (while (string= ans "")
- (setq ans (read-directory-name "Download directory: "
dir-default)))
- ans)
- dir-default)))
-
- (if (string= dir dir-default)
- (when (not (file-directory-p dir))
- (make-directory dir t))
- (when (not (file-directory-p dir))
- (user-error "%s is not an existing directory" dir)))
+ (matlab--ts-grammar-check-version)
- (setq dir (file-name-as-directory (file-truename dir)))
+ (let* ((branch-and-dir (matlab--ts-get-grammar-branch-and-install-dir arg))
+ (branch (car branch-and-dir))
+ (dir (cdr branch-and-dir)))
- (let* ((download-url (matlab--ts-grammar-download-url branch arg))
- (grammar-slib-base (file-name-nondirectory download-url))
- (grammar-slib (concat dir grammar-slib-base))
+ (let* ((download-url (concat
"https://raw.githubusercontent.com/mathworks/Emacs-MATLAB-Mode/"
+ branch "/matlab-ts-bin/"
matlab--ts-grammar-release "/"
+ (matlab--ts-grammar-arch-and-shared-lib)))
+ (grammar-slib (concat dir (file-name-nondirectory download-url)))
(grammar-slib-tmp (concat grammar-slib ".tmp")))
(when (y-or-n-p (format "Download %s\nto %s? " download-url
grammar-slib))
@@ -239,8 +207,8 @@ Try exiting Emacs and re-running the install before loading
any *.m files"
(message "Downloaded %s" grammar-slib))
('downloaded-and-updated
(let ((prompt (concat "Downloaded and updated " grammar-slib
"\n"
- "If the older " grammar-slib-base
- " was in use, Emacs must be restarted.\n"
+ "If an older grammar library was in use, "
+ "Emacs must be restarted.\n"
"Exit Emacs? ")))
(when (y-or-n-p prompt)
(save-buffers-kill-terminal))))
@@ -251,4 +219,4 @@ Try exiting Emacs and re-running the install before loading
any *.m files"
;;; matlab-ts-grammar-install.el ends here
;; LocalWords: libtree dylib defun SLIB pcase darwin aarch maca linux nt buf
cadr alist YYYYMMDD
-;; LocalWords: SHA setq slib truename nondirectory tmp delq lang repeat:nil
+;; LocalWords: SHA setq slib truename nondirectory tmp delq lang repeat:nil
abi ce da treesit cdr
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 5006ad563a..bb321d36d1 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.2
+;; Version: 7.3.3
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2248,7 +2248,7 @@ Example:
"Return the offset computed by
`matlab-ts-mode--i-comment-under-fcn-matcher'."
(cdr matlab-ts-mode--i-comment-under-fcn-pair))
-(defun maltab-ts-mode--i-top-level (node parent _bol &rest _)
+(defun matlab-ts-mode--i-top-level (node parent _bol &rest _)
"Is NODE with PARENT a top-level classdef, function, or code?"
(and node
(not (string-match-p (rx bos (or "line_continuation" "\n") eos)
@@ -2257,7 +2257,7 @@ Example:
(defun matlab-ts-mode--column-0 (_node _parent bol &rest _)
"Return column-0 for BOL.
-Note treesit column-0 moves point, fixed in Fmacs 31."
+Note treesit column-0 moves point, fixed in Emacs 31."
(save-excursion
(goto-char bol)
(line-beginning-position)))
@@ -2453,7 +2453,7 @@ Example:
,#'matlab-ts-mode--i-comment-under-fcn-offset)
;; I-Rule: classdef's, function's, or code for a script that is at the
top-level
- (,#'maltab-ts-mode--i-top-level
+ (,#'matlab-ts-mode--i-top-level
,#'matlab-ts-mode--column-0
0)
@@ -4364,4 +4364,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
+;; LocalWords: matlabls vscode buf dolist sp ppss bobp sexps
diff --git a/matlab.el b/matlab.el
index 5e18d98240..a8727e272f 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.2
+;; Version: 7.3.3
;; URL: https://github.com/mathworks/Emacs-MATLAB-Mode
;; SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/tests/t-utils.el b/tests/t-utils.el
index c74201c14d..818929b15f 100644
--- a/tests/t-utils.el
+++ b/tests/t-utils.el
@@ -3199,4 +3199,4 @@ To debug a specific -parser test file
;; LocalWords: consp listp cdr CRLF impl tmp xr boundp SPC kbd prin progn
defmacro sexp stdlib locs
;; LocalWords: showall repeat:nil kkk fff Dkkkk kkkkkk mapcar eobp trim'd bol
NPS prev puthash md
;; LocalWords: maphash lessp gethash nbutlast mapconcat ppss imenu pcase eow
NAME's darwin libtree
-;; LocalWords: defface fontify keymap
+;; LocalWords: defface fontify keymap curr