               (equal major-mode 'dired-mode)
               (not (file-exists-p (file-name-directory buffer-file-name)))
               (file-writable-p buffer-file-name))
-    (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
+    (prelude-find-alternate-file-as-root buffer-file-name)))
 
 (defun prelude-start-or-switch-to (function buffer-name)
   "Invoke FUNCTION if there is no buffer with BUFFER-NAME.

  (interactive)
  (byte-recompile-directory prelude-dir 0))

(require 'ido)
(defun prelude-sudo-edit (&optional arg)
  "Edit currently visited file as root.

  (if (or arg (not buffer-file-name))
      (find-file (concat "/sudo:root@localhost:"
                         (ido-read-file-name "Find file(as root): ")))
    (prelude-find-alternate-file-as-root buffer-file-name)))

(defadvice ido-find-file (after find-file-sudo activate)
  "Find file as root if necessary."
