Opened 12 years ago

Last modified 12 years ago

#480 new enhancement

-*- coding: xxx -*-

Reported by: gz Owned by:
Priority: minor Milestone: Cocoa IDE v?
Component: IDE Version: 1.3
Keywords: Cc:


It might be cool for Hemlock to support the Emacs 'coding:' modeline variable as a way to specify the file's encoding. I haven't thought about whether this makes sense (e.g. I don't even know how standard emacs encoding names are, etc), but I just wanted to put the idea on record for when somebody does have time to look into it.

Change History (1)

comment:1 Changed 12 years ago by gb

One issue is that the IDE editor believes that it needs to know the file's character encoding in order to be able to open it (and see if its attribute line contains "- ... coding:"). I suppose that we could peek at the first 100 or so bytes of the file and see if they seem to contain such a line.

If a file is saved with an explicit encoding (on Tiger or later), the name of the encoding is saved as file metadata (an "extended attribute"); you can see if that attribute exists via:

$ xattr file

and if the file has an attribute (like "") see the value of that attribute via:

$ xattr -p

(There's no reason to be as stupid about this stuff as Apple's xattr program is.)

I'm fairly sure that when the "automatic" pseudo-encoding is used when opening a file in the IDE, it checks to see if an extended attribute exists. If it does, then we have some confidence that the file was saved in the encoding specified by the xattr. (I don't know what happens if a file is saved in one encoding from the IDE and another from a non-xattr-aware editor.)

It'd probably be good to pay at least enough attention to the modeline variable to notice when it specifies a different encoding than was used to open the file.

Note: See TracTickets for help on using tickets.