renard/dired-toggle-sudo — Issue #1: Opening the current file with sudo
Author: DamienCassou
Created: 2011-11-22 12:08:57+00:00
State: open

Hi,

I found this version somewhere on the web a long time ago and thought it might be a good addition to your package. Sure, it's not related to dired, but the idea is the same. Moreover, this function could benefit from dired-toggle-sudo code which looks more robust:

``` Lisp
(defun find-alternative-file-with-sudo ()
(interactive)
(let ((fname (or buffer-file-name
dired-directory)))
(when fname
(if (string-match "^/sudo:root@localhost:" fname)
(setq fname (replace-regexp-in-string
"^/sudo:root@localhost:" ""
fname))
(setq fname (concat "/sudo:root@localhost:" fname)))
(find-alternate-file fname))))
```