I don't have enough karma or whatever to comment, but I wanted to improve HD's style a bit.
Here is the original:
(loop
for n from (string-to-char "A") to (string-to-char "Z")
for c = (char-to-string n)
do (insert (concat "\\newcommand{\\c" c "}{\\mathcal " c "}\n")))
First off, Emacs Lisp has reader syntax for chars. Instead of (string-to-char "X")
, you can just write ?X
. Then, you can use the printf-style format
instead of char-to-string
and concat
to produce the final result:
(loop for n from ?A to ?Z
do (insert (format "\\newcommand{\\c%s}{\\mathcal %s}\n" n n)))
Now it's concise enough to type without thinking into the M-:
prompt.
I will also point out that TeX has macros too, if this is indeed TeX.
Edit: Another bit of style advice for Joe Casadonte; (incf foo)
is much easier to type than (setq foo (+ foo 1))
.