mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
Refactor doom/sudo-find-file, add doom/sudo-this-file
This commit is contained in:
@ -1,12 +1,19 @@
|
|||||||
;;; editor.el
|
;;; editor.el
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/sudo-find-file ()
|
(defun doom/sudo-find-file (file)
|
||||||
"Open a file as root."
|
"Open a file as root."
|
||||||
|
(interactive
|
||||||
|
(list (read-file-name "Open as root: ")))
|
||||||
|
(find-file (if (file-writable-p file)
|
||||||
|
file
|
||||||
|
(concat "/sudo:root@localhost:" file))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom/sudo-this-file ()
|
||||||
|
"Open the current file as root."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((file (read-file-name "Open as root: ")))
|
(doom/sudo-find-file (file-truename buffer-file-name)))
|
||||||
(unless (file-writable-p file)
|
|
||||||
(find-file (concat "/sudo:root@localhost:" file)))))
|
|
||||||
|
|
||||||
(defun doom--goto-first-non-blank ()
|
(defun doom--goto-first-non-blank ()
|
||||||
(beginning-of-visual-line)
|
(beginning-of-visual-line)
|
||||||
|
Reference in New Issue
Block a user