문제

My .emacs file concerning Matlab is as follows:

;; Matlab mode
(autoload    'matlab-mode "matlab" "Matlab Editing Mode" t)
(setq matlab-indent-function t)
(setq matlab-shell-command "matlab")

But when I open a Matlab file, I see I'm in Objective-C mode. Since I do not plan on writing Objective-C anytimes soon, how do I default all .m files to open in Matlab mode?

도움이 되었습니까?

해결책

Your comment says you've resolved this. Something tells me you did it by adding

(add-to-list 'auto-mode-alist '("\\.m" . matlab-mode))

to your .emacs. I've got so many of these sprinkled around that I just wrote a convenience macro for it:

(defmacro by-extension (ext mode)
  `(add-to-list 'auto-mode-alist '(,(format "\\.%s" ext) . ,mode)))

which lets me write things like

(by-extension "m" matlab-mode)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top