help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Distinguishing between interactive and asynchronous shell buffers


From: Sean McAfee
Subject: Distinguishing between interactive and asynchronous shell buffers
Date: Sun, 20 Feb 2011 16:02:39 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin)

I find that dired is a much better way of navigating around a large
directory hierarchy than staying in my shell buffer and issuing lots of
cd/ls commands.  To bring my shell buffer to a directory I've located
with dired, I wrote an interactive command
bring-last-shell-buffer-to-this-directory (aliased to "c'mere") which
locates the most-recently-used shell buffer like this:

  (let ((buffer (or (loop for buffer being the buffers
                          if (with-current-buffer buffer 
                               (eq major-mode 'shell-mode))
                          return buffer)
                    (error "No shell buffers!"))))
    ;; Issue a "cd" command in buffer that sends that shell
    ;; to the starting buffer's default-directory

This works great most of the time, but once I started an asynchronous
shell command after moving around in dired, and when I did M-x c'mere,
my routine tried to send a cd to the *Async Shell Command* buffer.

What's the best way to distinguish asynchronous shell command buffers
from interactive shell buffers?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]