From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Phillip Lord Newsgroups: gmane.emacs.help Subject: Re: shell mode, changing directory Date: 24 Mar 2003 16:21:29 +0000 Organization: BIOSCI/MRC Human Genome Mapping Project Resource Centre Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1048523220 22106 80.91.224.249 (24 Mar 2003 16:27:00 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 24 Mar 2003 16:27:00 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 24 17:26:59 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18xUmp-0005kN-00 for ; Mon, 24 Mar 2003 17:26:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18xUlC-0007S6-06 for gnu-help-gnu-emacs@m.gmane.org; Mon, 24 Mar 2003 11:25:18 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.uchicago.edu!logbridge.uoregon.edu!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!server1.netnews.ja.net!hgmp.mrc.ac.uk!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 95 Original-NNTP-Posting-Host: bromine.hgmp.mrc.ac.uk Original-X-Trace: niobium.hgmp.mrc.ac.uk 1048522889 24249 193.62.192.35 (24 Mar 2003 16:21:29 GMT) Original-X-Complaints-To: news@net.bio.net Original-NNTP-Posting-Date: Mon, 24 Mar 2003 16:21:29 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93 Original-Xref: shelby.stanford.edu gnu.emacs.help:111347 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:7849 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:7849 >>>>> "Piet" == Piet van Oostrum writes: >>>>> "Bingham, Jay" (BJ) wrote: BJ> On Friday, March 21, 2003 12:23 PM Alan Shutko wrote: >>> Phillip Lord 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"))))