Some (X)Emacs stuff

I am the author of two little developments for Emacs:

To use these two files, download them and put them (untar holes.tgz with the command tar xvfz holes.tgz, you get a directory with four files) somewhere Xemacs can find them. Then put this in you initialization file:

(require 'holes-load)
(require 'circul)
To toggle holes-mode: M-x holes-mode. You can put (holes-mode 1) in the hooks of your modes in order to have holes-mode automatically enabled. All shortcuts described above will only work on buffers where holes-mode is on. Of course you can edit holes.el to change the shortcuts.

The files span.el, span-extent.el and span.el are from the ProofGeneral mode. Everything is under GPL. It should work on both FSF Emacs(21) and Xemacs. Ideas for improvement and bug reports are welcome.

Emacs and git (magit)

magit is quite easy to use for nomianl use. I was unhappy with magit's way of splitting/deleting windows, so I put this in my initialization file (notice that for quitting I only redefine the "q" keybinding, the menu "quit" still kills the window):
(defvar pc:magit-from-buffer
  "Buffer from where magit-status were last called."

(defun pc:magit-status-buffer-switch (buf)
  "My replacement for `magit-status-buffer-switch-function'.
`magit-status' does not split windows (switch to magit buffer
instead). Also store the current buffer to switch back to it when
TODO: store the whole frame config instead?"
  (setq pc:magit-from-buffer (current-buffer))
  (switch-to-buffer buf))

(setq magit-status-buffer-switch-function 'pc:magit-status-buffer-switch)

(defun pc:magit-quit-window (&optional kill-buffer)
  "My replacement for \"q\" keybinding in magit.
Bury the current (magit) buffer and switch to original buffer.
With a prefix argument, kill the magit buffer instead."
  (interactive "P")
  (if kill-buffer (kill-buffer) (bury-buffer))
  (switch-to-buffer pc:magit-from-buffer))

(add-hook 'magit-mode-hook
	  '(lambda () (define-key magit-mode-map (kbd "q") 'pc:magit-quit-window)))

Emacs and LaTeX

Here is a minimum config you should add to your .emacs (replace (control fxx) by the keystroke you want). RefTeX should be installed by default if you have a standard installation of (x)emacs:
 (add-hook 'LaTeX-mode-hook '(lambda () 
    (turn-on-reftex); Turn on RefTeX Minor Mode for all LaTeX files
    (define-key LaTeX-mode-map [(control f12)] 'TeX-next-error)
    (define-key LaTeX-mode-map [(control f11)]
      '(lambda () (interactive) 
         (TeX-command-menu "LaTeX")))
Now hit (control f11), it compiles, if there are some errors, type (control f12) and it goes straight to the error and shows the message. See also the ref menu to navigate through the table of content of your document.

A hack to have xdvi updated when latex compile is finished:

This one is a bit outdated since everybody uses pdf output nowadays. It allows to have a keystroke which runs latex on your file, then waits for the process to finish, and then sends a signal to xdvi telling him to watch the file (change "xdvi.bin" by the exact name of the process if necessary). That way you don't have to switch to xdvi's window each time. Thanks to Eric Pop helping make this emacs compatible.

(defvar latex-process-timer nil
  "the timer used to watch latex and dvips processes.")

(defun send-sig (process-string sig)
  "sends sig signal to every process having name process-string"
  (call-process "killall" nil nil nil sig process-string))
(defun wait-latex-xdvi ()
  "wait for the latex process to stop, and send the USR1 signal to all
  running xdvi.bin processes"
  (if (TeX-active-process)
    (let ((x (current-message)))
      (send-sig "xdvi.bin" "-USR1")
      (if (featurep 'xemacs) (delete-itimer latex-process-timer) 
	(cancel-timer latex-process-timer))
      (message x))

(defun latex-xdvi () 
  (TeX-command-menu "LaTeX")
  (setq latex-process-timer (run-with-timer 1 1 'wait-latex-xdvi)) ;; latex-process-timer is a global variable

Then replace the control f11 shortcut above by this one:
(add-hook 'LaTeX-mode-hook '(lambda () 
  (define-key LaTeX-mode-map [(control f11)] 'latex-xdvi))

Last modified: Wed Sep 6 17:56:47 CEST 2006