unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* default-directory launched from Dock macOS
@ 2020-04-27  8:24 Tak Kunihiro
  2020-04-27 20:37 ` Perry Smith
  2020-04-28  4:47 ` Tak Kunihiro
  0 siblings, 2 replies; 12+ messages in thread
From: Tak Kunihiro @ 2020-04-27  8:24 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: tak.kunihiro

I want to launch emacs from Dock on macOS.

From scratch buffer on emacs 26.3, C-x C-f prompts home directory
"~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
root directory "/", which is inconvenient.  When I launch emacs
27.0.91 by `cd; emacs &`, C-x C-f prompts "~/".

Is there a good way to launch emacs 27.0.91 from Dock with
default-directory "~/"?



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

* Re: default-directory launched from Dock macOS
  2020-04-27  8:24 default-directory launched from Dock macOS Tak Kunihiro
@ 2020-04-27 20:37 ` Perry Smith
  2020-04-28  4:47 ` Tak Kunihiro
  1 sibling, 0 replies; 12+ messages in thread
From: Perry Smith @ 2020-04-27 20:37 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: help-gnu-emacs

I noticed this too but I wasn’t sure if it was because MacOS changed
or emacs changed because I changed both roughly at the same time.

Aside from doing something in the init.el startup file, I’m curious what
the others suggest.

> On Apr 27, 2020, at 3:24 AM, Tak Kunihiro <tak.kunihiro@gmail.com> wrote:
> 
> I want to launch emacs from Dock on macOS.
> 
> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
> root directory "/", which is inconvenient.  When I launch emacs
> 27.0.91 by `cd; emacs &`, C-x C-f prompts "~/".
> 
> Is there a good way to launch emacs 27.0.91 from Dock with
> default-directory "~/"?
> 




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

* Re: default-directory launched from Dock macOS
  2020-04-27  8:24 default-directory launched from Dock macOS Tak Kunihiro
  2020-04-27 20:37 ` Perry Smith
@ 2020-04-28  4:47 ` Tak Kunihiro
  2020-04-28  7:32   ` Eli Zaretskii
                     ` (2 more replies)
  1 sibling, 3 replies; 12+ messages in thread
From: Tak Kunihiro @ 2020-04-28  4:47 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: tak.kunihiro

From: 조성빈 <pcr910303@icloud.com>
Subject: Re: default-directory launched from Dock macOS
Date: Tue, 28 Apr 2020 08:37:33 +0900

>> I want to launch emacs from Dock on macOS.
>>
>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>> root directory "/", which is inconvenient.

> I also noticed this - I launch Emacs from spotlight, and it’s pretty
> inconvenient. Can anybody explain why the change happened?
> Was it explicit?

It's good to know I'm not the only one.


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

* Re: default-directory launched from Dock macOS
  2020-04-28  4:47 ` Tak Kunihiro
@ 2020-04-28  7:32   ` Eli Zaretskii
  2020-04-28  7:33   ` Carlo Tambuatco
  2020-04-28  7:46   ` default-directory launched from Dock macOS Nicolas Cavigneaux
  2 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2020-04-28  7:32 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 28 Apr 2020 13:47:10 +0900 (JST)
> From: Tak Kunihiro <tak.kunihiro@gmail.com>
> Cc: tak.kunihiro@gmail.com
> 
> From: 조성빈 <pcr910303@icloud.com>
> Subject: Re: default-directory launched from Dock macOS
> Date: Tue, 28 Apr 2020 08:37:33 +0900
> 
> >> I want to launch emacs from Dock on macOS.
> >>
> >> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
> >> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
> >> root directory "/", which is inconvenient.
> 
> > I also noticed this - I launch Emacs from spotlight, and it’s pretty
> > inconvenient. Can anybody explain why the change happened?
> > Was it explicit?
> 
> It's good to know I'm not the only one.

If you want this issue to be investigated and maybe fixed, please
submit a bug report with all the details.

Thanks.



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

* Re: default-directory launched from Dock macOS
  2020-04-28  4:47 ` Tak Kunihiro
  2020-04-28  7:32   ` Eli Zaretskii
