Emacs can also be annoying when it autoinserts text without checking to see if it’s already there. Case in point, gettext .po files under Emacs 23.1. For whatever reason, my copy kept inserting this header whenever I opened a translation file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSIONn"
"PO-Revision-Date: 2012-12-10 05:06+0000n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>n"
"Language-Team: LANGUAGE <LL@li.org>n"
"MIME-Version: 1.0n"
"Content-Type: text/plain; charset=CHARSETn"
"Content-Transfer-Encoding: 8bitn"
|
If this header sneaks into a .po file, when you try to compile the file with Django’s compilemessages command, you get the following error:
1
2
3
4
5
6
7
|
$ django-admin.py compilemessages
processing file django.po in /home/user/project/app/locale/de/LC_MESSAGES
/home/user/project/app/locale/de/LC_MESSAGES/django.po: warning: Charset "CHARSET" is not a portable encoding name.
Message conversion to user's charset might not work.
/home/user/project/app/locale/de/LC_MESSAGES/django.po:21: duplicate message definition...
/home/user/project/app/locale/de/LC_MESSAGES/django.po:7: ...this is the location of the first definition
msgfmt: found 1 fatal error
|
What seems to happen is that this header is only inserted when you use C-x C-f to open a file. When opening a file directly from the command line, this corruption does not seem to occur.
If you look at the PO Group configuration options, this text is listed there as the default PO file header. I haven’t validated this as a solution, but you should be able to switch this value to be the comment character “#”, and that should take care of the problem.
Also, why the hell does the PO major mode not allow you to destroy entire msgid’s and their translations? This is really annoying. Yes, it’s nice sometimes when programs limit your options, but in this case, Emacs was messing up by inserting the bad header, then refusing me the option of removing it.