[Arcana] Because it just kills me to type C-x b *com TAB RET when I don't really have to.

Roland McGrath roland at frob.com
Thu Mar 12 19:03:22 CDT 2009


I don't have one of those.  I have this, and C-c c is switch-to-compilation.

(defun really-compilation-buffer-p (buffer)
  (and (null (buffer-file-name buffer)) (compilation-buffer-p buffer)))

(if (fboundp 'next-error-find-buffer)
    (defun really-compilation-find-buffer (&optional avoid-current)
      (next-error-find-buffer avoid-current nil
			      (lambda () (null (buffer-file-name)))))
  (fset 'really-compilation-find-buffer 'compilation-find-buffer))

(defun switch-to-compilation ()
  "Switch to a compilation buffer.
If the current buffer is a compilation buffer, switch to a different one."
  (interactive)
  (condition-case lose
      (let ((buf (current-buffer)))
	(switch-to-buffer (really-compilation-find-buffer t))
	(if (really-compilation-buffer-p buf)
	    (bury-buffer buf)))
    (error (beep)
	   (if (y-or-n-p "No compilation started!  Did you want one? ")
	       (call-interactively 'compile)))))

There is also the attached.  Between all that, my idiom is:

* C-c c until I see the right one (I guess for some kind of loon who only
  works on one program at a time, it would always be the right one).
* C-x c or C-u C-x c <edit> RET

Your style would probably bug me before long because it's not uncommon for
me to be doing two builds from one srcdir in parallel (a -m32 and a -m64,
or different kernel configs, different --enable-foos, etc).  I tend to keep
state in two ways: rename a compilation buffer in the right
default-directory, and navigate to that with C-c c or explicitly; use many
shell buffers where I use cd/pushd/etc to match the mental focus that
buffer represents at that time, the local C-x c history is what I want to
do there, and navigate to that with C-c s or explicitly.  C-c s is:

(defun switch-to-shell ()
  "Switch to a buffer in shell-mode."
  (interactive)
  (let ((bufs (buffer-list)))
    (while (and bufs
		(or (not (memq (cdr (assq 'major-mode
					  (buffer-local-variables (car bufs))))
			       '(shell-mode rlogin-mode)))
		    (get-buffer-window (car bufs) t)))
      (setq bufs (cdr bufs)))
    (cond (bufs
	   (switch-to-buffer (car bufs)))
	  ((eq major-mode 'shell-mode)
	   (message "This is the only shell buffer."))
	  (t
	   (message "Starting new shell.")
	   (shell)))))

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: compilestuff.el
URL: <http://www.red-bean.com/pipermail/arcana/attachments/20090312/bcc915b5/attachment-0002.ksh>


More information about the Arcana mailing list