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

    matlab-ts-mode: add debugger, update menu
---
 matlab--shared.el       | 20 ++++++++++++++++++++
 matlab--shell-bridge.el |  9 +++++++++
 matlab-shell-gud.el     | 14 ++++++++++----
 matlab-shell.el         |  2 +-
 matlab-topic.el         |  2 +-
 matlab-ts-mode.el       | 41 ++++++++++++++++++++++-------------------
 matlab.el               | 21 +--------------------
 toolbox/ebclear.m       |  5 +++--
 8 files changed, 67 insertions(+), 47 deletions(-)

diff --git a/matlab--shared.el b/matlab--shared.el
index 31ed61231a..aa93065e65 100644
--- a/matlab--shared.el
+++ b/matlab--shared.el
@@ -23,5 +23,25 @@
     (delete-horizontal-space)
     (justify-current-line)))
 
+;; Support debug mode and read only toggling.
+(defvar gud-matlab-debug-active nil)
+(declare-function matlab-shell-gud-minor-mode "matlab-shell-gud")
+
+(defun matlab-toggle-read-only (&optional arg)
+  "Toggle read-only bit in MATLAB mode.
+This looks to see if we are currently debugging, and if so re-enable our
+debugging feature.  Optional argument ARG is ignored.  ARG is present
+because we are replacing `read-only-mode' key defintion with this
+function."
+
+  (interactive "P")
+  (ignore arg)
+  (if (and (featurep 'matlab-shell-gud)
+           gud-matlab-debug-active)
+      ;; The debugging is active, just re-enable debugging read-only-mode
+      (matlab-shell-gud-minor-mode 1)
+    ;; Else - it is not - probably doing something else.
+    (call-interactively 'read-only-mode)))
+
 (provide 'matlab--shared)
 ;;; matlab--shared.el ends here
diff --git a/matlab--shell-bridge.el b/matlab--shell-bridge.el
index f993408c30..8e27d8363e 100644
--- a/matlab--shell-bridge.el
+++ b/matlab--shell-bridge.el
@@ -34,6 +34,15 @@ to strings and comments."
       matlab-ts-mode--syntax-table
     matlab-mode-syntax-table))
 
+(defvar matlab-ts-mode-map)
+(defvar matlab-mode-map)
+
+(defun matlab--get-matlab-map ()
+  "Return either `matlab-mode-map' or `matlab-ts-mode-map'."
+  (if (matlab--is-matlab-ts-mode-active)
+      matlab-ts-mode-map
+    matlab-mode-map))
+
 (declare-function matlab-scan-beginning-of-command "matlab-mode")
 (declare-function matlab-scan-end-of-command "matlab-mode")
 
