GNU bug report logs - #73728
29.3; Specifing an --alternate-editor for emacscleintw.exe with custom --init-directory does not work on Windows

Previous Next

Package: emacs;

Reported by: Jonas Großekathöfer <jonas <at> grszkth.fr>

Date: Thu, 10 Oct 2024 10:56:01 UTC

Severity: normal

Found in version 29.3

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jonas Großekathöfer <jonas <at> grszkth.fr>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 73728 <at> debbugs.gnu.org
Subject: bug#73728: 29.3; Specifing an --alternate-editor for emacscleintw.exe with custom --init-directory does not work on Windows
Date: Thu, 10 Oct 2024 14:32:30 +0200
[Message part 1 (text/plain, inline)]
Am 2024-10-10 13:39, schrieb Eli Zaretskii:

>> Date: Thu, 10 Oct 2024 08:56:43 +0200
>> From:  Jonas Großekathöfer via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> I want emacsclientw.exe to start up an emacs daemon with a custom 
>> --init-directory in case no server is
>> running. For that case, I think, I need to explicitly set the value 
>> for the "--alternate-editor"-flag to something
>> like:
>> 
>> -a "%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory
>> %APPDATA%\Dotfiles\emacs\.emacs.d\"
> 
> Can you explain why you need a custom --init-directory in that case?

Quality of life improvement: I have my configs online in a git-repo. I 
manage the dotfiles on my Linux machine with stow. On my Windows machine 
I want Emacs to follow that structure. As such I want to link to the 
config via --init-directory, so that I can place the Dotfiles-Folder 
where ever I want. However, I can't place the Dotfiles folder so, that 
the ".emacs.d/"-folder ends up under the parent "~/" as well.

I already tried a route via tangling to different targets for Linux and 
Windows. But that introduced other problems... so I decided to follow 
this route. Seems the most straightforward to me actually. For the start 
I decided to place it under "~/" on Windows as well. As such I ended up 
with that specific location. But AFAICT my problem is location agnostic.

I am open to suggestions if I am missing the super obvious solution 
here. (:

>> However, doing so results in the following error: "file name or 
>> argument required". This is also true when
>> specifing a relative path (i.e. AppData\Dotfiles\emacs\.emacs.d\).
>> 
>> After some more trials with single and/or double qoutes (details see 
>> below), I got the impression that this
>> behavior is unlikely intentional. And I am somewhat confident, that 
>> more then one oy my many attempts
>> should've been successful. (Note that I raised this issue first here:
>> https://emacs.stackexchange.com/a/82355/30098)
>> 
>> For completeness, the full comand ("Target") I am trying to run is:
>> 
>> %UserProfile%\bin\emacs-29.3\bin\emacsclientw.exe -a 
>> '%UserProfile%\bin\emacs-29.3\bin\runemacs.exe -
>> -init-directory "AppData\Dotfiles\emacs\.emacs.d\"' -n -c 
>> --server-file
>> %APPDATA%\Dotfiles\emacs\.emacs.d\server\server
>> 
>> that command starts in
>> 
>> %UserProfile%
>> 
>> ATM, I have as a work around a shortcut to emacscleintw.exe without an 
>> -a flag. Before using it, I once have
>> to run:
>> 
>> %UserProfile%\bin\emacs-29.3\bin\runemacs.exe --daemon 
>> ----init-directory
>> %APPDATA%\Dotfiles\emacs\.emacs.d\
>> 
>> Obviously, I would rather have to have it all in one place.
>> 
>> And here are the Details, regarding the use of quotes with or without 
>> relative path for --init-directory:
>> 
>> For the several options using quotes, I got the following problems, 
>> depending on whether I put single or
>> double quoutes for the whole argument or just the path:
>> 
>> Double quotes around the argmument and single quotes for the path, 
>> using the full path:
>> 
>> -a "%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory
>> '%APPDATA%\Dotfiles\emacs\.emacs.d\'"
>> 
>> --> Warning: "Warning (initialization): Unable to create 
>> `user-emacs-directory'
>> (c:/Users/gross20/'C:/Users/gross20/AppData/Roaming/Dotfiles/emacs/.emacs.d/'/)."
>> 
>> Single quotes around the argmument and double quotes for the path, 
>> using the full path:
>> 
>> -a '%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory
>> "%APPDATA%\Dotfiles\emacs\.emacs.d\"'
>> 
>> --> Error: Try --help for more information
>> 
>> Double quotes around the argmument and single quotes for the path, 
>> using a relative path:
>> 
>> -a "%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory
>> 'AppData\Roaming\Dotfiles\emacs\.emacs.d\'"
>> 
>> --> Strarts without errors or warning, but the user-emacs-directory is
>> "c:/Users/XXX/'AppData/Roaming/Dotfiles/emacs/.emacs.d/'/" (Note the 
>> single quote in the folder name for
>> AppData)
>> 
>> Single quotes around the argmument and single quotes for the path, 
>> using a relative path:
>> 
>> -a '%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory 
>> "AppData\Dotfiles\emacs\.emacs.d\"'
>> 
>> --> Error: Try --help for more information
> 
> Don't use single quotes, they are not supported by Windows.
> 
> But I admit I don't understand why you needed nested quotes at all.
> What happens if you use double quotes around the entire argument of
> the -a option?

Do you mean like how in the first example I gave?

-a "%UserProfile%\bin\emacs-29.3\bin\runemacs.exe --init-directory 
%AppData%\Dotfiles\emacs\.emacs.d\"

That one gives "file name or Argument required. Try --help"

Best
Jonas
[Message part 2 (text/html, inline)]

This bug report was last modified 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.