[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: With /sudo::/etc instead of /etc, files are not conf mode by default
From: |
Michael Albinus |
Subject: |
Re: With /sudo::/etc instead of /etc, files are not conf mode by default |
Date: |
Sun, 05 Aug 2007 11:09:10 +0200 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) |
trentbuck@gmail.com writes:
> The file /etc/default/tftpd-hpa uses conf mode by default, presumably
> due to auto-mode-alist. However, opening the same file with TRAMP's
> sudo method: /sudo::/etc/default/tftpd-hpa, causes it to be in
> fundamental mode. Presumably this is because the auto-mode-alist
> entry uses ^/ to match the root directory or similar.
The following patch should fix it. It will appear also in Emacs 22.2.
Thanks for reporting, and best regards, Michael.
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.896.2.5
retrieving revision 1.896.2.11
diff -u -u -r1.896.2.5 -r1.896.2.11
--- lisp/files.el 22 May 2007 11:41:33 -0000 1.896.2.5
+++ lisp/files.el 5 Aug 2007 08:57:24 -0000 1.896.2.11
@@ -2254,7 +2254,12 @@
;; Next compare the filename against the entries in auto-mode-alist.
(unless done
(if buffer-file-name
- (let ((name buffer-file-name))
+ (let ((name buffer-file-name)
+ (remote-id (file-remote-p buffer-file-name)))
+ ;; Remove remote file name identification.
+ (when (and (stringp remote-id)
+ (string-match remote-id name))
+ (setq name (substring name (match-end 0))))
;; Remove backup-suffixes from file name.
(setq name (file-name-sans-versions name))
(while name