Re: Why does emacs lack non-tramp tools to find files as sudo?
Jean Louis <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Organization | GNU Support |
| Message-ID | <[email protected]> |
On 2026-04-08 10:26, BP25 wrote:
> Emacs is the most complete and modern editor out there. How can it lack
> "innate" (non tramp) facilities to edit files as superuser?
You're correct. Emacs has no built-in, non-Tramp way to edit a file as
superuser with a simple command like M-x sudo-find-file or C-c C-s
/etc/hosts.
With Tramp:
;; This works out of the box:
C-x C-f /sudo::/etc/hosts
;; Or shorter:
C-x C-f /su::/etc/hosts
This is not "non-innate" - Tramp is part of Emacs core since long time.
I think there is no alternative to it technically. It needs privileged
subprocess, and Tramp is doing it well.
You can make it invisible:
(defun sudo-find-file (file)
(interactive "FOpen as root: ")
(let ((tramp-display-syntax nil)) ; If such a variable existed
(find-file (concat "/sudo::" file))))
--
Jean Louis