wainstead: In your Emacs Lisp snippets, you could use
let instead of
setq to get real local variables. The trouble with
setq is that it will set an existing variable to the new value, by searching up the stack to find where the variable exists and defaulting to a global if none is found. So, there's a risk that it will interfere with some other variable. This is riskier than it might seem, since even "top-level" interactive commands could find themselves munging local variables in other functions that are making
recursive edits.
For example, you could switch to let like this:
(defun sw-list ()
(interactive)
(let ((buffer (get-buffer "*Ibuffer*")))
(if (bufferp buffer)
(progn
(switch-to-buffer buffer)
(ibuffer-update nil))
(ibuffer))))
More details at http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_49.html