sudo-edit
sudo-edit copied to clipboard
Emacslient closes whenever i call sudo-edit
I run emacs as a server, and running sudo-edit
closes emacs whenever I run it. It doesn't crash or alter emacs in anyway, it's only that I'm back at my shell and have to rerun my emacs command. I can then edit the files as a sudo user like normal.
I can't reproduce this; can you give full instructions on how to reproduce starting from a clean (-q) emacs server?
~~Can't reproduce with a clean server either, I'll try and see what the problem is.~~ Oddly enough running
emacs-26.1 --daemon -q
does now trigger the undesired behavior described in my first post. The same goes for emacs with my whole init.el file commented out. (I'm running the stable emacs from the Arch Linux repos btw, I don't remember whether I had this problem on macOS as well, but I could check)
Disregard my previous comment, running emacs-26.1 --daemon -q
and then manually loading sudo-edit.el seems to work now. Nevertheless, commenting my whole init.el still displays the problematic behavior outlined above when invoking M-x sudo-edit
. @nflath any ideas?
Possibly something in your .emacs?
On Tue, Oct 16, 2018 at 4:19 AM Rijnder Wever [email protected] wrote:
Disregard my previous comment, running emacs-26.1 --daemon -q and then manually loading sudo-edit.el seems to work now. Nevertheless, commenting my whole init.el still displays problematic behavior when invoking M-x sudo-edit. @nflath https://github.com/nflath any ideas?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nflath/sudo-edit/issues/21#issuecomment-430199397, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC2817pmrcPAWUrZMIKC8dldbzQcLaTks5ulcCqgaJpZM4WgAVD .
Same problem here. It seems to close if opening in a terminal, but just hangs if on a separate frame. All instances hang, but C-g brings it back. Any thoughts?
I also still experience this. If I find the time, I'll try nflaths suggestion and see if something in my global .emacs folder is causing the problem, as I already established that the problem seems to persist when commenting out all of my init.el (probably not, given that it is not super populated). @someonewithpc does the problem still persist when you comment out all of your init.el and then load sudo-edit manually?
As a work around, I now generally use this function/alias E
(which pairs nicely with aliasing emacs
to e
) to do my sudo edits:
function E
env SUDO_EDITOR="emacsclient -t -a emacs" sudoedit $argv
end
(fish syntax, but conversion to bash should be trivial)
I can reproduce this with no .emacs
or .emacs.d
at all. I’m using Emacs 27.1. For reproduction, it’s important that I specify the file on the emacsclient
command line.
-
emacs --daemon
-
emacsclient -c /etc/fstab
-
M-x load-library /path/to/sudo-edit.el
-
M-x sudo-edit
causesemacsclient
to close.
Some variants that might help shed light on what’s going on:
- If I open two
emacsclient
s to different files in step 2, then step 4 closes the currentemacsclient
, prompts for thesudo
password in the other one, and opens the current file there. - If I open two
emacsclient
s to the same file in step 2, then step 4 closes them both. - If I visit a different file with
C-x C-f
before invokingsudo-edit
, it doesn’t close anything and works as expected.
Related: https://emacs.stackexchange.com/questions/59541/prevent-dired-find-alternate-file-from-killing-emacsclient
I think the problem is with the function find-alternate-file
, but I don't know why:
-
emacs --daemon -q
-
emacsclient -c /etc/fstab
- And
M-x eval-expression
this(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))