#+TITLE: emacs notes #+SHORT-TITLE: emacs #+KEYWORDS: lisp, emacs #+DESCRIPTION: emacs notes #+BEGIN(menu):left [[toc][]] #+END * emacs For people familiar with lisp emacs has no competitors; but even before learning lisp it was a handy tool for me and I used it for c.a. 10 years. Here I collect my emacs tips/notes and pieces of code. * Bugs Somehow emacs does not handle remote connections well: it may freeze up and become immortal (immune even to [[src:kill -9]]). So instead of [[src:C-x C-f /ssh:server.com:/path/to/file.txt]] I prefer mounting remote directory into [[src:/mnt/]] and then access it with emacs as a local file. * TeX-lisp manual I do not remember all Lisp functions, so it is helpful to quickly access extended articles from the TeX-lisp manual when updating a [[src:.lisp]] file. [[https://github.com/ruricolist/dpans2texi][dpans2texi]] is a useful software which transforms TeX manuals into [[https://www.gnu.org/software/texinfo/][texinfo format]]. The latter is understood by emacs, so, for example, when you write lisp code, you can get documentation (better than what slime provides) for lisp functions and symbols by pressing [[src:C-c C-d h]]. Unfortunately it did not work for me out of the box, so I had to patch it. My [[files/dpans2texi.patch][patch]] 1. fixes [[src:dpi.texi]] encoding, 2. does a couple of fixes in [[src:dp.texi]], 3. adds treatment of TeX macro [[src:it]] to [[src:dpans2texi.el]], 4. removes non-working redefinition of [[src:@code]] from [[src:dpi.texi]]. This patch is a quick fix; it can be improved (sometimes I note strange symbols in the emacs info-buffer). Unfortunately, many packages available from quicklisp are not covered in the standard TeX-lisp manual; If/when I have time, I will slowly update the standard TeX-lisp manual with info on (my favorite) common-lisp packages. * Patching dpans2texi The original dpans2texi project was erased on github, so now one can use [[https://github.com/ruricolist/dpans2texi][its clone]]. Install original [[https://github.com/ruricolist/dpans2texi][dpans2texi]] and patch it: #+BEGIN(src):shell git clone https://github.com/ruricolist/dpans2texi cd dpans2texi wget chalaev.com/files/dpans2texi.patch patch -p1 < dpans2texi.patch make clean; rm *.tex ./configure --prefix=$HOME/local make wget && make && make install #+END (See also [[https://github.com/ruricolist/dpans2texi][dpans2texi]] manual). * Configuring emacs After the following piece of code is evaluated, we can get help on lisp symbols using standard slime key combination (default [[src:C-c C-d h]]). In order to activate info-files produced by [[https://github.com/ruricolist/dpans2texi][dpans2texi]] insert the following into your [[src:\~\/.emacs]] file: #+BEGIN(src):elisp (require 'info-look) (setq Info-additional-directory-list (list(substitute-in-file-name "$HOME/local/share/info"))) (with-eval-after-load "slime" (info-lookup-add-help :mode 'lisp-mode :regexp "[^][()'\" \t\n]+" :ignore-case t :doc-spec '(("(ansicl)Symbol Index" nil nil nil))) (info-lookup-add-help :mode 'slime-repl-mode :regexp "[^][()'\" \t\n]+" :ignore-case t :doc-spec '(("(ansicl)Symbol Index" nil nil nil))) (defvar slime-old-documentation-lookup-function (if (boundp 'slime-documentation-lookup-function) slime-documentation-lookup-function)) (defun slime-ansicl-lookup (symbol-name) (interactive (list (slime-read-symbol-name "Symbol: "))) (info-lookup-symbol symbol-name 'lisp-mode)) (setq slime-documentation-lookup-function 'slime-ansicl-lookup) (setq slime-ansicl-lookup (symbol-function 'slime-ansicl-lookup))) #+END