12 lines
554 B
EmacsLisp
12 lines
554 B
EmacsLisp
|
;;; Edit files as root
|
||
|
;; https://emacsredux.com/blog/2013/04/21/edit-files-as-root/
|
||
|
(defun emacsredux-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:"
|
||
|
(read-file-name "Find file(as root): ")))
|
||
|
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
|