[emacs-berlin] Automatic sudo
arne.brasseur at gmail.com
Mon Aug 24 10:01:40 UTC 2015
I would love to get some feedback on this snippet. What it does is,
whenever you try to type in a read-only buffer, it will ask if you want to
re-open the file with sudo. I think it's pretty cool, and it turned out to
be relatively easy to set up.
(defadvice self-insert-command (around automagic-sudo activate)
(let ((path (buffer-file-name))
(when (and path (y-or-n-p "File is read-only, reopen with sudo?"))
(find-file (concat "/sudo:root at localhost:" path))
The only downside I've noticed so far is that e.g. pressing enter does not
work, because that issues the command "newline" instead of
"self-insert-command". You could of course repeat this snippet for newline,
and indent-for-tab-command, etc. Does anyone have a better idea?
| @plexus <https://twitter.com/plexus> | arnebrasseur.net | The Happy
Lambda <https://leanpub.com/happylambda> |
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the emacs-berlin