all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Glenn Morris <rgm@gnu.org>, 28264-done@debbugs.gnu.org
Cc: Michael Albinus <michael.albinus@gmx.de>
Subject: bug#28264: Accessing source directory through symlink produces false warnings
Date: Mon, 28 Aug 2017 21:57:15 -0700	[thread overview]
Message-ID: <6cd94296-2dd5-ac88-185b-ed7d5d8e5533@cs.ucla.edu> (raw)
In-Reply-To: <8fo9qzeei7.fsf@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

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.

[-- Attachment #2: 0001-Silence-false-alarms-for-symlinks-to-sources.patch --]
[-- Type: text/x-patch, Size: 2516 bytes --]

From c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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


  reply	other threads:[~2017-08-29  4:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 18:25 bug#28264: Accessing source directory through symlink produces false warnings Glenn Morris
2017-08-29  4:57 ` Paul Eggert [this message]
2017-08-29 20:41   ` Michael Albinus
2017-08-30  2:20     ` Paul Eggert
2017-08-30  8:37       ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cd94296-2dd5-ac88-185b-ed7d5d8e5533@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=28264-done@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.