|
From: Uwe B. <ou...@ma...> - 2016-02-19 13:11:54
|
Hi
One of the feature I miss most is to insert the result of
matlab-shell-run-command in the matlab buffer.
The following code cleans up that result and inserts it in the buffer.
I have a different version which also wraps
\begin{displaymath}
\end{displaymath}
Around it.
The funny thing is that I wrote this function for Xemacs but in GNU
emacs ;
(string-rectangle (point-min) (point-max) "% ")
behaves differently, it inserts the "% " but deletes all the other
content!
So I found a different solution using comment-region.
Any comments and improvements are very welcome.
Uwe Brauer
(defun my-matlab-insert-simple-raw ()
"Change and insert the content of the *Matlab Help* buffer.
(Sometimes invoked with `matlab-shell-run-command'.)
`kill-empty-lines' put all results in one line, and `comment'
them out according to the `matlab' syntax."
(interactive)
(save-excursion
(let ((currentname (current-buffer)))
(switch-to-buffer "*MATLAB Help*")
(make-variable-buffer-local 'comment-start)
(setq comment-start "%")
(toggle-read-only nil)
(goto-char (point-min))
(delete-empty-lines-region (point-min) (point-max))
(goto-char (point-max))
(delete-backward-char 1 nil)
(goto-char (point-min))
(while (re-search-forward "=" nil t)
(kill-line nil))
(goto-char (point-min))
(comment-region (point-min) (point-max) nil)
; (string-rectangle (point-min) (point-max) "% ")
(switch-to-buffer currentname)
(insert-buffer "*MATLAB Help*"))))
|