@ 2020-04-28  7:33   ` Carlo Tambuatco
  2020-04-28  8:08     ` Tak Kunihiro
  2020-04-28  7:46   ` default-directory launched from Dock macOS Nicolas Cavigneaux
  2 siblings, 1 reply; 12+ messages in thread
From: Carlo Tambuatco @ 2020-04-28  7:33 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: help-gnu-emacs

When I set ‘initial-buffer-choice to anything other than default, for example my 
home directory “~/“, C-x C-f prompts that directory.

If I set it to “~/foo/bar”, C-x C-f will prompt ~/foo/bar.

Maybe try that?


> On Apr 28, 2020, at 12:47 AM, Tak Kunihiro <tak.kunihiro@gmail.com> wrote:
> 
> From: 조성빈 <pcr910303@icloud.com>
> Subject: Re: default-directory launched from Dock macOS
> Date: Tue, 28 Apr 2020 08:37:33 +0900
> 
>>> I want to launch emacs from Dock on macOS.
>>> 
>>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>>> root directory "/", which is inconvenient.
> 
>> I also noticed this - I launch Emacs from spotlight, and it’s pretty
>> inconvenient. Can anybody explain why the change happened?
>> Was it explicit?
> 
> It's good to know I'm not the only one.
> 




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

* Re: default-directory launched from Dock macOS
  2020-04-28  4:47 ` Tak Kunihiro
  2020-04-28  7:32   ` Eli Zaretskii
  2020-04-28  7:33   ` Carlo Tambuatco
@ 2020-04-28  7:46   ` Nicolas Cavigneaux
  2020-04-28 12:45     ` Perry Smith
  2020-05-04  2:06     ` Ben McGinnes
  2 siblings, 2 replies; 12+ messages in thread
From: Nicolas Cavigneaux @ 2020-04-28  7:46 UTC (permalink / raw)
  To: help-gnu-emacs

Tak Kunihiro <tak.kunihiro@gmail.com> writes:

> From: 조성빈 <pcr910303@icloud.com>
> Subject: Re: default-directory launched from Dock macOS
> Date: Tue, 28 Apr 2020 08:37:33 +0900
>
>>> I want to launch emacs from Dock on macOS.
>>>
>>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>>> root directory "/", which is inconvenient.
>
>> I also noticed this - I launch Emacs from spotlight, and it’s pretty
>> inconvenient. Can anybody explain why the change happened?
>> Was it explicit?
>
> It's good to know I'm not the only one.

Maybe it's related to how MacOS and Spotlight handle environment
variables when the app is launch by clicking its icon or using
spotlight.

There are good chance that your HOME environment variable is empty.

You can instruct MacOS about these environment variables by following a
post I wrote about it:

https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/

Hope this helps.
-- 
Nicolas Cavigneaux
http://www.bounga.org
http://www.cavigneaux.net




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

* Re: default-directory launched from Dock macOS
  2020-04-28  7:33   ` Carlo Tambuatco
@ 2020-04-28  8:08     ` Tak Kunihiro
  2020-04-28  8:24       ` 27.0.91; default-directory launched via Dock MacOS Tak Kunihiro
  0 siblings, 1 reply; 12+ messages in thread
From: Tak Kunihiro @ 2020-04-28  8:08 UTC (permalink / raw)
  To: Carlo Tambuatco; +Cc: help-gnu-emacs, 国広卓也

>>>> I want to launch emacs from Dock on macOS.
>>>> 
>>>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>>>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>>>> root directory "/", which is inconvenient.

> When I set ‘initial-buffer-choice to anything other than default, for example my 
> home directory “~/“, C-x C-f prompts that directory.

Thank you for the suggestion.  That does not change the response.
I will submit a bug report.




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

* 27.0.91; default-directory launched via Dock MacOS
  2020-04-28  8:08     ` Tak Kunihiro
@ 2020-04-28  8:24       ` Tak Kunihiro
  0 siblings, 0 replies; 12+ messages in thread
From: Tak Kunihiro @ 2020-04-28  8:24 UTC (permalink / raw)
  To: bug-gnu-emacs; +Cc: help-gnu-emacs, tak.kunihiro

I want to launch emacs via Dock or Spotlight on MacOS.

From scratch buffer on emacs 26.3, C-x C-f prompts home directory
"~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
root directory "/", which is inconvenient.

When emacs 27.0.91 is started in home directory, C-x C-f prompts
"~/", as expected.

