Bind 'SPC b u' to save current file as root
This commit is contained in:
parent
a28de332fc
commit
f04af0b8a2
2 changed files with 13 additions and 0 deletions
|
@ -341,3 +341,15 @@ file if it exists, without confirmation."
|
|||
"Open the current file as root."
|
||||
(interactive)
|
||||
(find-alternate-file (doom--sudo-file buffer-file-name)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/sudo-save-buffer ()
|
||||
"Save this file as root."
|
||||
(interactive)
|
||||
(let ((origin (current-buffer))
|
||||
(buffer (doom--sudo-file buffer-file-name)))
|
||||
(unwind-protect
|
||||
(with-current-buffer buffer
|
||||
(save-buffer))
|
||||
(unless (eq origin buffer)
|
||||
(kill-buffer buffer)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue