Setup: Xubuntu 16.04, GNU Emacs

I have the following function defined.

(defun sudo-edit (&optional arg)
  "Edit currently visited file as root.

With a prefix ARG prompt for a file to visit.
Will also prompt for a file to visit if current
buffer is not visiting a file."
  (interactive "P")
  (if (or arg (not buffer-file-name))
      (find-file (concat "/sudo:root@localhost:"
                         (ido-read-file-name "Find file(as root): ")))
    (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))

When I want to edit /etc/default/grub, and in the GUI Emacs frame I call sudo-edit, after typing my password, it works fine. But when I do the same with the emacsclient in terminal, it exits directly to the terminal after calling the same sudo-edit. And it's not responding anymore, and I cannot create another frame.

I fail to understand why Emacs is not handling this properly in terminal, and the GUI frame does it well. I couldn't find anything in the function which is related to the GUI.

Anybody that can find where this functions went wrong with the terminal Emacs?

  • Is the password prompt a GUI window? Or something you type in the minibuffer? – Kaushal Modi Aug 10 '16 at 18:45
  • @KaushalModi In the minibuffer. Have you tried it? – ReneFroger Aug 10 '16 at 22:50
  • I have not tried, and I cannot.. Can't sudo on work machine. – Kaushal Modi Aug 10 '16 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.