emacs.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 28 Dec 2009 23:01:00 +0200
changeset 268 b99a51c4e605
parent 225 0de8b66b6f49
child 269 77c8799aa8de
permissions -rw-r--r--
Emacs treat text as local variable definition, escape text.

-*- mode: outline; coding: utf-8 -*-

* Variables.

Select one of:

  (set 'variable value)
  (setq variable value)
  (defvar variable value "documentation")

or (replace <colon> with :)

  # Local variables<colon>
  # variable<colon> value
  # End<colon>

* Debugging.

** Using edebug.

Execute 'M-x edebug-defun' (also on 'C-u C-M-x') on defun in source code to
enable debugging for desired function. When next time this function invoked
you entered to its debugging (jumped to its source code).

To start debug execute code which used debugged function.

You can disable edebug on a function by evaluating the function again using
'C-M-x'.

** How debug func?

Use M-x debug-on-entry and M-x cancel-debug-on-entry to control
which functions will enter the debugger when called.

When next time that function called automatically loaded debug-mode.

** How debug ini file?

When your ini has a bug, or when you load external files that cause
errors, the bug is often hard to find, because the Emacs Lisp reader does not
know about line numbers and files - it just knows an error happened, and
that's it.

*** Binary Search.

Select half of the file in a region, and M-x eval-region. Depending on whether
that causes the error or not, split this half or the other half again, and
repeat.

*** Elisp.

 - Use a keyboard macro that moves forward one expression (sexp) and evaluates
   it.
 - Try C-x check-parens.
 - Set (setq debug-on-error t).

*** CLI.

  $ emacs --no-init-file --no-site-file --debug-init

*** Simplified Binary Search.

Add (error 'No error until here') in the middle of your file. If you get the
error 'No error until here' when reloading the file, move the expression
towards the back of the file, otherwise towards the front of the file.

** Call tree.

Before byte compiling file execute

  (setq byte-compile-generate-call-tree t)

* WWW.

** Text based WWW browser.

  http://en.wikipedia.org/wiki/W3m
  http://emacs-w3m.namazu.org/
  http://www.gnu.org/software/w3/

* Tricks.

** Sort and uniquify lines.

Select region, type C-u M-| sort -u RET.

With transient-mark-mode and delete-selection-mode enabled: select region,
type M-| sort -u RET to replace selection with sorted and uniquified lines.