473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Combining mode and encoding in emacs

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?

--
Magnus Lie Hetland "Canned Bread: The greatest thing since sliced
http://hetland.org bread!" [from a can in Spongebob Squarepants]
Jul 18 '05 #1
3 2314
In article <sl****************@furu.idi.ntnu.no>,
ml*@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.
Jul 18 '05 #2
At some point, ml*@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
Jul 18 '05 #3
On Fri, Sep 03, 2004 at 04:30:33PM +0000, 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.)


what I do is

# -*- python -*- coding: iso-8859-1 -*-

--
John Lenton (jo**@grulic.org.ar) -- Random fortune:
La sociedad moderna olvida que el mundo no es propiedad de una única
generación.
-- Oskar Kokoshka.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBOKPagPqu395ykGsRAsYuAKCljqCmHqJW1vfsCrXtS7 vADAn0UACfZoUQ
QVa0hz/bF6+BX6/yhkmt4D0=
=Cwv/
-----END PGP SIGNATURE-----

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Locke | last post by:
Hi All, I'm having trouble with the python shell within emacs. It's hanging when I use tkinter. Setup is: Windows XP emacs 21.3 py-mode 4.6 Recipe:
6
by: Christian Seberino | last post by:
I am looking at the ELSE home page and trying to figure out if I should invest the time to learn about the ELSE minor mode for Emacs. Is there any programmer out there using ELSE that is getting...
1
by: Marcio Rosa da Silva | last post by:
Hi all, My first try on using RST to write an email. so I can (will) make mistakes :-) I am experiencing the problem shown in this thread_ of the `python-mode`_ discussion list hosted at...
9
by: Alan Mackenzie | last post by:
To all those who use (X)Emacs's CC Mode to edit C, C++, Java, Objective-C, Pike, AWK or IDL: To help direct the development of CC Mode, it would be useful to find out how people use the...
3
by: John J Lee | last post by:
Is it possible to get doctest-mode to work with mmm-mode and python-mode nicely so that docstrings containing doctests are editable in doctest-mode? In my utter e-lisp ignorance, I tried this: ...
2
by: sparkw | last post by:
I am using WinXP, GNU Emacs 23, MySQL 5. When I start a mysql process with `sql-mysql' in emacs, no output is displayed in the buffer until I quit or kill the process. After I add the following...
0
by: sparkw | last post by:
I collect the following messages from Usenet and make a summary. *Problem*: There is no buffer output or output prompt ( the line after output), when a mysql process is initiated in Emacs WinNT....
0
by: damonwischik | last post by:
I use emacs 22 and python-mode. Emacs can display utf8 characters (e.g. when I open a utf8-encoded file with Chinese, those characters show up fine), and I'd like to see utf8-encoded output from my...
7
by: Michele Simionato | last post by:
I have noticed that the python-mode for Emacs that comes with the latest Ubuntu is missing the class browser. Moreover if works differently from the python-mode I was used to (for instance CTRL-c-c...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.