Hello,
I like to mimic the behavior of f9 when I am editing an .m file.  So 
when I hit f9, I want the line to be sent to matlab and then I want to 
go to the next line in the buffer.   I believe matlab.el does not 
currently have a function that supports this behavior.  To get part of 
this behavior I created the following lisp function which I would bind to f9
(defun my-matlab-shell-run-region ()
"Runs shell command"
;(implement-debug-on-entry)
(interactive)
(setq mybuf (buffer-name))
(matlab-shell-run-region-or-line)
(switch-to-buffer mybuf)
(next-line)
)
This works great until I step across a region of code that matlab.el 
recognizes as a block.  If I press f9 once entering this block, 
matlab-run-region issues an error about the shell being busy.  Then I 
have to copy and paste the rest of the block manually.  I would rather 
have the option that the code be sent to matlab and a warning issued.  
Octave-mode already has this feature, without the warning. Below is the 
modification I made to matlab-shell-run-region.
--- a/matlab.el
+++ b/matlab.el
@@ -5212,15 +5212,19 @@ This command requires an active MATLAB shell."
         (setq msbn (matlab-shell-buffer-barf-not-running))
         (set-buffer msbn)
         (if (not (matlab-on-prompt-p))
-           (error "MATLAB shell must be non-busy to do that"))
-       ;; Save the old command
-       (beginning-of-line)
-       (re-search-forward comint-prompt-regexp)
-       (setq lastcmd (buffer-substring (point) (matlab-point-at-eol)))
-       (delete-region (point) (matlab-point-at-eol))
-       ;; We are done error checking, run the command.
-       (matlab-shell-send-string command)
-       (insert lastcmd))
+           (progn
+             (matlab-shell-send-string command)
+             (message "Continue Entering Statement"))
+         (progn
+           ;; Save the old command
+           (beginning-of-line)
+           (re-search-forward comint-prompt-regexp)
+           (setq lastcmd (buffer-substring (point) (matlab-point-at-eol)))
+           (delete-region (point) (matlab-point-at-eol))
+           ;; We are done error checking, run the command.
+           (matlab-shell-send-string command)
+           (insert lastcmd)
+           )))
        (set-buffer msbn)
        (goto-char (point-max))
        (display-buffer msbn nil "visible"))
-- 


------------------------------------------------------------------------------
_______________________________________________
Matlab-emacs-discuss mailing list
Matlab-emacs-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss

Reply via email to