* problems with tramp
@ 2006-02-16 18:33 Kirill Kuvaldin
0 siblings, 0 replies; only message in thread
From: Kirill Kuvaldin @ 2006-02-16 18:33 UTC (permalink / raw)
Hello!
I want to open files with sudo using tramp, but the suggestions from
http://www.emacswiki.org/cgi-bin/wiki/TrampMode didn't help me.
I've put the following code into my ~/.emacs:
(defvar find-file-root-prefix (if (featurep 'xemacs) "/[sudo/root@localhost]" "/sudo:root@localhost:" )
"*The filename prefix used to open a file with `find-file-root'.")
(defvar find-file-root-history nil
"History list for files found using `find-file-root'.")
(defvar find-file-root-hook nil
"Normal hook for functions to run after finding a \"root\" file.")
(defun find-file-root ()
"*Open a file as the root user.
Prepends `find-file-root-prefix' to the selected file name so that it
maybe accessed via the corresponding tramp method."
(interactive)
(require 'tramp)
(let* (;; We bind the variable `file-name-history' locally so we can
;; use a separate history list for "root" files.
(file-name-history find-file-root-history)
(name (or buffer-file-name default-directory))
(tramp (and (tramp-tramp-file-p name)
(tramp-dissect-file-name name)))
path dir file)
;; If called from a "root" file, we need to fix up the path.
(when tramp
(setq path (tramp-file-name-path tramp)
dir (file-name-directory path)))
(when (setq file (read-file-name "Find file (UID = 0): " dir path))
(find-file (concat find-file-root-prefix file))
;; If this all succeeded save our new history list.
(setq find-file-root-history file-name-history)
;; allow some user customization
(run-hooks 'find-file-root-hook))))
(global-set-key [(control x) (control r)] 'find-file-root)
However that didn't make tramp works properly. When I invoke find-file-root
and enter the filename I want to open, emacs hangs up and doesn't open file.
Did anybody encounter similar problem?
--
kuvkir
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-02-16 18:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-16 18:33 problems with tramp Kirill Kuvaldin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).