|
From: Uwe B. <ou...@ma...> - 2012-02-13 14:10:21
|
>> On Sun, 12 Feb 2012 17:20:26 +0000, Eric Ludlam <Eri...@ma...> wrote:
Hi Eric,
> Hi Uwe,
It seems an earlier message did not make it to the list.
> I can't run matlab-shell at the moment to help answer the question,
> but I'm confused as to what you are expecting. In your example, of
> the cursor is on line 2, run cell should only run x=8. If your cursor
> is on the line for y=91, it should only run that. I tried the parsing
> bit of matlab-shell-run-cell without executing the code, and it seemed
> to work as expected for me. Are you seeing some other behavior?
Yes but the reason is the behaviour of
matlab-shell-run-region. The issue is the cell line contains
naturally %% and then the current implementation of
matlab-shell-run-region just ignores the lines of that cell.
If I follow the advice as expressed in
the message: Bug in matlab-shell-run-region
,----
| Hello All,
|
| I just bumped into something looking suspiciously like a bug.
|
| symptoms:
| while running matlab-shell-run-region over matlab code including
| comments, all the code followed by the commented line is no executed.
|
| causes:
| In the definition 'matlab-shell-run-region @ matlab.el, while creating
| the 'command binding, there is a 'while loop labeled as ;; HACK FOR
| NOSHOW whose action is to replace '\n' by ',' regardless of the present
| line being or not a comment.
|
| aesthetic considerations:
| I do prefer to see the lines ran in the prompt as they were layered out
| by me in the code file. I can understand some people might wish to
| completely remove those lines from the matlab-shell buffer; that would
| certainly be another effort, different from simply concatenating
| everything in a big one-liner...
|
|
| the cure:
| Just comment the hack code...
|
`----
then the problem which occurs in matlab-shell-run-cell
disappears!
That is the culprit is the
the code
;; HACK FOR NOSHOW
(while (string-match "\n" str)
(setq str (replace-match ", " t t str)))
Which I commented out!
I strongly recommend to modify matlab-shell-run-region and
to remove that code or define a variable
(defvar matlab-shell-run-no-show nil
*Variable which defines whether to replace '\n' by ','
regardless of the present line being or not a comment.)
So matlab-shell-run-region should look like:
(defun matlab-shell-run-region (beg end)
"Run region from BEG to END and display result in MATLAB shell.
This command requires an active MATLAB shell."
(interactive "r")
(if (> beg end) (let (mid) (setq mid beg beg end end mid)))
(let ((command (let ((str (concat (buffer-substring-no-properties beg end)
"\n")))
(while (string-match "\n\\s-*\n" str)
(setq str (concat (substring str 0 (match-beginning 0))
"\n"
(substring str (match-end 0)))))
;; HACK FOR NOSHOW
(if matlab-shell-run-no-show
(while (string-match "\n" str)
(setq str (replace-match ", " t t str))))
(setq str (concat str "\n"))
str))
(msbn nil)
(lastcmd)
(inhibit-field-text-motion t))
(if (matlab-with-emacs-link)
;; Run the region w/ Emacs Link
(matlab-eei-eval-region beg end)
(save-excursion
(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))
(set-buffer msbn)
(goto-char (point-max))
(display-buffer msbn))
))
But I leave it up to you and others to decide.....
Uwe
|