From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pierre Lorenzon Newsgroups: gmane.emacs.help Subject: Re: dired-make-relative-symlink Date: Thu, 06 Jul 2017 04:35:00 +0200 (CEST) Message-ID: <20170706.043500.939942186111861974.devel@pollock-nageoire.net> References: <20170704.161038.773751553356814485.devel@pollock-nageoire.net> <20170704.172133.1757667556293342530.devel@pollock-nageoire.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1499309693 6142 195.159.176.226 (6 Jul 2017 02:54:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Jul 2017 02:54:53 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: rfrancoise@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 06 04:54:49 2017 Return-path: Envelope-to: geh-help-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 1dSwwI-0001Dr-Pj for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Jul 2017 04:54:46 +0200 Original-Received: from localhost ([::1]:48964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSwwM-0000D8-Q5 for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 22:54:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSwvu-0000Cm-B8 for help-gnu-emacs@gnu.org; Wed, 05 Jul 2017 22:54:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSwvr-0002De-5g for help-gnu-emacs@gnu.org; Wed, 05 Jul 2017 22:54:22 -0400 Original-Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:18000 helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSwvq-0002C3-Pz for help-gnu-emacs@gnu.org; Wed, 05 Jul 2017 22:54:19 -0400 Original-Received: from localhost ([86.246.93.223]) by mwinf5d71 with ME id hEuE1v0024p9RrJ03EuEcn; Thu, 06 Jul 2017 04:54:16 +0200 X-ME-Helo: localhost X-ME-Date: Thu, 06 Jul 2017 04:54:16 +0200 X-ME-IP: 86.246.93.223 In-Reply-To: <20170704.172133.1757667556293342530.devel@pollock-nageoire.net> X-Mailer: Mew version 6.7 on Emacs 26.0.50 / Mule 6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 80.12.242.135 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113712 Archived-At: From: Pierre Lorenzon Subject: Re: dired-make-relative-symlink Date: Tue, 04 Jul 2017 17:21:33 +0200 (CEST) > > Hi, > > Here is a very compact and short implementation > > (defun dired-make-relative-symlink (file1 file2 &optional ok-if-already-exists) > "Make a symbolic link (pointing to FILE1) in FILE2. > The link is relative (if possible), for example > > \"/vol/tex/bin/foo\" \"/vol/local/bin/foo\" > > results in > > \"../../tex/bin/foo\" \"/vol/local/bin/foo\"" > (interactive "FRelSymLink: \nFRelSymLink %s: \np") > (let ((file1 (expand-file-name file1)) > (file2 (expand-file-name file2))) > (make-symbolic-link (directory-file-name > (file-relative-name file1 > (file-name-directory > file2))) > file2 ok-if-already-exists))) Notice that dired-make-relative could probably be used here as well. Anyway dired-make-relative could certainly be implmented by file-relative-name. The code is not duplicated but at least written three times ! I think it is the case in most of codes and even when someone discovers it maintainers do not have time to clean such situations and verify that modification do no cause bugs. Regard Pierre > > I did not yet notice bugs but maybe there are some ! > > If you think it is accurate to replace the code in dired-x.el > fell free to do it ! > > Regards > > Pierre > > > From: Pierre Lorenzon > Subject: dired-make-relative-symlink > Date: Tue, 04 Jul 2017 16:10:38 +0200 (CEST) > >> >> >> Hi, >> >> I wonder why the function dired-make-relative-symlink >> recalculate the relative name of the file instead of using >> file-relative-name of the files.el library. >> >> Making a few tests it seems that both codes produce the same >> result. Anyway maybe these tests are not torturing the code >> enough. >> >> files.el library seems to be very old and it looks strange to >> me that when dired-x.el was developped files.el was not known. >> >> I did not report that as a bug since it is not a bug but I >> think that a system is more maintainable when code is not >> duplicated. >> >> Regards >> >> PS/ Sory if I did not notice an evident reason for which the >> code is so ! >> >