From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: Re: With /sudo::/etc instead of /etc, files are not conf mode by default Date: Sun, 05 Aug 2007 11:09:10 +0200 Message-ID: <87zm161h6x.fsf@gmx.de> References: <87bqdmbox1.fsf@baal.twb.ath.cx> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1186305001 31619 80.91.229.12 (5 Aug 2007 09:10:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 5 Aug 2007 09:10:01 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: trentbuck@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 05 11:09:59 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IHc7Z-0000MC-0d for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Aug 2007 11:09:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IHc7W-0000ZW-FY for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Aug 2007 05:09:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IHc7T-0000ZB-PE for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2007 05:09:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IHc7K-0000Yx-BG for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2007 05:09:50 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IHc7K-0000Yu-6O for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2007 05:09:42 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1IHc7G-0001vu-QL for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2007 05:09:40 -0400 Original-Received: (qmail invoked by alias); 05 Aug 2007 09:09:12 -0000 Original-Received: from p57A242EA.dip0.t-ipconnect.de (EHLO localhost.local) [87.162.66.234] by mail.gmx.net (mp020) with SMTP; 05 Aug 2007 11:09:12 +0200 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX1+4iiZq97i4Ho6Jbj3OehKN5EvB4lCpRYtRIgSnsD Og/K4ifTzN6N9Y In-Reply-To: <87bqdmbox1.fsf@baal.twb.ath.cx> (trentbuck@gmail.com's message of "Sun, 05 Aug 2007 14:12:10 +1000") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16282 Archived-At: 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