I think that C-x C-f should prompt home directory "~/" instead of root
directory "/" when emacs is launched via Dock or Spotlight.  Since
that worked good until emacs 26.3, something was changed on emacs 27.

Can you store the behavior back?  I show the recipe below to reproduce
the problem.

 $ cd; mv .emacs.d dot.emacs.d
 click emacs 27.0.91 on Dock
 C-x b *scratch*
 C-x C-f ; => Find file: /
 M-x kill-emacs

 $ ./Downloads/emacs-27.0.91/nextstep/Emacs.app/Contents/MacOS/Emacs &
 C-x b *scratch*
 C-x C-f ; => Find file: ~/
 M-x kill-emacs

 click emacs 26.3 on Dock
 C-x b *scratch*
 C-x C-f ;=> Find file: ~/



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

* Re: default-directory launched from Dock macOS
  2020-04-28  7:46   ` default-directory launched from Dock macOS Nicolas Cavigneaux
@ 2020-04-28 12:45     ` Perry Smith
  2020-04-28 13:46       ` Nicolas Cavigneaux
  2020-05-04  2:06     ` Ben McGinnes
  1 sibling, 1 reply; 12+ messages in thread
From: Perry Smith @ 2020-04-28 12:45 UTC (permalink / raw)
  To: Nicolas Cavigneaux; +Cc: help-gnu-emacs



> On Apr 28, 2020, at 2:46 AM, Nicolas Cavigneaux <cavigneaux@gmail.com> wrote:
> 
> Tak Kunihiro <tak.kunihiro@gmail.com> writes:
> 
>> From: 조성빈 <pcr910303@icloud.com>
>> Subject: Re: default-directory launched from Dock macOS
>> Date: Tue, 28 Apr 2020 08:37:33 +0900
>> 
>>>> I want to launch emacs from Dock on macOS.
>>>> 
>>>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>>>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>>>> root directory "/", which is inconvenient.
>> 
>>> I also noticed this - I launch Emacs from spotlight, and it’s pretty
>>> inconvenient. Can anybody explain why the change happened?
>>> Was it explicit?
>> 
>> It's good to know I'm not the only one.
> 
> Maybe it's related to how MacOS and Spotlight handle environment
> variables when the app is launch by clicking its icon or using
> spotlight.
> 
> There are good chance that your HOME environment variable is empty.
> 
> You can instruct MacOS about these environment variables by following a
> post I wrote about it:
> 
> https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/
> 
> Hope this helps.

This sounded plausible but HOME is set to my HOME directory and USER is set to my user name.

It will be curious to learn what changed.





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

* Re: default-directory launched from Dock macOS
  2020-04-28 12:45     ` Perry Smith
@ 2020-04-28 13:46       ` Nicolas Cavigneaux
  2020-04-28 15:51         ` Perry Smith
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Cavigneaux @ 2020-04-28 13:46 UTC (permalink / raw)
  To: help-gnu-emacs

Perry Smith <pedz@easesoftware.com> writes:

>> On Apr 28, 2020, at 2:46 AM, Nicolas Cavigneaux <cavigneaux@gmail.com> wrote:
>> 
>> Tak Kunihiro <tak.kunihiro@gmail.com> writes:
>> 
>>> From: 조성빈 <pcr910303@icloud.com>
>>> Subject: Re: default-directory launched from Dock macOS
>>> Date: Tue, 28 Apr 2020 08:37:33 +0900
>>> 
>>>>> I want to launch emacs from Dock on macOS.
>>>>> 
>>>>> From scratch buffer on emacs 26.3, C-x C-f prompts home directory
>>>>> "~/".  However, from scratch buffer on emacs 27.0.91, C-x C-f prompts
>>>>> root directory "/", which is inconvenient.
>>> 
>>>> I also noticed this - I launch Emacs from spotlight, and it’s pretty
>>>> inconvenient. Can anybody explain why the change happened?
>>>> Was it explicit?
>>> 
>>> It's good to know I'm not the only one.
>> 
>> Maybe it's related to how MacOS and Spotlight handle environment
>> variables when the app is launch by clicking its icon or using
>> spotlight.
>> 
>> There are good chance that your HOME environment variable is empty.
>> 
>> You can instruct MacOS about these environment variables by following a
>> post I wrote about it:
>> 
>> https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/
>> 
>> Hope this helps.
>
> This sounded plausible but HOME is set to my HOME directory and USER is set to my user name.

In your shell or in launchd?

Launchd is responsible for the environment variables your GUI apps
(launched by clicking their icon or using Spotlight) have access to.

> It will be curious to learn what changed.

If my theory is right, previous Emacs versions were doing some black
magic to find your home even if the HOME environment variable wasn't set
and new version doesn't try anymore and defaults to "/".
-- 
Nicolas Cavigneaux
http://www.bounga.org
http://www.cavigneaux.net




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

* Re: default-directory launched from Dock macOS
  2020-04-28 13:46       ` Nicolas Cavigneaux
