[emacs-berlin] Automatic sudo

Tilmann Singer tils at tils.net
Wed Aug 26 20:27:10 UTC 2015


That's a cool idea! However my personal preference would be to trigger
it manually than have it automatically ask on keypress, and I would like
it to work dired somehow. Here is a variation that does that, requiring
to manually run "M-x sudo":

(defun sudo()
  "Re-open current file with sudo"
  (interactive)
  (let ((path (or
               (buffer-file-name)
               (and dired-directory (expand-file-name dired-directory))))
        (buff (current-buffer)))
    (when (not path) (error "No buffer file name or directory found to re-open with sudo"))
    (find-file (concat "/sudo:root at localhost:" path))
    (kill-buffer buff)))


Til
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20150826/33d37ebb/attachment.sig>


More information about the emacs-berlin mailing list