By default, comment-region
inserts #
for comments in Octave major mode:
# foo
I want to modify the behavior so that it inserts the percent sign
% foo
I used the following
(setq octave-mode-hook
(lambda () (setq octave-comment-char ?%) ))
(modify-syntax-entry ?% "<" octave-mode-syntax-table)
But it gives me this error:
Symbol's value as variable is void: octave-mode-syntax-table
I don't know about elisp so well, so how can I solve this?
Edit
Here is the configuration needed to make octave-mode
the default one for .m
files and change commenting behaviour to that of MATLAB's. Note that for Octave, both %
and #
are valid for commenting.
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))
(add-hook 'octave-mode-hook
(lambda () (progn (setq octave-comment-char ?%)
(setq comment-start "% ")
(setq comment-add 0))))