Sunday, April 30, 2006

Edit and debug Matlab with emacs (my present way)

following the file: $MATLAB/java/extern/EmacsLink/install.html

You can run 'M-matlab-shell' in emacs and get the matlab shell mode to debug it in emacs, but it is not comfortable. My present solution is:

Run matlab first, then edit *.m to open emacs. Now matlab-eei-minor-mode is opened and adds a Mdb menu in matlab. This is the only way I can find to active matlab-eei-minor-mode. There is no shell mode for it.

[coolcode]

;; MATLAB

;; Edit the path in the following line to reflect the

;; actual location of the MATLAB root directory on your system.

(add-to-list 'load-path "/usr/local/matlab7/java/extern/EmacsLink/lisp")


(autoload 'matlab-eei-connect "matlab-eei"

"Connects Emacs to MATLAB's external editor interface." t)


(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)

(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))

(autoload 'matlab-shell "matlab" "Interactive Matlab mode." t)


(setq matlab-indent-function t) ; if you want function bodies indented

(setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save

(defun my-matlab-mode-hook ()

(define-key matlab-mode-map [f4] 'matlab-eei-exit-debug)

(define-key matlab-mode-map [f5] 'matlab-eei-run-continue)

(define-key matlab-mode-map [C-f5] 'matlab-eei-go-until-cursor)

(define-key matlab-mode-map [f9] 'matlab-shell-run-region)

(define-key matlab-mode-map [f10] 'matlab-eei-step)

(define-key matlab-mode-map [f11] 'matlab-eei-step-in)

(define-key matlab-mode-map [C-f11] 'matlab-eei-step-out)

(define-key matlab-mode-map [f12] 'matlab-eei-breakpoint-set-clear)

(setq fill-column 76)

(imenu-add-to-menubar "Find")) ; where auto-fill should wrap

(add-hook 'matlab-mode-hook 'my-matlab-mode-hook)


(setq matlab-show-mlint-warnings t)

(setq matlab-highlight-cross-function-variables t)


(setq max-specpdl-size 6800)

;; number font face

(defface font-lock-number-face

'((t (:foreground "lime green")))

"Used for numbers and such.")

(defvar my-extra-keywords

'(("\(\<[0-9.]+\>\)" . 'font-lock-number-face)))

;; add it to matlab-mode

(font-lock-add-keywords 'matlab-mode my-extra-keywords)


(setq matlab-shell-command-switches '("-nojvm"))

;; (defun my-matlab-shell-mode-hook ()

;; '())

;; (add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook)

(setq matlab-shell-enable-gud-flag t)

[/coolcode]

No comments:

Post a Comment