diff --git a/matlab-shell-gud.el b/matlab-shell-gud.el
index 85265b1d24..4289914bad 100644
--- a/matlab-shell-gud.el
+++ b/matlab-shell-gud.el
@@ -25,6 +25,7 @@
 ;; to supporting mlgud.
 
 (require 'matlab-shell)
+(require 'matlab--shell-bridge)
 
 (eval-and-compile
   (require 'mlgud)
@@ -91,7 +92,8 @@ Disable this option if the tooltips are too slow in your 
setup."
   (when window-system
 
     (setq gud-matlab-tool-bar-map
-          (let ((map (make-sparse-keymap)))
+          (let ((map (make-sparse-keymap))
+                (matlab-map (matlab--get-matlab-map)))
             (dolist (x '((mlgud-break . "gud/break")
                          (mlgud-remove . "gud/remove")
                          (mlgud-cont . "gud/cont")
@@ -103,7 +105,7 @@ Disable this option if the tooltips are too slow in your 
setup."
                          (mlgud-list-breakpoints . "describe")
                          ))
               (tool-bar-local-item-from-menu
-               (car x) (cdr x) map matlab-mode-map))
+               (car x) (cdr x) map matlab-map))
             map))
 
     )
@@ -124,6 +126,7 @@ Disable this option if the tooltips are too slow in your 
setup."
   (setq mlgud-minor-mode 'matlab)
 
   ;; This starts us supporting mlgud tooltips.
+  (add-to-list 'mlgud-tooltip-modes 'matlab-ts-mode)
   (add-to-list 'mlgud-tooltip-modes 'matlab-mode)
 
   (make-local-variable 'mlgud-marker-filter)
@@ -608,6 +611,7 @@ LONGESTNAME specifies the how long the longest name we can 
expect is."
       ))
   ;; The first time breakpoints are added, make sure we can activate 
breakpoints
   ;; when new files are opened in a buffer.
+  (add-hook 'matlab-ts-mode-hook 'mlg-breakpoint-activate-buffer-opened-hook)
   (add-hook 'matlab-mode-hook 'mlg-breakpoint-activate-buffer-opened-hook)
   )
 
@@ -964,7 +968,8 @@ Debug commands are:
 
 (defun matlab-shell-gud-minor-mode-activator ()
   "Activate gud in matlab-shell when in MATLAB mode."
-  (when (eq major-mode 'matlab-mode)
+  (when (or (eq major-mode 'matlab-ts-mode)
+            (eq major-mode 'matlab-mode))
     (matlab-shell-gud-minor-mode 1)))
 
 ;;;###autoload
@@ -1024,7 +1029,8 @@ Debug commands are:
 
 (defun matlab-shell-gud-minor-mode-deactivator ()
   "Deactivate gud in matlab-shell when in MATLAB mode."
-  (when (eq major-mode 'matlab-mode)
+  (when (or (eq major-mode 'matlab-ts-mode)
+            (eq major-mode 'matlab-mode))
     (matlab-shell-inactive-gud-minor-mode 1)))
 
 ;;;###autoload
diff --git a/matlab-shell.el b/matlab-shell.el
index e5a2324e21..bf2355e92d 100644
--- a/matlab-shell.el
+++ b/matlab-shell.el
@@ -30,7 +30,7 @@
 (eval-and-compile
   (require 'matlab--access))
 (require 'matlab--shell-bridge)
-(require 'matlab--shell-map)
+(require 'matlab--shared)
 
 ;; Note this should *NOT*
 ;;   (require 'matlab) ;; or (require 'matlab-mode)
diff --git a/matlab-topic.el b/matlab-topic.el
index 66db975835..3f186a2735 100644
--- a/matlab-topic.el
+++ b/matlab-topic.el
@@ -24,7 +24,7 @@
 
 ;;; Code:
 (require 'matlab)
-(require 'matlab--shell-map)
+(require 'matlab--shared)
 (require 'matlab-shell)
 (require 'view)
 
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 0b4b5e9d1b..2bc5128b8a 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -2142,22 +2142,7 @@ Within comments, the following markers will be 
highlighted:
   "C-c ?" 'matlab-shell-locate-fcn
   "C-h C-m" matlab--shell-help-map
   "M-s" 'matlab-show-matlab-shell-buffer
-  "C-M-<mouse-2>" 'matlab-find-file-click
-
-  ;; TODO test ebbreak, ebclear, etc. and all menu items related to debugging
-  ;;    ebstop in /home/ciolfi/tmp/foo.m at 13%%
-  ;;    ebclear in /home/ciolfi/tmp/foo.m at 13%%
-  ;;    Error using dbclear
-  ;;    Argument must be a text scalar.
-  ;;
-  ;;    Error in ebclear (line 21)
-  ;;        dbclear(args);
-  ;;        ^^^^^^^^^^^^^
-
-  ;; ;; Debugger interconnect
-  ;; (substitute-key-definition 'read-only-mode 'matlab-toggle-read-only km 
global-map)
-
-  )
+  "C-M-<mouse-2>" 'matlab-find-file-click)
 
 ;;; Menu
 
@@ -2296,10 +2281,20 @@ mark at the beginning of the \"%% section\" and point 
at the end of the section"
     ["Comment marker help" matlab-ts-mode-comment-marker-help]
     "----"
     ("Format"
-     ["Fill comment / string / reindent function" prog-fill-reindent-defun]
+     ["Fill comment / string / indent function" prog-fill-reindent-defun]
+     ["Indent region" indent-region
+      :help "Indent active region"]
      ["Justify line" matlab-justify-line]
-     ["Comment DWIM" comment-dwim]
-     ["Comment/uncomment region" comment-or-uncomment-region])
+     ["Comment DWIM" comment-dwim
+      :help "Comment Do What I Mean
+If region is active comment or uncomment it,
+Else insert comment if line is empty,
+Else call comemnt-indent.
+See `comment-dwim' for more capabilties."]
+     ["Comment/uncomment current line " comment-line
+      :help "Comment or uncomment current line and leave point after it."]
+     ["Set comment column to point" comment-set-column
+      :help "Set the column for when M-; inserts a column"])
 
     "----"
     ("Customize"
@@ -2485,6 +2480,9 @@ is t, add the following to an Init File (e.g. 
`user-init-file' or
     ;;
     ;; TODO org mode matlab-ts-mode blocks testing
     ;;
+    ;; TODO matlab.el, matlab-is-matlab-file - handle matlab-ts-mode
+    ;;
+    ;; TODO matlab-shell-mode: update help to have matlab-ts-mode or 
matlab-mode
     
     (treesit-major-mode-setup)
 
@@ -2493,6 +2491,11 @@ is t, add the following to an Init File (e.g. 
`user-init-file' or
     ;; for our tests work. We need to evaluate (t-utils-NAME ....) expressions 
from within comments
     ;; using C-x C-e and this leverages forward-sexp to match up the 
parentheses.
     (setq-local forward-sexp-function #'matlab-ts-mode--forward-sexp)
+
+    ;; M-x matlab-shell Debugger interconnect
+    (let ((km (current-local-map)))
+      (substitute-key-definition 'read-only-mode #'matlab-toggle-read-only km 
global-map))
+
     ))
 
 (provide 'matlab-ts-mode)
diff --git a/matlab.el b/matlab.el
index 2c1daeaf76..9e19ad635c 100644
--- a/matlab.el
+++ b/matlab.el
@@ -1277,6 +1277,7 @@ This will also enter `matlab-mode' for empty files *.m 
files when
                             enter-matlab-mode)
                         (while buffers
                           (with-current-buffer (car buffers)
+                            ;; TODO - handle matlab-ts-mode
                             (when (or (eq major-mode 'matlab-mode)
                                       (eq major-mode 'matlab-shell-mode))
                               (setq enter-matlab-mode t)
@@ -1479,26 +1480,6 @@ All Key Bindings:
         ;; continue.
         (error nil))))
 
-
-;; Support debug mode and read only toggling.
-(defvar gud-matlab-debug-active nil)
-(declare-function matlab-shell-gud-minor-mode "matlab-shell-gud")
-
-(defun matlab-toggle-read-only (&optional arg)
-  "Toggle read-only bit in MATLAB mode.
-This looks to see if we are currently debugging, and if so re-enable
-our debugging feature.
-Optional argument ARG specifies if the read-only mode should be set."
-  (interactive "P")
-  (ignore arg)
-  (if (and (featurep 'matlab-shell-gud)
-           gud-matlab-debug-active)
-      ;; The debugging is active, just re-enable debugging read-only-mode
-      (matlab-shell-gud-minor-mode 1)
-    ;; Else - it is not - probably doing something else.
-    (call-interactively 'read-only-mode)
-    ))
-
 
 ;;; Utilities =================================================================
 
diff --git a/toolbox/ebclear.m b/toolbox/ebclear.m
index 9841249f25..b77eaa8007 100644
--- a/toolbox/ebclear.m
+++ b/toolbox/ebclear.m
@@ -14,11 +14,12 @@
 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 function ebclear(varargin)
-% Emacs version of dbstop.  Tells emacs which breakpoints are active.
+% Emacs version of dbclear.
+% Removes a breakpoint and tells Emacs about that.
 
     args = emacsstripremote(varargin);
 
-    dbclear(args);
+    dbclear(args{:});
 
     % Send emacs some breakpoints
     bp = getappdata(groot, 'EmacsBreakpoints');

Reply via email to