all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Go to my CWD!
@ 2010-01-27 17:44 Andrea Crotti
  2010-01-27 19:38 ` Andreas Röhler
  2010-01-28  2:17 ` Kevin Rodgers
  0 siblings, 2 replies; 6+ messages in thread
From: Andrea Crotti @ 2010-01-27 17:44 UTC (permalink / raw)
  To: help-gnu-emacs

Whenever I have a shell or another interpreter of course they keep
they're own current directory, which is given from the first time I've
launched them.

But if I for example call
M-x shell 
again it means that I want the shell in the directory of the current
buffer, not that old forgotten position.

That's also true for python interpreter or any other interpreter, is
there a way to solve this problem automatically?

Maybe a second call should kill and restart instead of visiting the
already open?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Go to my CWD!
  2010-01-27 17:44 Go to my CWD! Andrea Crotti
@ 2010-01-27 19:38 ` Andreas Röhler
  2010-01-27 21:08   ` Andrea Crotti
  2010-01-28  2:17 ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Röhler @ 2010-01-27 19:38 UTC (permalink / raw)
  To: Andrea Crotti; +Cc: help-gnu-emacs

Andrea Crotti wrote:
> Whenever I have a shell or another interpreter of course they keep
> they're own current directory, which is given from the first time I've
> launched them.
>
> But if I for example call
> M-x shell 
> again it means that I want the shell in the directory of the current
> buffer, not that old forgotten position.
>
> That's also true for python interpreter or any other interpreter, is
> there a way to solve this problem automatically?
>   

Maybe that way?:

(defun my-shell-always-in-default-dir ()
(interactive)
(shell default-directory))

Cheers

Andreas
> Maybe a second call should kill and restart instead of visiting the
> already open?
>
>
>
>
>   






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Go to my CWD!
  2010-01-27 19:38 ` Andreas Röhler
@ 2010-01-27 21:08   ` Andrea Crotti
  2010-01-27 21:30     ` Andreas Röhler
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Crotti @ 2010-01-27 21:08 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> Andrea Crotti wrote:
> Maybe that way?:
>
> (defun my-shell-always-in-default-dir ()
> (interactive)
> (shell default-directory))
>
> Cheers
>

Nice thanks that would work, but then I have to setup a wrapper for
every possible interpreter (octave, python etc etc...)
Something more automatic is not possible?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Go to my CWD!
  2010-01-27 21:08   ` Andrea Crotti
@ 2010-01-27 21:30     ` Andreas Röhler
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2010-01-27 21:30 UTC (permalink / raw)
  To: help-gnu-emacs

Andrea Crotti wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>   
>> Andrea Crotti wrote:
>> Maybe that way?:
>>
>> (defun my-shell-always-in-default-dir ()
>> (interactive)
>> (shell default-directory))
>>
>> Cheers
>>
>>     
>
> Nice thanks that would work, but then I have to setup a wrapper for
> every possible interpreter (octave, python etc etc...)
> Something more automatic is not possible?
>
>
>
>
>   

its quite easy to change the function shell for your needs. the
beginning reads

  (interactive
   (list
    (and current-prefix-arg
     (prog1
         (read-buffer "Shell buffer: "
              (generate-new-buffer-name "*shell*"))
       (if (file-remote-p default-directory)
           ;; It must be possible to declare a local default-directory.
           (setq default-directory
             (expand-file-name
              (read-file-name
               "Default directory: " default-directory default-directory
               t nil 'file-directory-p))))))))


you see the user is queried and our default-directory also will be
delivered per default

To automatize this, just introduce a variable Yes-I-will, ask for it at
the right place(s),
get your extension excuted instead         (read-file-name

BTW think its worth a feature request at emacs-devel

Andreas











^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Go to my CWD!
  2010-01-27 17:44 Go to my CWD! Andrea Crotti
  2010-01-27 19:38 ` Andreas Röhler
@ 2010-01-28  2:17 ` Kevin Rodgers
  2010-01-28  9:02   ` Andreas Röhler
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2010-01-28  2:17 UTC (permalink / raw)
  To: help-gnu-emacs

Andrea Crotti wrote:
> Whenever I have a shell or another interpreter of course they keep
> they're own current directory, which is given from the first time I've
> launched them.
> 
> But if I for example call
> M-x shell 
> again it means that I want the shell in the directory of the current
> buffer, not that old forgotten position.

`C-u M-x shell RET' will give you a new shell buffer named *shell*<2>
whose default directory is the same as the buffer from which you called
it.  Subsequent shells will be named *shell*<3>, *shell*<4>, *shell*<5>
etc.

> That's also true for python interpreter or any other interpreter, is
> there a way to solve this problem automatically?

No, each interpreter starts comint in its own way.

> Maybe a second call should kill and restart instead of visiting the
> already open?

Happy hacking,

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Go to my CWD!
  2010-01-28  2:17 ` Kevin Rodgers
@ 2010-01-28  9:02   ` Andreas Röhler
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2010-01-28  9:02 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers wrote:
> Andrea Crotti wrote:
>> Whenever I have a shell or another interpreter of course they keep
>> they're own current directory, which is given from the first time I've
>> launched them.
>>
>> But if I for example call
>> M-x shell again it means that I want the shell in the directory of
>> the current
>> buffer, not that old forgotten position.
>
> `C-u M-x shell RET' will give you a new shell buffer named *shell*<2>
> whose default directory is the same as the buffer from which you called
> it.  
Storing it as a keyboard-macro, naming the macro, binding it to a key,
probably is better solution than having a separate function for it.

Andreas


> Subsequent shells will be named *shell*<3>, *shell*<4>, *shell*<5>
> etc.
>
>> That's also true for python interpreter or any other interpreter, is
>> there a way to solve this problem automatically?
>
> No, each interpreter starts comint in its own way.
>
>> Maybe a second call should kill and restart instead of visiting the
>> already open?
>
> Happy hacking,
>





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-28  9:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27 17:44 Go to my CWD! Andrea Crotti
2010-01-27 19:38 ` Andreas Röhler
2010-01-27 21:08   ` Andrea Crotti
2010-01-27 21:30     ` Andreas Röhler
2010-01-28  2:17 ` Kevin Rodgers
2010-01-28  9:02   ` Andreas Röhler

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.