Combining mode and encoding in emacs

Roy Smith roy at panix.com
Fri Sep 3 18:41:31 CEST 2004


In article <slrncjh719.bs2.mlh at furu.idi.ntnu.no>,
 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.)
> 
> Any tips?

You can set the mode (and a lot of other things) with a local variable 
list on the last page (i.e. after the last form-feed).  Put something 
like this at the end of your file:

#                                                                                                          
# ^L                                                                                                       
#                                                                                                          

# Local Variables:                                                                                         
# mode:python                                                                                              
# End:     
                                                                                                







Look up info on "file variables" for more details.  The -*- stuff is 
just a convenient shorthand for a subset of what you can do with the 
more verbose Local Variables syntax.



More information about the Python-list mailing list