m (.emacs)
m (aucTeX)
Line 103: Line 103:
 
== aucTeX ==
 
== aucTeX ==
  
If for some reason, pdf stops compiling (and reverts to dvi), then:
+
If for some reason, pdf stops compiling (and reverts to dvi) or there is a complain of <tt>no-matching-viewer</tt>, then:
  
 
<pre>
 
<pre>

Revision as of 09:14, 25 September 2023

Emacs logo.png

Contents

Emacs

Emacs is the most powerful text editor.

It is so powerful that you cannot limit it to this task alone; removing "text" in the above statement gives a better idea of what Emacs is.

It is one of the big marvels of computer codes, along with Unix, $\mathrm{\TeX}$ and others. Stallman wrote the popular GNU version in 1984 and it is still actively maintained as of today and will hopefully remain so forever. This is the real jewel.

The XEmacs branch, from the flamboyant Jamie Zawinski, was one of the earliest forking process in the computer software industry. It's without any doubt the version to use in the DNA lounge.

Useful

To remove trailing␣␣␣␣␣␣spaces, use M-SPACE. This is however preempted by kde for "Run command", for which I prefer the global alternative Alt+F2, so just remove this assignment in ksettings.

To replace a character, say ";", with a line-break, use [1]:

M-x replace-string RET ; RET C-q C-j

with C-q for "quoted-insert" and C-j for "newline".

Registers

See [2]

  • text register

C-x r s a | store region as “a”
C-x r i a | insert region stored in “a”
C-x r r a | store rectangle as “a”

  • point register

C-x r SPC a | store current point as “a”
C-x r j a | move to point in “a”

  • window register

C-x r w a | store configuration of windows in frame
C-x r j a | restore window configurations

  • frame register

C-x r f a | store window configuration for all frames
C-x r j a | restore all window configurations

  • number register

C-x r N | insert a column of successive numbers - Prefix with C-u to set starting value.
C-u 1 C-x r n a | store 1 in “a”
C-u 1 C-x r + a | add 1 to number in “a”
C-x r i a | insert number in “a”

  • position register

C-x r m RET | save default
C-x r m <NAME> RET | save as NAME
C-x r b RET move to | default
C-x r b <NAME> RET | move to NAME
C-x r l list

Keyboard macros

This is like registers but on steroids: there you record entire sequences.

See the documentation or follow these steps:

  • Hit C-x ( to start recording a keyboard macro.
  • Do what the command is supposed to do (i.e. execute commands, hit keys, ...)
  • Hit C-x ) to stop recording the keyboard macro.
  • Execute M-x name-last-kbd-macro to name the last-defined keyboard macro (i.e. the one you just defined).
  • Execute M-x insert-kbd-macro to insert the code of the last defined macro at point, copy it into your init file.
  • Put (global-set-key (kbd "M-n") 'my-macro) into your init file (assuming you named the macro my-macro) and to have M-n bind to it.

This is for instance how to bind subequations and align with automatic labelling (after my uniqname convention) for aucTeX:

(fset 'mysubeqs
   [?\C-c ?\C-e ?s ?u ?b ?e ?q ?u ?a ?t ?i ?o ?n ?s return ?\\ ?l ?a ?b ?e ?l ?\{ ?e ?q ?: ?\C-u ?\M-! ?u ?n ?i ?q ?n ?a ?m ?e return ?\C-e ?\} return ?\C-c ?\C-e ?a ?l ?i ?g ?n return return])
(global-set-key (kbd "C-c s") 'mysubeqs)

Lisp

To define a new Lisp command M-x eval-region RET on the code itself of M-x Eval-buffer to evaluate the whole page.

Links

Local file variables

A file can specify local variables. "Visiting" the file checks for local variable and makes them local to the buffer. We use this mainly for aucTeX, to read:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-command-extra-options: "-shell-escape"
%%% End:

the -shell-escape command is useful when compiling, e.g., with minted (and is usually not needed).

aucTeX

If for some reason, pdf stops compiling (and reverts to dvi) or there is a complain of no-matching-viewer, then:

M-x TeX-PDF-mode

should revert to enabling it.

.emacs

My dot-emacs configuration file: .emacs.gz. It can be kept compressed as ".emacs.gz" in the home directory /home/laussy/ and opened directly with emacs and saved as such.

Versions:

  1. 1°0: 1 April (2022) started versioning (not a joke) to keep track + operatorname (C-M-o) to add \operatorname{}.
  2. 1°1: 20 May (2022) eqtomultline to replace a LaTeX equation environment to a multline one.

Abbrevs

My Emacs-abbrevs file.

Links