From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#28264: Accessing source directory through symlink produces false warnings Date: Mon, 28 Aug 2017 21:57:15 -0700 Organization: UCLA Computer Science Department Message-ID: <6cd94296-2dd5-ac88-185b-ed7d5d8e5533@cs.ucla.edu> References: <8fo9qzeei7.fsf@fencepost.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E3463A97300559C7E452761B" X-Trace: blaine.gmane.org 1503982697 9513 195.159.176.226 (29 Aug 2017 04:58:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2017 04:58:17 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Cc: Michael Albinus To: Glenn Morris , 28264-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 29 06:58:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmYbH-0001w7-6R for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Aug 2017 06:58:07 +0200 Original-Received: from localhost ([::1]:42788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmYbO-0006o4-2r for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Aug 2017 00:58:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmYbF-0006nf-JL for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 00:58:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmYbC-0003bx-F8 for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 00:58:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51238) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmYbC-0003bn-Bk for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 00:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dmYbB-0008Nk-VF for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 00:58:01 -0400 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Aug 2017 04:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 28264 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 28264@debbugs.gnu.org, eggert@cs.ucla.edu, rgm@gnu.org Original-Received: via spool by 28264-done@debbugs.gnu.org id=D28264.150398265532183 (code D ref 28264); Tue, 29 Aug 2017 04:58:01 +0000 Original-Received: (at 28264-done) by debbugs.gnu.org; 29 Aug 2017 04:57:35 +0000 Original-Received: from localhost ([127.0.0.1]:59919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmYal-0008N1-5I for submit@debbugs.gnu.org; Tue, 29 Aug 2017 00:57:35 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmYai-0008Mn-OY for 28264-done@debbugs.gnu.org; Tue, 29 Aug 2017 00:57:33 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 93A06160910; Mon, 28 Aug 2017 21:57:25 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id HdPtHcKFFHlI; Mon, 28 Aug 2017 21:57:24 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B281D160952; Mon, 28 Aug 2017 21:57:24 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RceAs2N-RFN6; Mon, 28 Aug 2017 21:57:24 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 89E4C1608E8; Mon, 28 Aug 2017 21:57:24 -0700 (PDT) In-Reply-To: <8fo9qzeei7.fsf@fencepost.gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136314 Archived-At: This is a multi-part message in MIME format. --------------E3463A97300559C7E452761B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the bug report. I reproduced the problem and installed the attached patch to fix it. It strikes me, though, that the code still won't work in other cases (e.g., symlinks containing ":"), and that Emacs probably has other instances of confusion between how it treats symlinks and how the OS treats them. I'll CC: this to Michael to give him a heads-up about this particular issue, as I'm not really up to speed on magic file names. --------------E3463A97300559C7E452761B Content-Type: text/x-patch; name="0001-Silence-false-alarms-for-symlinks-to-sources.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Silence-false-alarms-for-symlinks-to-sources.patch" >From c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 28 Aug 2017 21:50:09 -0700 Subject: [PATCH] Silence false alarms for symlinks to sources Problem reported by Glenn Morris (Bug#28264). * lisp/files.el (files--splice-dirname-file): New function. (file-truename, file-chase-links): Use it. --- lisp/files.el | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index b3eab29..5f55aa7 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1153,6 +1153,21 @@ files--name-absolute-system-p (and (file-name-absolute-p file) (not (eq (aref file 0) ?~)))) +(defun files--splice-dirname-file (dirname file) + "Splice DIRNAME to FILE like the operating system would. +If FILENAME is relative, return DIRNAME concatenated to FILE. +Otherwise return FILE, quoted with `/:' if DIRNAME and FILE have +different handlers; although this quoting is dubious if DIRNAME +is remote, it is not clear what would be better. This function +differs from `expand-file-name' in that DIRNAME must be a +directory name and leading `~' and `/:' are not special in FILE." + (if (files--name-absolute-system-p file) + (if (eq (find-file-name-handler dirname 'file-symlink-p) + (find-file-name-handler file 'file-symlink-p)) + file + (concat "/:" file)) + (concat dirname file))) + (defun file-truename (filename &optional counter prev-dirs) "Return the truename of FILENAME. If FILENAME is not absolute, first expands it against `default-directory'. @@ -1253,10 +1268,7 @@ file-truename ;; We can't safely use expand-file-name here ;; since target might look like foo/../bar where foo ;; is itself a link. Instead, we handle . and .. above. - (setq filename - (concat (if (files--name-absolute-system-p target) - "/:" dir) - target) + (setq filename (files--splice-dirname-file dir target) done nil) ;; No, we are done! (setq done t)))))))) @@ -1291,10 +1303,8 @@ file-chase-links (directory-file-name (file-name-directory newname)))) ;; Now find the parent of that dir. (setq newname (file-name-directory newname))) - (setq newname (concat (if (files--name-absolute-system-p tem) - "/:" - (file-name-directory newname)) - tem)) + (setq newname (files--splice-dirname-file (file-name-directory newname) + tem)) (setq count (1+ count)))) newname)) -- 2.7.4 --------------E3463A97300559C7E452761B--