0

My Octave scripts start with descriptions, like

## -*- texinfo -*-
## @deftypefn  {} {} @var{planesource}
##
## This class implements an abstract planar structure
## that functions as a source of waves.
##
## @end deftypefn

If the description is omitted, Emacs uses Octave mode automatically, because I have this code in my ~/.emacs.d/init.el:

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

However, with the TexInfo description, TexInfo mode seems to override Octave mode, even when my Emacs is configured to treat .m files as Octave files.

How can I make Emacs automatically use Octave mode even in those cases where the description exists and is written in the TexInfo format?

  • I can't reproduce this problem. Normally modes are set based on file names, not their contents. I suspect there's something in your configuration causing this issue. See https://emacs.stackexchange.com/questions/28429/how-do-i-troubleshoot-emacs-problems – Tyler Apr 05 '22 at 20:37

1 Answers1

0

The problem is that Emacs processes first-line comments of the form -*- [something] -*- specially, as (IMO rather crude) directives for things like (as in this case) setting or overriding the major mode.

I believe (untested) that simply adding a single blank comment line, or a comment line giving e.g. the file name, above your class doco should fix this.

Phil Hudson
  • 1,651
  • 10
  • 13