mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-16 15:56:52 -05:00
Bind 'SPC b u' to save current file as root
This commit is contained in:
@@ -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)))))
|
||||
|
Reference in New Issue
Block a user