Combining mode and encoding in emacs

David M. Cooke cookedm+news at physics.mcmaster.ca
Fri Sep 3 18:59:27 CEST 2004


At some point, mlh at furu.idi.ntnu.no (Magnus Lie Hetland) wrote:

> If I want to specify both mode and source encoding using the
>
>   -*- FOO -*-
>
> syntax in emacs -- how can I do that? Both insist on being on the
> second line of the file, yet I have found no way of combining them.
> That is, the following doesn't work properly (not in all emaxen, at
> least):
>
>   #!/usr/bin/env python
>   # -*- encoding: iso-8859-1 -*-
>   # -*- python -*-
>
> If I switch the two, Python doesn't get the encoding. (I need to
> specify the mode, because the file has a '.cgi' ending.)

#!/usr/bin/env python
# -*- mode: python; encoding: iso-8859-1 -*-

This works for me in GNU emacs 21.3.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list