* how to not change the working directory when opening a file
@ 2008-01-14 15:15 Francis Moreau
2008-01-14 23:17 ` Eric Hanchrow
0 siblings, 1 reply; 16+ messages in thread
From: Francis Moreau @ 2008-01-14 15:15 UTC (permalink / raw)
To: help-gnu-emacs
Hello list,
I'd like Emacs to not changing the working directory when opening
a file.
For example when doing:
$ pwd
/home/fmoreau/tmp
$ emacs /tmp/foo.txt
I'd like the current working directory to be "/home/fmoreau/tmp"
when editing "/tmp/foo.txt" in emacs.
This is useful when composing an email. I sometime need to
include the output of a shell command but this shell command
must be executed in the directory where emacs was launched.
Does anybody can give me a hint to do that ?
Thanks
--
Francis
PS: Please CC me when replying since I'm not subscribed.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-14 15:15 how to not change the working directory when opening a file Francis Moreau
@ 2008-01-14 23:17 ` Eric Hanchrow
2008-01-15 0:21 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 16+ messages in thread
From: Eric Hanchrow @ 2008-01-14 23:17 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> "Francis" == Francis Moreau <francis.moro@gmail.com> writes:
Francis> Hello list, I'd like Emacs to not changing the working
Francis> directory when opening a file.
Francis> For example when doing:
Francis> $ pwd /home/fmoreau/tmp $ emacs /tmp/foo.txt
Francis> I'd like the current working directory to be
Francis> "/home/fmoreau/tmp" when editing "/tmp/foo.txt" in emacs.
Francis> This is useful when composing an email. I sometime need
Francis> to include the output of a shell command but this shell
Francis> command must be executed in the directory where emacs was
Francis> launched.
Francis> Does anybody can give me a hint to do that ?
I can't think of an easy way. If it were me, I'd just prepend a "cd"
command to the shell command, like this:
C-u M-! cd ~/yow ; ls RET
--
I shrivel inside each time [Star Wars] is mentioned.
-- Sir Alec Guinness
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-14 23:17 ` Eric Hanchrow
@ 2008-01-15 0:21 ` Lennart Borgman (gmail)
2008-01-15 9:27 ` Francis Moreau
0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman (gmail) @ 2008-01-15 0:21 UTC (permalink / raw)
Cc: help-gnu-emacs
>>>>>> "Francis" == Francis Moreau <francis.moro@gmail.com> writes:
>
> Francis> Hello list, I'd like Emacs to not changing the working
> Francis> directory when opening a file.
>
> Francis> For example when doing:
>
> Francis> $ pwd /home/fmoreau/tmp $ emacs /tmp/foo.txt
>
> Francis> I'd like the current working directory to be
> Francis> "/home/fmoreau/tmp" when editing "/tmp/foo.txt" in emacs.
>
> Francis> This is useful when composing an email. I sometime need
> Francis> to include the output of a shell command but this shell
> Francis> command must be executed in the directory where emacs was
> Francis> launched.
>
> Francis> Does anybody can give me a hint to do that ?
Can't you use the variable default-directory? Ie do
M-: (setq default-directory "/my-full-dir-path/")
when you are in that files buffer.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 0:21 ` Lennart Borgman (gmail)
@ 2008-01-15 9:27 ` Francis Moreau
2008-01-15 15:13 ` Eric Hanchrow
0 siblings, 1 reply; 16+ messages in thread
From: Francis Moreau @ 2008-01-15 9:27 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: help-gnu-emacs
Hello,
On Jan 15, 2008 1:21 AM, Lennart Borgman (gmail)
<lennart.borgman@gmail.com> wrote:
> >>>>>> "Francis" == Francis Moreau <francis.moro@gmail.com> writes:
> >
> > Francis> Hello list, I'd like Emacs to not changing the working
> > Francis> directory when opening a file.
> >
> > Francis> For example when doing:
> >
> > Francis> $ pwd /home/fmoreau/tmp $ emacs /tmp/foo.txt
> >
> > Francis> I'd like the current working directory to be
> > Francis> "/home/fmoreau/tmp" when editing "/tmp/foo.txt" in emacs.
> >
> > Francis> This is useful when composing an email. I sometime need
> > Francis> to include the output of a shell command but this shell
> > Francis> command must be executed in the directory where emacs was
> > Francis> launched.
> >
> > Francis> Does anybody can give me a hint to do that ?
>
> Can't you use the variable default-directory? Ie do
>
> M-: (setq default-directory "/my-full-dir-path/")
>
> when you are in that files buffer.
>
Yes something like this may work.
But I need to set 'default-directory' to the directory where emacs was
launched. I don't want to set a fixed path.
Actually I'm using mutt as MUA and use emacs as editor inside mutt.
When I compose an email mutt basically does the following to start
emacs:
emacs -nw /tmp/mutt-file -f post-mode
So I'm using "post" mode to compose my email. I could create a post
mode hook to change 'default-directory' value but i don't know how to
specify "the directory where emacs was launched".
I could change mutt's email file path to the current directory but I
would prefer not to and let its temporary directory in /tmp which is
the default configuration.
Thanks
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 9:27 ` Francis Moreau
@ 2008-01-15 15:13 ` Eric Hanchrow
2008-01-15 15:53 ` Francis Moreau
0 siblings, 1 reply; 16+ messages in thread
From: Eric Hanchrow @ 2008-01-15 15:13 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> "Francis" == Francis Moreau <francis.moro@gmail.com> writes:
Francis> When I compose an email mutt basically does the following
Francis> to start emacs:
Francis> emacs -nw /tmp/mutt-file -f post-mode
Francis> ... i don't know how to specify "the directory where
Francis> emacs was launched".
I imagine you could simply put this in your .emacs:
(setq emacs-startup-directory default-directory)
Then your hook could refer to emacs-startup-directory.
--
I hope to get back to work on Arc soon.
-- Paul Graham, quoted in "ACM Crossroads", no date given
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 15:13 ` Eric Hanchrow
@ 2008-01-15 15:53 ` Francis Moreau
2008-01-15 16:25 ` Sebastian Tennant
0 siblings, 1 reply; 16+ messages in thread
From: Francis Moreau @ 2008-01-15 15:53 UTC (permalink / raw)
To: Eric Hanchrow; +Cc: help-gnu-emacs
On Jan 15, 2008 4:13 PM, Eric Hanchrow <offby1@blarg.net> wrote:
> I imagine you could simply put this in your .emacs:
>
> (setq emacs-startup-directory default-directory)
>
> Then your hook could refer to emacs-startup-directory.
>
Yes.
I added this to my .emacs:
(add-hook 'post-mode-hook '(lambda () (setq default-directory
emacs-startup-directory)))
and it does the right thing now although I'm really not sure about the
syntax I used.
Thanks
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 15:53 ` Francis Moreau
@ 2008-01-15 16:25 ` Sebastian Tennant
2008-01-15 17:16 ` Francis Moreau
0 siblings, 1 reply; 16+ messages in thread
From: Sebastian Tennant @ 2008-01-15 16:25 UTC (permalink / raw)
To: help-gnu-emacs
Quoth "Francis Moreau" <francis.moro@gmail.com>:
> (add-hook 'post-mode-hook '(lambda () (setq default-directory emacs-startup-directory)))
If it works go with it. It's also a more focussed solution than:
(cd (getenv "PWD"))
in that it only applies to post-mode, although my 'getenv' solution is
perhaps more flexible in that Emacs' default directory at startup will
always be the directory you launched Emacs from, rather than the value
of emacs-startup-directory.
Just for your information, you shouldn't really quote lambda functions,
i.e., you should remove the single quote before (lambda ...).
Quoting lambda functions happens to work in Emacs Lisp but won't work in
other Lisp dialects, so it's not a good habit to get into.
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 16:25 ` Sebastian Tennant
@ 2008-01-15 17:16 ` Francis Moreau
0 siblings, 0 replies; 16+ messages in thread
From: Francis Moreau @ 2008-01-15 17:16 UTC (permalink / raw)
To: Sebastian Tennant; +Cc: help-gnu-emacs
On Jan 15, 2008 5:25 PM, Sebastian Tennant <sebyte@smolny.plus.com> wrote:
> Quoth "Francis Moreau" <francis.moro@gmail.com>:
> > (add-hook 'post-mode-hook '(lambda () (setq default-directory emacs-startup-directory)))
>
> If it works go with it. It's also a more focussed solution than:
>
> (cd (getenv "PWD"))
>
> in that it only applies to post-mode, although my 'getenv' solution is
> perhaps more flexible in that Emacs' default directory at startup will
> always be the directory you launched Emacs from, rather than the value
> of emacs-startup-directory.
>
> Just for your information, you shouldn't really quote lambda functions,
> i.e., you should remove the single quote before (lambda ...).
>
> Quoting lambda functions happens to work in Emacs Lisp but won't work in
> other Lisp dialects, so it's not a good habit to get into.
>
For for this information. I actually don't know elisp at all...
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
* How to not change the working directory when opening a file
@ 2008-01-14 21:13 Francis Moreau
2008-01-15 16:16 ` Sebastian Tennant
2008-01-16 2:56 ` Kevin Rodgers
0 siblings, 2 replies; 16+ messages in thread
From: Francis Moreau @ 2008-01-14 21:13 UTC (permalink / raw)
To: help-gnu-emacs
Hello list,
I'd like Emacs to not changing the working directory when opening
a file.
For example when doing:
$ pwd
/home/fmoreau/tmp
$ emacs /tmp/foo.txt
I'd like the current working directory to be "/home/fmoreau/tmp"
when editing "/tmp/foo.txt" in emacs.
This is useful when composing an email. I sometime need to
include the output of a shell command but this shell command
must be executed in the directory where emacs was launched.
Does anybody can give me a hint to do that ?
Thanks
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How to not change the working directory when opening a file
2008-01-14 21:13 How " Francis Moreau
@ 2008-01-15 16:16 ` Sebastian Tennant
2008-01-16 2:56 ` Kevin Rodgers
1 sibling, 0 replies; 16+ messages in thread
From: Sebastian Tennant @ 2008-01-15 16:16 UTC (permalink / raw)
To: help-gnu-emacs
Quoth "Francis Moreau" <francis.moro@gmail.com>:
> $ pwd
> /home/fmoreau/tmp
> $ emacs /tmp/foo.txt
>
> I'd like the current working directory to be "/home/fmoreau/tmp"
> when editing "/tmp/foo.txt" in emacs.
Perhaps putting this at the end of your ~/.emacs:
(cd (getenv "PWD"))
I haven't tested this, but it might do it.
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How to not change the working directory when opening a file
2008-01-14 21:13 How " Francis Moreau
2008-01-15 16:16 ` Sebastian Tennant
@ 2008-01-16 2:56 ` Kevin Rodgers
2008-01-16 6:35 ` Francis Moreau
1 sibling, 1 reply; 16+ messages in thread
From: Kevin Rodgers @ 2008-01-16 2:56 UTC (permalink / raw)
To: help-gnu-emacs
Francis Moreau wrote:
> Hello list,
>
> I'd like Emacs to not changing the working directory when opening
> a file.
>
> For example when doing:
>
> $ pwd
> /home/fmoreau/tmp
> $ emacs /tmp/foo.txt
>
> I'd like the current working directory to be "/home/fmoreau/tmp"
> when editing "/tmp/foo.txt" in emacs.
>
> This is useful when composing an email. I sometime need to
> include the output of a shell command but this shell command
> must be executed in the directory where emacs was launched.
>
> Does anybody can give me a hint to do that ?
(add-hook 'find-file-hook
(lambda ()
(setq default-directory
(buffer-local-value 'default-directory
(get-buffer "*scratch*")))))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How to not change the working directory when opening a file
2008-01-16 2:56 ` Kevin Rodgers
@ 2008-01-16 6:35 ` Francis Moreau
0 siblings, 0 replies; 16+ messages in thread
From: Francis Moreau @ 2008-01-16 6:35 UTC (permalink / raw)
To: Kevin Rodgers; +Cc: help-gnu-emacs
On Jan 16, 2008 3:56 AM, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:
>
> Francis Moreau wrote:
> > Hello list,
> >
> > I'd like Emacs to not changing the working directory when opening
> > a file.
> >
> > For example when doing:
> >
> > $ pwd
> > /home/fmoreau/tmp
> > $ emacs /tmp/foo.txt
> >
> > I'd like the current working directory to be "/home/fmoreau/tmp"
> > when editing "/tmp/foo.txt" in emacs.
> >
> > This is useful when composing an email. I sometime need to
> > include the output of a shell command but this shell command
> > must be executed in the directory where emacs was launched.
> >
> > Does anybody can give me a hint to do that ?
>
> (add-hook 'find-file-hook
> (lambda ()
> (setq default-directory
> (buffer-local-value 'default-directory
> (get-buffer "*scratch*")))))
Looks even better to me !
Thanks
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <mailman.6126.1200343901.18990.help-gnu-emacs@gnu.org>]
* Re: how to not change the working directory when opening a file
[not found] <mailman.6126.1200343901.18990.help-gnu-emacs@gnu.org>
@ 2008-01-15 8:02 ` Thien-Thi Nguyen
2008-01-15 9:29 ` Francis Moreau
0 siblings, 1 reply; 16+ messages in thread
From: Thien-Thi Nguyen @ 2008-01-15 8:02 UTC (permalink / raw)
To: francis.moro; +Cc: gnu-emacs-help
() "Francis Moreau" <francis.moro@gmail.com>
() Mon, 14 Jan 2008 16:15:54 +0100
This is useful when composing an email. I sometime need to
include the output of a shell command but this shell command
must be executed in the directory where emacs was launched.
you can try something like: emacs --insert /tmp/foo.txt -f text-mode
alternatively, you can try: emacs -f compose-mail
and then `C-x i /tmp/foo.txt RET' at a later point.
probably best if you invert your flow to live in emacs, in
which case you can use `C-u M-! SHELL-COMMAND RET' as needed.
thi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 8:02 ` how " Thien-Thi Nguyen
@ 2008-01-15 9:29 ` Francis Moreau
2008-01-15 15:11 ` Thierry Volpiatto
0 siblings, 1 reply; 16+ messages in thread
From: Francis Moreau @ 2008-01-15 9:29 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: gnu-emacs-help
Hello,
On Jan 15, 2008 9:02 AM, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
> () "Francis Moreau" <francis.moro@gmail.com>
> () Mon, 14 Jan 2008 16:15:54 +0100
>
> This is useful when composing an email. I sometime need to
> include the output of a shell command but this shell command
> must be executed in the directory where emacs was launched.
>
> you can try something like: emacs --insert /tmp/foo.txt -f text-mode
> alternatively, you can try: emacs -f compose-mail
> and then `C-x i /tmp/foo.txt RET' at a later point.
>
Yes but once I need to really save /tmp/foo.txt after composing my
email, I need to specify /tmp/foo.txt. It's not convenient and foo.txt
is a temporary file so its name is rather complex to remember.
> probably best if you invert your flow to live in emacs, in
> which case you can use `C-u M-! SHELL-COMMAND RET' as needed.
I prefer using mutt as MUA.
Thanks
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 9:29 ` Francis Moreau
@ 2008-01-15 15:11 ` Thierry Volpiatto
2008-01-15 15:25 ` Francis Moreau
0 siblings, 1 reply; 16+ messages in thread
From: Thierry Volpiatto @ 2008-01-15 15:11 UTC (permalink / raw)
To: Francis Moreau; +Cc: gnu-emacs-help, Thien-Thi Nguyen
"Francis Moreau" <francis.moro@gmail.com> writes:
> Hello,
>
> On Jan 15, 2008 9:02 AM, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
>> () "Francis Moreau" <francis.moro@gmail.com>
>> () Mon, 14 Jan 2008 16:15:54 +0100
>>
>> This is useful when composing an email. I sometime need to
>> include the output of a shell command but this shell command
>> must be executed in the directory where emacs was launched.
>>
>> you can try something like: emacs --insert /tmp/foo.txt -f text-mode
>> alternatively, you can try: emacs -f compose-mail
>> and then `C-x i /tmp/foo.txt RET' at a later point.
>>
>
> Yes but once I need to really save /tmp/foo.txt after composing my
> email, I need to specify /tmp/foo.txt. It's not convenient and foo.txt
> is a temporary file so its name is rather complex to remember.
>
>> probably best if you invert your flow to live in emacs, in
>> which case you can use `C-u M-! SHELL-COMMAND RET' as needed.
>
> I prefer using mutt as MUA.
How do you use mutt ?
if you set your env variable EDITOR to emacsclient
(or a script launching emacsclient) you can edit your mail in an
existing session of emacs (or open emacs if it's not already launched)
and use all the features of emacs when editing mails.
--
A + Thierry
Pub key: http://pgp.mit.edu
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to not change the working directory when opening a file
2008-01-15 15:11 ` Thierry Volpiatto
@ 2008-01-15 15:25 ` Francis Moreau
0 siblings, 0 replies; 16+ messages in thread
From: Francis Moreau @ 2008-01-15 15:25 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: gnu-emacs-help, Thien-Thi Nguyen
On Jan 15, 2008 4:11 PM, Thierry Volpiatto <thierry.volpiatto@gmail.com> wrote:
> How do you use mutt ?
In my ~/.muttrc, I put:
set editor = "emacs -nw %s -f post-mode"
> if you set your env variable EDITOR to emacsclient
> (or a script launching emacsclient) you can edit your mail in an
> existing session of emacs (or open emacs if it's not already launched)
> and use all the features of emacs when editing mails.
>
Well, I just want emacs to not change the default directory when
editing an email. It's really simple and IMHO the right thing to do
when opening an outgoing email.
BTW, vi does that.
--
Francis
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-01-16 6:35 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-14 15:15 how to not change the working directory when opening a file Francis Moreau
2008-01-14 23:17 ` Eric Hanchrow
2008-01-15 0:21 ` Lennart Borgman (gmail)
2008-01-15 9:27 ` Francis Moreau
2008-01-15 15:13 ` Eric Hanchrow
2008-01-15 15:53 ` Francis Moreau
2008-01-15 16:25 ` Sebastian Tennant
2008-01-15 17:16 ` Francis Moreau
-- strict thread matches above, loose matches on Subject: below --
2008-01-14 21:13 How " Francis Moreau
2008-01-15 16:16 ` Sebastian Tennant
2008-01-16 2:56 ` Kevin Rodgers
2008-01-16 6:35 ` Francis Moreau
[not found] <mailman.6126.1200343901.18990.help-gnu-emacs@gnu.org>
2008-01-15 8:02 ` how " Thien-Thi Nguyen
2008-01-15 9:29 ` Francis Moreau
2008-01-15 15:11 ` Thierry Volpiatto
2008-01-15 15:25 ` Francis Moreau
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.