1
0
emacs-config/others-utils/emacsredux.el

12 lines
554 B
EmacsLisp
Raw Normal View History

2021-02-08 05:03:36 -05:00
;;; 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))))