diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-11 12:35:09 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-11 12:35:09 +0100 |
| commit | 6abf9fd7ab5875ee167004aa8d99f8a04a1a67b0 (patch) | |
| tree | 6b39db46523ca8149e139fe65b36f8f4658b53bc | |
| parent | d2576df00c6dbdca8eb13c615c915daf9328fa1c (diff) | |
emacs: Support editing files via doas/sudo
| -rw-r--r-- | .config/emacs/modules/mm-editing.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index 73b29a6..2ae4107 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -426,4 +426,17 @@ is as described by `emmet-expand-line'." (use-package subword :hook prog-mode) + +;;; Edit Files via Doas/Sudo + +(defvar mm-root-editing-program + (if (string= (system-name) "mangobox") "doas" "sudo")) + +(defun mm-edit-root-protected-file-buffer () + (interactive) + (when (and buffer-file-name (not (file-writable-p buffer-file-name))) + (find-alternate-file (format "/%s:root@localhost:%s" + mm-root-editing-program + buffer-file-name)))) + (provide 'mm-editing) |