* M-x shell question
@ 2016-08-17 17:45 Richard Stallman
2016-08-17 18:09 ` raman
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Richard Stallman @ 2016-08-17 17:45 UTC (permalink / raw)
To: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
I'm thinking that M-x shell should cd the subshell
to the current directory of the buffer you're in
when you type M-x shell. I often want to do that.
Or perhaps C-u M-x shell should do that.
The current behavior of C-u M-x shell, to use a different buffer name
for the shell buffer, is not very useful; if you want to make multiple
shell buffers, the easiest way is to make each one as *shell* and
rename it.
Is anyone against?
--
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 17:45 M-x shell question Richard Stallman
@ 2016-08-17 18:09 ` raman
2016-08-17 19:04 ` Uwe Brauer
2016-08-18 14:07 ` Richard Stallman
2016-08-17 19:12 ` Robert Weiner
2016-08-17 20:24 ` Andreas Schwab
2 siblings, 2 replies; 22+ messages in thread
From: raman @ 2016-08-17 18:09 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel
Richard Stallman <rms@gnu.org> writes:
1+ -- I implemented myself a different shell command specifically for
this case and bound it to a key:
(defun emacspeak-wizards-shell-toggle ()
"Switch to the shell buffer and cd to
the directory of the current buffer."
(interactive)
(declare (special default-directory))
(let ((dir default-directory))
(shell)
(unless (string-equal (expand-file-name dir)
(expand-file-name default-directory))
(goto-char (point-max))
(insert (format "pushd %s" dir))
(comint-send-input)
(shell-process-cd dir))
(emacspeak-auditory-icon 'select-object)
(emacspeak-speak-mode-line)))
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> I'm thinking that M-x shell should cd the subshell
> to the current directory of the buffer you're in
> when you type M-x shell. I often want to do that.
>
> Or perhaps C-u M-x shell should do that.
>
> The current behavior of C-u M-x shell, to use a different buffer name
> for the shell buffer, is not very useful; if you want to make multiple
> shell buffers, the easiest way is to make each one as *shell* and
> rename it.
>
> Is anyone against?
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 18:09 ` raman
@ 2016-08-17 19:04 ` Uwe Brauer
2016-08-17 21:13 ` raman
2016-08-18 14:07 ` Richard Stallman
1 sibling, 1 reply; 22+ messages in thread
From: Uwe Brauer @ 2016-08-17 19:04 UTC (permalink / raw)
To: emacs-devel
>>> "raman" == raman <raman@google.com> writes:
> Richard Stallman <rms@gnu.org> writes:
> 1+ -- I implemented myself a different shell command specifically for
> this case and bound it to a key:
That function depends on emacspeak, why?
> (defun emacspeak-wizards-shell-toggle () > "Switch to the shell buffer and cd to
> the directory of the current buffer."
> (interactive)
> (declare (special default-directory))
What is this declare call good for?
> (let ((dir default-directory))
> (shell)
> (unless (string-equal (expand-file-name dir)
> (expand-file-name default-directory))
> (goto-char (point-max))
> (insert (format "pushd %s" dir))
> (comint-send-input)
> (shell-process-cd dir))
> (emacspeak-auditory-icon 'select-object)
> (emacspeak-speak-mode-line)))
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 18:09 ` raman
2016-08-17 19:04 ` Uwe Brauer
@ 2016-08-18 14:07 ` Richard Stallman
2016-08-18 14:13 ` Fwd: " Kaushal Modi
` (3 more replies)
1 sibling, 4 replies; 22+ messages in thread
From: Richard Stallman @ 2016-08-18 14:07 UTC (permalink / raw)
To: raman; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Your function seems to do basically what I want (I think cd is better
than pushd for this). I've put it in my .emacs, but I think it should
be a standard feature -- perhaps as M-x cdshell.
Does anyone disagree?
--
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Fwd: M-x shell question
2016-08-18 14:07 ` Richard Stallman
@ 2016-08-18 14:13 ` Kaushal Modi
2016-08-19 5:29 ` Richard Stallman
2016-08-18 14:22 ` Oleh Krehel
` (2 subsequent siblings)
3 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2016-08-18 14:13 UTC (permalink / raw)
To: rms@gnu.org, Emacs developers; +Cc: raman
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
Following the convention of keeping the package name as the first part of
the command name, may be the command should be named 'shell-cd'?
---------- Forwarded message ---------
From: Richard Stallman <rms@gnu.org>
Date: Thu, Aug 18, 2016 at 10:07 AM
Subject: Re: M-x shell question
To: raman <raman@google.com>
Cc: <emacs-devel@gnu.org>
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Your function seems to do basically what I want (I think cd is better
than pushd for this). I've put it in my .emacs, but I think it should
be a standard feature -- perhaps as M-x cdshell.
Does anyone disagree?
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 1195 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-18 14:13 ` Fwd: " Kaushal Modi
@ 2016-08-19 5:29 ` Richard Stallman
2016-08-19 5:49 ` Kaushal Modi
2016-08-19 7:16 ` Eli Zaretskii
0 siblings, 2 replies; 22+ messages in thread
From: Richard Stallman @ 2016-08-19 5:29 UTC (permalink / raw)
To: Kaushal Modi; +Cc: raman, emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> Following the convention of keeping the package name as the first part of
> the command name, may be the command should be named 'shell-cd'?
That name is logical, but inconvenient: you have to type s h e SPC SPC c d.
'shell-this-directory' is almost as inconvenient: s h e SPC SPC t.
--
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 5:29 ` Richard Stallman
@ 2016-08-19 5:49 ` Kaushal Modi
2016-08-19 7:18 ` Eli Zaretskii
2016-08-19 13:21 ` Robert Weiner
2016-08-19 7:16 ` Eli Zaretskii
1 sibling, 2 replies; 22+ messages in thread
From: Kaushal Modi @ 2016-08-19 5:49 UTC (permalink / raw)
To: rms; +Cc: raman, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]
On Fri, Aug 19, 2016 at 1:29 AM Richard Stallman <rms@gnu.org> wrote:
> That name is logical, but inconvenient: you have to type s h e SPC SPC c d.
>
> 'shell-this-directory' is almost as inconvenient: s h e SPC SPC t.
>
I believe that keeping package name as first part of the command improves
discoverability. If I were to look into what all commands are available
related to 'shell', I can easily come across 'shell-cd' or 'shell-foo'
with packages like ido or counsel or helm and start using it. But if the
command is 'cd-shell', that reduces the discoverability (unless you have
the fuzzy search enabled in packages like ido).
I would just bind 'shell-cd' to a binding (like "C-c d s" maybe? :) ), if I
find myself using it very often. But naming it 'cd-shell' just so that it
comes up with lesser chars to type for guessing the right command doesn't
seem like a permanent solution to access that command quickly. What if
tomorrow we have more commands starting with 'cds'? Again, having
'cd-shell' show up as the best match for 'c d s' is very subjective. It is
very useful to people using 'cd-shell' or 'shell-cd' regularly, but
probably not to others.
What do you think?
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 1728 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 5:49 ` Kaushal Modi
@ 2016-08-19 7:18 ` Eli Zaretskii
2016-08-19 13:21 ` Robert Weiner
1 sibling, 0 replies; 22+ messages in thread
From: Eli Zaretskii @ 2016-08-19 7:18 UTC (permalink / raw)
To: Kaushal Modi; +Cc: emacs-devel, rms, raman
> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Fri, 19 Aug 2016 05:49:15 +0000
> Cc: raman@google.com, emacs-devel@gnu.org
>
> On Fri, Aug 19, 2016 at 1:29 AM Richard Stallman <rms@gnu.org> wrote:
>
> That name is logical, but inconvenient: you have to type s h e SPC SPC c d.
>
> 'shell-this-directory' is almost as inconvenient: s h e SPC SPC t.
>
> I believe that keeping package name as first part of the command improves discoverability. If I were to look
> into what all commands are available related to 'shell', I can easily come across 'shell-cd' or 'shell-foo' with
> packages like ido or counsel or helm and start using it. But if the command is 'cd-shell', that reduces the
> discoverability (unless you have the fuzzy search enabled in packages like ido).
>
> I would just bind 'shell-cd' to a binding (like "C-c d s" maybe? :) ), if I find myself using it very often.
We could also have an alias for faster typing.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 5:49 ` Kaushal Modi
2016-08-19 7:18 ` Eli Zaretskii
@ 2016-08-19 13:21 ` Robert Weiner
2016-08-19 14:14 ` Kaushal Modi
1 sibling, 1 reply; 22+ messages in thread
From: Robert Weiner @ 2016-08-19 13:21 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 523 bytes --]
On Fri, Aug 19, 2016 at 1:49 AM, Kaushal Modi <kaushal.modi@gmail.com>
wrote:
> But if the command is 'cd-shell', that reduces the discoverability
Just use {M-x apropos RET} which will find either 'cd' or 'shell'. There
is no need to use add-on packages for this. Many Emacs command names still
use a verb-noun ordering rather than a prefix-verb ordering, so in that
sense, cd-shell works fine. This could just be an alias as well if all of
the other shell related commands start with shell-.
Bob
[-- Attachment #2: Type: text/html, Size: 1128 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 13:21 ` Robert Weiner
@ 2016-08-19 14:14 ` Kaushal Modi
2016-08-19 14:35 ` Robert Weiner
0 siblings, 1 reply; 22+ messages in thread
From: Kaushal Modi @ 2016-08-19 14:14 UTC (permalink / raw)
To: rswgnu, emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 1097 bytes --]
On Fri, Aug 19, 2016 at 9:22 AM Robert Weiner <rsw@gnu.org> wrote:
> On Fri, Aug 19, 2016 at 1:49 AM, Kaushal Modi <kaushal.modi@gmail.com>
> wrote:
>
>> But if the command is 'cd-shell', that reduces the discoverability
>
>
> Just use {M-x apropos RET} which will find either 'cd' or 'shell'.
> There is no need to use add-on packages for this. Many Emacs command names
> still use a verb-noun ordering rather than a prefix-verb ordering, so in
> that sense, cd-shell works fine. This could just be an alias as well if
> all of the other shell related commands start with shell-.
>
It all boils down to your workflow .. Instead of doing M-x apropos or M-x
apropos-command and go through 10's or 100's of results, I prefer using
counsel-M-x from the counsel package. Below shows me all commands that
begin with 'shell'. Note that I intentionally use regexp here.. I have
"^shell" instead of just "shell", so it shows me only the commands that
begin with "shell". Once I have that list, I pick one and hit return.
That's it.
[image: pasted1]
--
Kaushal Modi
[-- Attachment #1.2: Type: text/html, Size: 2017 bytes --]
[-- Attachment #2: pasted1 --]
[-- Type: image/png, Size: 36273 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 14:14 ` Kaushal Modi
@ 2016-08-19 14:35 ` Robert Weiner
2016-08-19 14:45 ` Kaushal Modi
0 siblings, 1 reply; 22+ messages in thread
From: Robert Weiner @ 2016-08-19 14:35 UTC (permalink / raw)
To: Kaushal Modi; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
On Fri, Aug 19, 2016 at 10:14 AM, Kaushal Modi <kaushal.modi@gmail.com>
wrote:
> I wrote: This could just be an alias as well if all of the other shell
>> related commands start with shell-.
>>
>
> I have "^shell" instead of just "shell", so it shows me only the commands
> that begin with "shell". Once I have that list, I pick one and hit return.
> That's it.
>
A
propos accepts regular expressions as well, so you don't need counsel to
get similar behavior. As I said, one of the command names could start with
shell-.
Bob
[-- Attachment #2: Type: text/html, Size: 1717 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 14:35 ` Robert Weiner
@ 2016-08-19 14:45 ` Kaushal Modi
0 siblings, 0 replies; 22+ messages in thread
From: Kaushal Modi @ 2016-08-19 14:45 UTC (permalink / raw)
To: rswgnu; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
On Fri, Aug 19, 2016 at 10:36 AM Robert Weiner <rsw@gnu.org> wrote:
> On Fri, Aug 19, 2016 at 10:14 AM, Kaushal Modi <kaushal.modi@gmail.com>
> wrote:
>
>> I wrote: This could just be an alias as well if all of the other shell
>>> related commands start with shell-.
>>>
>>
>> I have "^shell" instead of just "shell", so it shows me only the commands
>> that begin with "shell". Once I have that list, I pick one and hit return.
>> That's it.
>>
>
> A
> propos accepts regular expressions as well, so you don't need counsel to
> get similar behavior. As I said, one of the command names could start with
> shell-.
>
As I said, it's preference. I meant to emphasize this in my previous email:
I prefer:
*Once I have that list, I pick one and hit return. That's it.*
I like the speed:
http://i.imgur.com/OP1RR8c.gifv
rather than:
1. M-x apropos-command (or C-h a)
2. Find the command I want after scrolling through a possible multi-page
buffer
3. M-x command-I-found
4. Repeat 1-2 till I find the right command
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 3241 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Fwd: M-x shell question
2016-08-19 5:29 ` Richard Stallman
2016-08-19 5:49 ` Kaushal Modi
@ 2016-08-19 7:16 ` Eli Zaretskii
1 sibling, 0 replies; 22+ messages in thread
From: Eli Zaretskii @ 2016-08-19 7:16 UTC (permalink / raw)
To: rms; +Cc: raman, emacs-devel, kaushal.modi
> From: Richard Stallman <rms@gnu.org>
> Date: Fri, 19 Aug 2016 01:29:41 -0400
> Cc: raman@google.com, emacs-devel@gnu.org
>
> > Following the convention of keeping the package name as the first part of
> > the command name, may be the command should be named 'shell-cd'?
>
> That name is logical, but inconvenient: you have to type s h e SPC SPC c d.
s-cd should also work. (Welcome to the improved completion in Emacs
24.)
> 'shell-this-directory' is almost as inconvenient: s h e SPC SPC t.
You can use s-thi instead.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-18 14:07 ` Richard Stallman
2016-08-18 14:13 ` Fwd: " Kaushal Modi
@ 2016-08-18 14:22 ` Oleh Krehel
2016-08-18 15:11 ` Andreas Schwab
2016-08-18 15:27 ` raman
3 siblings, 0 replies; 22+ messages in thread
From: Oleh Krehel @ 2016-08-18 14:22 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel
Richard Stallman <rms@gnu.org> writes:
> Your function seems to do basically what I want (I think cd is better
> than pushd for this). I've put it in my .emacs, but I think it should
> be a standard feature -- perhaps as M-x cdshell.
>
> Does anyone disagree?
I like the idea. I do the same thing in two steps in my config:
1. "C-x C-j" calls `dired-jump' globally.
2. "`" calls `cdshell' in `dired-mode'.
This way, I can quickly adjust the path in `dired'.
Oleh
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-18 14:07 ` Richard Stallman
2016-08-18 14:13 ` Fwd: " Kaushal Modi
2016-08-18 14:22 ` Oleh Krehel
@ 2016-08-18 15:11 ` Andreas Schwab
2016-08-19 2:53 ` Tino Calancha
2016-08-18 15:27 ` raman
3 siblings, 1 reply; 22+ messages in thread
From: Andreas Schwab @ 2016-08-18 15:11 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel, raman
On Aug 18 2016, Richard Stallman <rms@gnu.org> wrote:
> Your function seems to do basically what I want (I think cd is better
> than pushd for this). I've put it in my .emacs, but I think it should
> be a standard feature -- perhaps as M-x cdshell.
shell-this-directory
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-18 15:11 ` Andreas Schwab
@ 2016-08-19 2:53 ` Tino Calancha
0 siblings, 0 replies; 22+ messages in thread
From: Tino Calancha @ 2016-08-19 2:53 UTC (permalink / raw)
To: Andreas Schwab; +Cc: raman, Richard Stallman, emacs-devel
On Thu, 18 Aug 2016, Andreas Schwab wrote:
> shell-this-directory
+1
On Thu, 18 Aug 2016, raman wrote:
> after landing in the shell if I didn't want to be in the directory
> of the buffer from whence I came, then the most common thing I wanted
> was to go back to where it had been.
It has sense.
How about a new option controling if pushd or cd is used?
For instance: shell-this-directory-push-or-cd
Tino
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-18 14:07 ` Richard Stallman
` (2 preceding siblings ...)
2016-08-18 15:11 ` Andreas Schwab
@ 2016-08-18 15:27 ` raman
3 siblings, 0 replies; 22+ messages in thread
From: raman @ 2016-08-18 15:27 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel
I went back and forth with respect to pushd vs cd when I wrote this
(approx 10+ years ago from memory).
I stayed with pushd after changing back and forth because I found
that after landing in the shell if I didn't want to be in the directory
of the buffer from whence I came, then the most common thing I wanted
was to go back to where it had been.
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 17:45 M-x shell question Richard Stallman
2016-08-17 18:09 ` raman
@ 2016-08-17 19:12 ` Robert Weiner
2016-08-17 20:24 ` Andreas Schwab
2 siblings, 0 replies; 22+ messages in thread
From: Robert Weiner @ 2016-08-17 19:12 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1269 bytes --]
On Wed, Aug 17, 2016 at 1:45 PM, Richard Stallman <rms@gnu.org> wrote:
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> I'm thinking that M-x shell should cd the subshell
> to the current directory of the buffer you're in
> when you type M-x shell. I often want to do that.
>
It does do that when it creates a new shell buffer. Typically, that is
the only time I want it to do that as I work with buffers in many different
directories and then come back to the same shell that I want pointing to
the same directory.
>
> Or perhaps C-u M-x shell should do that.
>
> The current behavior of C-u M-x shell, to use a different buffer name
> for the shell buffer, is not very useful; if you want to make multiple
> shell buffers, the easiest way is to make each one as *shell* and
> rename it.
>
I like being able to quickly create multiple shells without having to
rename them, so I do think this behavior is useful.
I think a new command would be appropriate in this case that did both the
cd and the jump to the shell buffer, maybe cd-shell.
Bob
[-- Attachment #2: Type: text/html, Size: 2538 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 17:45 M-x shell question Richard Stallman
2016-08-17 18:09 ` raman
2016-08-17 19:12 ` Robert Weiner
@ 2016-08-17 20:24 ` Andreas Schwab
2016-08-18 3:51 ` Roland Winkler
2016-08-18 14:06 ` Richard Stallman
2 siblings, 2 replies; 22+ messages in thread
From: Andreas Schwab @ 2016-08-17 20:24 UTC (permalink / raw)
To: Richard Stallman; +Cc: emacs-devel
On Aug 17 2016, Richard Stallman <rms@gnu.org> wrote:
> I'm thinking that M-x shell should cd the subshell
> to the current directory of the buffer you're in
> when you type M-x shell. I often want to do that.
Emacs doesn't know what the shell is currently running, sending a cd
command may not do what you want.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 20:24 ` Andreas Schwab
@ 2016-08-18 3:51 ` Roland Winkler
2016-08-18 14:06 ` Richard Stallman
1 sibling, 0 replies; 22+ messages in thread
From: Roland Winkler @ 2016-08-18 3:51 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
On Wed, Aug 17 2016, Andreas Schwab wrote:
> Emacs doesn't know what the shell is currently running, sending a cd
> command may not do what you want.
For many years I have been using the command below. If the shell
appears to be busy, this command puts "cd dir" into the input history,
which makes the shell command available via comint-previous-input.
(defun my-shell (&optional buffer)
"Use `default-directory' of current buffer as working dir of `*shell*' buffer.
Also, switch to `*shell*' buffer.
Optional arg BUFFER has same meaning as for command `shell'."
(interactive ; code taken from `shell'
(list
(if current-prefix-arg
(read-buffer "Shell buffer: "
(generate-new-buffer-name "*shell*")))))
(unless default-directory
(error "default-directory of current buffer is nil"))
(let ((edir (expand-file-name default-directory))
(cdir (concat "cd " (abbreviate-file-name default-directory))))
(shell (get-buffer-create (or buffer "*shell*")))
;; change directory, unless we are already where we want to be
(unless (string= edir (expand-file-name default-directory))
(goto-char (point-max))
(if (looking-back comint-prompt-regexp nil)
(progn (insert cdir)
(comint-send-input))
(message "shell `%s' seems to be busy, cannot change directory"
(buffer-name))
(comint-add-to-input-history cdir)))))
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: M-x shell question
2016-08-17 20:24 ` Andreas Schwab
2016-08-18 3:51 ` Roland Winkler
@ 2016-08-18 14:06 ` Richard Stallman
1 sibling, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2016-08-18 14:06 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> Emacs doesn't know what the shell is currently running, sending a cd
> command may not do what you want.
That's true, but it's a problem only if plain M-x shell is the way to
do this. If the user explicitly says when to do this, the user
will judge when.
--
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2016-08-19 14:45 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17 17:45 M-x shell question Richard Stallman
2016-08-17 18:09 ` raman
2016-08-17 19:04 ` Uwe Brauer
2016-08-17 21:13 ` raman
2016-08-18 14:07 ` Richard Stallman
2016-08-18 14:13 ` Fwd: " Kaushal Modi
2016-08-19 5:29 ` Richard Stallman
2016-08-19 5:49 ` Kaushal Modi
2016-08-19 7:18 ` Eli Zaretskii
2016-08-19 13:21 ` Robert Weiner
2016-08-19 14:14 ` Kaushal Modi
2016-08-19 14:35 ` Robert Weiner
2016-08-19 14:45 ` Kaushal Modi
2016-08-19 7:16 ` Eli Zaretskii
2016-08-18 14:22 ` Oleh Krehel
2016-08-18 15:11 ` Andreas Schwab
2016-08-19 2:53 ` Tino Calancha
2016-08-18 15:27 ` raman
2016-08-17 19:12 ` Robert Weiner
2016-08-17 20:24 ` Andreas Schwab
2016-08-18 3:51 ` Roland Winkler
2016-08-18 14:06 ` Richard Stallman
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.