help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error: Setting the shell in sh-mode via a local variable does not work


From: Johannes Kastl
Subject: Error: Setting the shell in sh-mode via a local variable does not work
Date: Mon, 28 Dec 2015 17:35:36 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear all,

first of all, sorry if I failed in finding the answer to my question
on the web.

I have a file called 'whatever.spec.in', that basically is a rpm
spec file. (Technically, the spec file is generated from this file).
So, I'd like to have the nice rpm sh-mode, that my emacs uses for
files called 'whatever.spec'.

I googled a lot about major-modes, interpreter-mode-alist and all
kinds of stuff, even derived my own major-mode, but all fail, except
this:

(add-hook 'sh-mode-hook
          (lambda ()
            (if (string-match "\\.spec\\.in$" buffer-file-name)
                                (sh-set-shell "rpm"))))

This works. But:

The file contains some local variables at the end, that should
achieve the same:

# Local variables:
# mode: shell-script
# sh-shell: rpm
# end:

But regardless of what I put in the 'mode' and 'sh-shell' lines, I
always end up with shell-script[bash] when opening the file as
whatever.spec.in. If I rename it to whatever.spec, I get
shell-script[rpm].

Is this intended behaviour? Shouldn't the 'sh-shell:' line work? I
get no warning about malformed lines, so I think it is syntactically
correct.

Putting these local variables into an empty file call whatever.txt
gets me shell-script[bash], so apparently the 'mode:' line is used.

Thanks in advance, and please excuse the long descriptions...

Johannes

P.S.: System is OSX 10.10, emacs is GNU Emacs 24.5.1 from macports
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with SeaMonkey - http://www.enigmail.net/

iEYEARECAAYFAlaBZNIACgkQzi3gQ/xETbJLQgCfeBj+bVh4IzYCIb+CEMokqnko
MJYAn1dUEBM7w3VWCQa+/01gtKLcGulB
=r6ms
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]