all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Phillip Lord <p.lord@russet.org.uk>
Subject: Re: shell mode, changing directory
Date: 24 Mar 2003 16:21:29 +0000	[thread overview]
Message-ID: <vfllz4ybue.fsf@rpc71.cs.man.ac.uk> (raw)
In-Reply-To: wzznnnbuv4.fsf@nono.cs.uu.nl

>>>>> "Piet" == Piet van Oostrum <piet@cs.uu.nl> writes:

>>>>> "Bingham, Jay" <Jay.Bingham@hp.com> (BJ) wrote:

  BJ> On Friday, March 21, 2003 12:23 PM Alan Shutko wrote:
  >>> Phillip Lord <p.lord@russet.org.uk> writes:

  >>> Specifically I want to write two commands. The first is "move
  >>> CWD of shell to the same as the file of the current buffer"
  >>> (currently you can achieve this, by killing the *shell* buffer,
  >>> and typing M-x shell). And secondly I want to be able to use the
  >>> ECB's (ecb.sourceforge.net) directory window, to move shells
  >>> CWD.

  Piet> [snip]

  BJ> I hope that this helps clarify his needs.

  Piet> I use myself a slightly different approach, which in fact
  Piet> might even be more confortable: I have a command that starts a
  Piet> shell in the current directory which encodes the directory
  Piet> name in the buffer name. If there is already a shell running
  Piet> in the current directory it uses that buffer rather than
  Piet> starting a new one.

*Stuff snipped*

Hmmm. I'm not sure. This might actually be more convenient that my
approach, although, its liable to result in a lot of shell buffers
open. I am not sure which is better. I normally only use a single
shell buffer, although this is generally so I can find it (with M-x
shell, or C-xC-b) quickly. This is why I always wanted a *shell*
buffer which I can use manually. 

Possible the solution is a bit of both. If I am navigating around a
Java source hierarchy, then probably I would want the single shell
approach, as generally you want a single shell window, with a single
shared history (full of "ant test" commands!). But if I am using
several directories with different things in (latex document in one,
java source in another, and various application launchers in a
third!), I'd probably want your approach. 

Anyway I put my cheesy and inadequate approach up on the board for
informational purposes. Maybe we should work this up into a more
general "select a shell with a specific directory" kind of package,
with in true emacs fashion, a vast and bewildering array of different
options. 

Cheers

Phil

ps sorry about the terrible "phil-" prefix, but I find it hard to come
up with non clashing, and yet still meaningful prefixes for all my
little fixes, and fiddles)


(global-set-key "\C-cd" 'phil-show-shift-shell-to-current-dir)

(defun phil-show-shift-shell-to-current-dir()
  (interactive)
  (phil-shift-shell-to-current-dir)
  (other-window 1)
  (switch-to-buffer "*shell*"))

(defun phil-shift-shell-to-current-dir()
  (interactive)
  (let ((file-name(buffer-file-name
                   (current-buffer))))
    (if (not file-name)
        (error "Current buffer is not associated with a file"))
    (phil-shift-shell-to-directory
     (file-name-directory file-name))))

(defun phil-shift-shell-to-directory(directory)
  (let* ((poss-shell (get-buffer "*shell*"))
        (shell-buffer
         (if poss-shell
             poss-shell
           (shell)))
        (shell-process 
         (get-buffer-process shell-buffer))
        (directory-string (concat "cd " directory "\n")))
    (save-excursion
      (set-buffer shell-buffer)
      (process-send-string 
       shell-process directory-string)
      (cd directory)
      (process-send-string 
       shell-process "pwd\n"))))

  reply	other threads:[~2003-03-24 16:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3489.1048272184.21513.help-gnu-emacs@gnu.org>
2003-03-21 19:53 ` shell mode, changing directory Alan Shutko
2003-03-22  9:42 ` Piet van Oostrum
2003-03-24 16:21   ` Phillip Lord [this message]
2003-03-21 18:40 Bingham, Jay
  -- strict thread matches above, loose matches on Subject: below --
2003-03-19 16:22 Phillip Lord
2003-03-21 16:18 ` Kevin Rodgers
2003-03-21 17:56   ` Phillip Lord
2003-03-21 18:11     ` Barry Margolin
2003-03-21 21:15     ` Kevin Rodgers
2003-03-24 12:40       ` Phillip Lord
2003-03-21 18:23 ` Alan Shutko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vfllz4ybue.fsf@rpc71.cs.man.ac.uk \
    --to=p.lord@russet.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.