@ 2020-04-28 15:51         ` Perry Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Perry Smith @ 2020-04-28 15:51 UTC (permalink / raw)
  To: Nicolas Cavigneaux; +Cc: help-gnu-emacs



> On Apr 28, 2020, at 8:46 AM, Nicolas Cavigneaux <cavigneaux@gmail.com> wrote:
> 
> Perry Smith <pedz@easesoftware.com> writes:
> 
>> 
>> This sounded plausible but HOME is set to my HOME directory and USER is set to my user name.
> 
> In your shell or in launchd?

via launchd (open from the dock)

And that makes sense because launchd knows who owns the process.  e.g. the UID of Emacs is my user, not root.

    -+= 00001 root /sbin/launchd
     \-+= 00811 pedz /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_14
       \--= 15598 pedz /usr/local/bin/aspell -a -m -B --encoding=utf-8




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

* Re: default-directory launched from Dock macOS
  2020-04-28  7:46   ` default-directory launched from Dock macOS Nicolas Cavigneaux
  2020-04-28 12:45     ` Perry Smith
@ 2020-05-04  2:06     ` Ben McGinnes
  1 sibling, 0 replies; 12+ messages in thread
From: Ben McGinnes @ 2020-05-04  2:06 UTC (permalink / raw)
  To: Nicolas Cavigneaux; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]

On Tue, Apr 28, 2020 at 09:46:17AM +0200, Nicolas Cavigneaux wrote:
> 
> Maybe it's related to how MacOS and Spotlight handle environment
> variables when the app is launch by clicking its icon or using
> spotlight.

It could be, but OS X has been doing weird things with that for a
while, and not just with paths.

> There are good chance that your HOME environment variable is empty.
> 
> You can instruct MacOS about these environment variables by following a
> post I wrote about it:
> 
> https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/

That's an interesting solution, but there are a couple of others.

One option for use entirely within Emacs with elisp is this:

    https://github.com/purcell/exec-path-from-shell

I took a slightly different approach for launching Emacs from the Dock
that would inherit environmental variables and one or two other things
(including several, preconfigured Emacs server options), by making a
handful of these:

    https://github.com/adversary-org/emacs-launcher-osx

My solution is a bit more configurable since it's basically just
stripped down app container with just the Emacs icon and a shell
script to run a few things (like "source ~/.bashrc"), sometimes set
custom variables, and then launch Emacs.  Most of these are also set
to launch an Emacs server (with various applications configured to use
the relevant corresponding client).

Most of the time these[1] these all behave exactly as expected.


Regards,
Ben

 1. I'd say "all," but Murphy's Law dictates that it would break the
    moment I made the claim, so I won't.  😉

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2020-05-04  2:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-27  8:24 default-directory launched from Dock macOS Tak Kunihiro
2020-04-27 20:37 ` Perry Smith
2020-04-28  4:47 ` Tak Kunihiro
2020-04-28  7:32   ` Eli Zaretskii
2020-04-28  7:33   ` Carlo Tambuatco
2020-04-28  8:08     ` Tak Kunihiro
2020-04-28  8:24       ` 27.0.91; default-directory launched via Dock MacOS Tak Kunihiro
2020-04-28  7:46   ` default-directory launched from Dock macOS Nicolas Cavigneaux
2020-04-28 12:45     ` Perry Smith
2020-04-28 13:46       ` Nicolas Cavigneaux
2020-04-28 15:51         ` Perry Smith
2020-05-04  2:06     ` Ben McGinnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).