Remove CRLF line terminators using Emacs in batch mode

At the moment I cooperate with Windows users in writing a big latex file. A few of the editors are not willing to use version control. As result the ones using version control (like me) use diff to integrate the work of others. I am using Linux, like most of the team. So we don't have CRLF at the end of lines. To remove the CRLF in files originating from the Windows users, I use Emacs.

First: Check whether there are CRLF line endings.

$ file foo.tex
foo.tex: ISO-8859 English text, with very long lines, with CRLF line terminators

Yes, there are so let's remove them.

emacs -batch -no-site-file foo.tex \
--eval="(set-buffer-file-coding-system 'iso-latin-1-unix)" -f save-buffer

In this command line Emacs is called in batch mode. The -no-site-file argument prevents Emacs from loading init stuff like .emacs. After that the file is loaded and the command set-buffer-file-coding-system is evaluated with the coding-system iso-latin-1-unix. As last step we save the file.

Check if everything is okay now:

$ file foo.tex
foo.tex: ISO-8859 English text, with very long lines

Perfect.

Write exotic characters in Emacs

For example you need to write the Unicode-Character for an EM DASH (in Unicode-block 20 character 14).

So first change the input-method in Emacs to rfc1345 with C-x RET C-

Now the input-method for this buffer is rfc1345 and with & and the char-code we can enter every unicode character (for example &-M for the EM DASH).

All charcodes are listet in rfc1345 (i.e. http://www.faqs.org/rfcs/rfc1345.html)

With C-\ you can toggle back to the "normal" input-method.

Using Generic-Mode in Emacs

These tables are generated using a python script which extracts the data from Matlab files. To write every caption or heading only once I use a data file in which I store key:value-pairs.

Example file:

# comment
key-1: this is the snippet which reoccurs often.
key-2: and this is another one

To highlight the keys and the comments I use generic-mode (see in Emacswiki).

(define-generic-mode 'chunkdata-mode
  '("#")
  nil
  '(("^[a-zA-Z0-9\-\_\,]+:" . 'font-lock-variable-name-face))
  nil
  nil
  "Majormode for my chunks.data-files")

To enable this I added:

# -*- mode:chunkdata -*-

in the first line of the data-file. Now all Comments are highlighted in dark-red and all keys in dark-yellow. The result is a much better readability.