Random emacs useful things

Modes

Wraping lines

Emacs has various ways for wrapping lines, like a word processor. First off, you have to define what a paragraph is, or else they will be merged. The main way I know of is separating paragraphs with blank lines, but that's what most people use anyway. It is reasonably smart about prefixing lines, and initial indention:

Prefixing lines:

> oueuo
> i  aoeutenaou eouhtn nth ontao  tn nt nth nhtnht n nht nht nht
> oeuoeu hnt nthhnt hnt hnt hnt
> xoenut
> oeuneu

goes to

> oueuo i aoeutenaou eouhtn nth ontao tn nt nth nhtnht n nht nht nht
> oeuoeu hnt nthhnt hnt hnt hnt xoenut oeuneu

This won't let it recognize a paragraph break, but if you are in mail-mode, it does! Then, you can re-fill replied-to text quoted with .

So to do actually aligning of paragraphs, use M-q. auto-fill-mode will wrap lines whenever you get to the end of a line, you have to use M-q whenever you go back and mess it up. This is how I usually do it. refill-mode will keep the lines balanced at all times.

To set the number of columns it fills at, use M-<number> C-x f. (That is, C-x f with a numeric argument.)

Initial indention:

>   oueuo oooaeo  n aoa hnto n  no noae nnoa aoeno n
> ioeu e  aoeutenaou eouhtn nth ontao  tn nt nth nhtnht n nht nht nht

>   oueuo oooaeo n aoa hnto n no noae nnoa aoeno n i aoeutenaou eouhtn
> nth ontao tn nt nth nhtnht n nht nht nht

AUC TeX

Master Files

If you are producing a very large document, you may want to split it up into several subfiles. In order that C-c C-c will compile the "master" file, you need to tell each subfile what its master file is. The easiest way to do this is do C-c _. This will ask you for the master file, then put some macros in the file you are editing.

The next time you do C-c C-c, AUC TeX will compile the master file.

Using pdflatex

To automatically use pdflatex change the mode parameter to tex-pdf after running C-c _:

%%% Local Variables: 
%%% mode: tex-pdf
%%% TeX-master: t
%%% End:

Console stuff

Make it have a UTF-8 input method on the console. Use set-keyboard-coding-system and set it to utf-8 or so.

(if (not (eq window-system 'x))
    (set-keyboard-coding-system 'utf-8))

xterm-mouse-mode allows you to have the mouse interface with xterm's mouse-handling stuff. You can select stuff and paste it using the emacs buffer, but not with the X copy buffer. To force usage of the X buffer, hold down the shift key (this works in any mouse-application, such as w3m and aptitude.

To fix the problem with a font color which won't show up (in particular, this solution works for AUCTeX's LaTeX-mode), you can add this to your rc file: {{{(add-hook 'LaTeX-mode-hook

}}} Note that in this case, you need to protect it in the set-face-foreground command in a lambda function, since font-latex-sedate-face isn't defined before you load LaTeX-mode. You can use M-x set-face-foreground or M-x customize-face to experiment with available colors and such.

Encryption

A lot of useful stuff is here. This troper (mvd) likes using symmetric encryption for individual files. You could use any of the GPG-related things, but it's probably easiest to use ccrypt which comes with its own elisp file to transparently handle encryption of files with the extension "cpt" using AES encryption. Just add this to ~/.emacs:

(setq load-path (cons "/usr/share/emacs/site-lisp/ccrypt" load-path))
(require 'jka-compr-ccrypt "jka-compr-ccrypt.el")

The only slightly annoying thing this troper has found about this so far is that it always prompts for a password, even if the file doesn't exist yet. But you can just hit enter without entering anything and enter the actual password when saving.

DebianNotes/Emacs (last edited 2010-10-28 23:57:10 by MikeDePalatis)