From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.bugs Subject: bug#25075: 26.0.50; [PATCH] Dired can now dereference symlinks when copying Date: Wed, 30 Nov 2016 18:04:17 +0000 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114e5266447b83054288895c X-Trace: blaine.gmane.org 1480529127 26648 195.159.176.226 (30 Nov 2016 18:05:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2016 18:05:27 +0000 (UTC) To: 25075@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 30 19:05:18 2016 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 1cC9Fq-00052O-DM for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 19:05:14 +0100 Original-Received: from localhost ([::1]:45523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC9Fr-00039q-4y for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 13:05:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC9Fk-00035w-IR for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:05:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC9Fe-0002pe-LF for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:05:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cC9Fe-0002pU-HJ for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cC9Fe-0004es-6x for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Nov 2016 18:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25075 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.148052908317877 (code B ref -1); Wed, 30 Nov 2016 18:05:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Nov 2016 18:04:43 +0000 Original-Received: from localhost ([127.0.0.1]:47730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cC9FL-0004eG-4d for submit@debbugs.gnu.org; Wed, 30 Nov 2016 13:04:43 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cC9FI-0004e4-UE for submit@debbugs.gnu.org; Wed, 30 Nov 2016 13:04:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC9FC-0002hf-Ku for submit@debbugs.gnu.org; Wed, 30 Nov 2016 13:04:35 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cC9FC-0002hb-IY for submit@debbugs.gnu.org; Wed, 30 Nov 2016 13:04:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC9FA-000340-UY for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:04:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC9F9-0002gj-NE for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:04:32 -0500 Original-Received: from mail-vk0-x234.google.com ([2607:f8b0:400c:c05::234]:33912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cC9F9-0002gN-D7 for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2016 13:04:31 -0500 Original-Received: by mail-vk0-x234.google.com with SMTP id x186so114606489vkd.1 for ; Wed, 30 Nov 2016 10:04:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=FQ6MfvOOypLG0uniH2m6vG8USnRYVMRfWHZjVf7ypPU=; b=vKY/4WpsG4fps9/YFPnuznbs37jWUZZlWPfo1q/2ZPoSQyiFiIy+qj/ruVAhZAGURR zUnxX1OWp81aipMTZ2WCIIXs9fSs0j2YayW7DM18W0jd9/VCt551Mn//fWWeydBuHBzv K2fV3s125payVFJ2XfkLFmzm+PZrs6VvR4JYv5gudCNHy+TbDxq4JY3/Ic+Qo+qkfJft Ds+AQlByfwybPy9ump5dQjUEny8Y7gfGpQcAYzzj3R5sjIKHhcMuNQx9LAVS+4kVE3Rl r1S6jjdnO5GctaIonUghHuLReHdM/LaEBtAymWAfHZpIepP/CSy+Y6XFmnd4mAeNfwpx 9tkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=FQ6MfvOOypLG0uniH2m6vG8USnRYVMRfWHZjVf7ypPU=; b=QPYiM9Y0h7EGPCfa4UQnOtakA5rry0/c3ryesgV6Xv3uu6tDA/SFp85yZdIQOktgyr tD0WFrjj4MdCe/tW/6+SSstlNH8D5eOYvlmw/fnwNGgzwstHZ2U3HQoto3QjF10Ifdgp Xw3RYYaT42KUfBKNwf/hg+M5k/qXKZ4ou26c/za06dvKoWVrEPGLcrGxjq8Gf98ERmsK CE5mLnrauTyUUkPFVSYLwsJUrcXTxivNhHwrxg1GMmyJJSRewbfRp0zAw5Gg98cQJRgL x/hYHAJWDYDWOONV2mQUPpiS3hBTZ1aCiwKJaO3YB47t9oPQoNXTQbmL2B7deqOEUBR4 76aw== X-Gm-Message-State: AKaTC03jI6cZa30A8S+IX44zIWxq2ZpT76X8bMrpvj3N0MJa/6qAUWOAZIvxxWvvJGUowO2yQi1jv+BCI+BQDQ== X-Received: by 10.31.92.215 with SMTP id q206mr10416775vkb.104.1480529069503; Wed, 30 Nov 2016 10:04:29 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:126322 Archived-At: --001a114e5266447b83054288895c Content-Type: text/plain; charset=UTF-8 Hello, Can you review and comment on the below patch. I came up with a necessity to copy symlinks from one dired buffer to another dired buffer as a dereferenced copy of that symlink. In terminal, I would use the -L option of the cp command to do the same. The current default behavior is unchanged as the new defcustom dired-copy-dereference is set to nil. >From 4c4185b9d4df2dcbbb6e1e7fa8a21b75e84ca79f Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Wed, 30 Nov 2016 12:52:42 -0500 Subject: [PATCH] Dired can now dereference symlinks when copying * lisp/dired.el (dired-copy-dereference): New defcustom, defaults to nil. * lisp/dired-aux.el (dired-copy-file-recursive): Add new optional argument `dereference'. * lisp/dired-aux.el (dired-copy-file): Use `dired-copy-dereference' as the `dereference' argument to `dired-copy-file-recursive'. --- lisp/dired-aux.el | 8 +++++--- lisp/dired.el | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index f94e053..149c540 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1507,12 +1507,13 @@ dired-handle-overwrite (defun dired-copy-file (from to ok-flag) (dired-handle-overwrite to) (dired-copy-file-recursive from to ok-flag dired-copy-preserve-time t - dired-recursive-copies)) + dired-recursive-copies dired-copy-dereference)) (declare-function make-symbolic-link "fileio.c") (defun dired-copy-file-recursive (from to ok-flag &optional - preserve-time top recursive) + preserve-time top recursive + dereference) (when (and (eq t (car (file-attributes from))) (file-in-directory-p to from)) (error "Cannot copy `%s' into its subdirectory `%s'" from to)) @@ -1524,7 +1525,8 @@ dired-copy-file-recursive (copy-directory from to preserve-time) (or top (dired-handle-overwrite to)) (condition-case err - (if (stringp (car attrs)) + (if (and (not dereference) + (stringp (car attrs))) ;; It is a symlink (make-symbolic-link (car attrs) to ok-flag) (copy-file from to ok-flag preserve-time)) diff --git a/lisp/dired.el b/lisp/dired.el index daa6d77..ca7ab28 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -191,6 +191,12 @@ dired-copy-preserve-time :type 'boolean :group 'dired) +(defcustom dired-copy-dereference nil + "If non-nil, Dired dereferences symlinks when copying them. +This is similar to the \"-L\" option for the \"cp\" shell command." + :type 'boolean + :group 'dired) + ; ; These variables were deleted and the replacements are on files.el. ; We leave aliases behind for back-compatibility. (defvaralias 'dired-free-space-program 'directory-free-space-program) -- 2.10.0 -- Kaushal Modi --001a114e5266447b83054288895c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,

Can you review and co= mment on the below patch. I came up with a necessity to copy symlinks from = one dired buffer to another dired buffer as a dereferenced copy of that sym= link.

In terminal, I would use the -L option of th= e cp command to do the same.

The current default b= ehavior is unchanged as the new defcustom dired-copy-dereference is set to = nil.

From 4c4185b9d4df2dcbbb6e1e7fa8a21b75e84ca79f= Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: We= d, 30 Nov 2016 12:52:42 -0500
Subject: [PATCH] Dired can now dere= ference symlinks when copying

* lisp/dired.el (dir= ed-copy-dereference): New defcustom, defaults to
nil.
<= br>
* lisp/dired-aux.el (dired-copy-file-recursive): Add new opti= onal
argument `dereference'.

* lisp/= dired-aux.el (dired-copy-file): Use `dired-copy-dereference' as
the `dereference' argument to `dired-copy-file-recursive'.
=
---
=C2=A0lisp/dired-aux.el | 8 +++++---
=C2=A0lis= p/dired.el =C2=A0 =C2=A0 | 6 ++++++
=C2=A02 files changed, 11 ins= ertions(+), 3 deletions(-)

diff --git a/lisp/dired= -aux.el b/lisp/dired-aux.el
index f94e053..149c540 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -= 1507,12 +1507,13 @@ dired-handle-overwrite
=C2=A0(defun dired-cop= y-file (from to ok-flag)
=C2=A0 =C2=A0(dired-handle-overwrite to)=
=C2=A0 =C2=A0(dired-copy-file-recursive from to ok-flag dired-co= py-preserve-time t
- =C2=A0 =C2=A0 dired-recursive-copies))
+ =C2=A0 = =C2=A0 dired-recursive-copies dired-copy-dereference))
=C2=A0
=C2=A0(declare-function make-symbolic-link "fileio.c")
=C2=A0
=C2=A0(defun dired-copy-file-recursive (from to ok-= flag &optional
- =C2=A0 =C2=A0 =C2=A0 preserve-time top recursive)
+ =C2=A0 =C2=A0 =C2=A0 preserve-time top recursive
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dereference)
=C2= =A0 =C2=A0(when (and (eq t (car (file-attributes from)))
=C2=A0 =C2=A0 =C2= =A0 (file-in-directory-p to from))
=C2=A0 =C2=A0 =C2=A0(error &qu= ot;Cannot copy `%s' into its subdirectory `%s'" from to))
@@ -1524,7 +1525,8 @@ dired-copy-file-recursive
=C2=A0 (copy-directory= from to preserve-time)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(or top (dired= -handle-overwrite to))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(condition-case= err
- <= /span> =C2=A0(if (stringp (car attrs))
+ =C2=A0(if (and (not dereference)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= stringp (car attrs)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; It is a symlink
<= div>=C2=A0 = =C2=A0 =C2=A0 =C2=A0(make-symbolic-link (car attrs) to ok-flag)
= =C2=A0 =C2= =A0 =C2=A0(copy-file from to ok-flag preserve-time))
diff --git a= /lisp/dired.el b/lisp/dired.el
index daa6d77..ca7ab28 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -191,6= +191,12 @@ dired-copy-preserve-time
=C2=A0 =C2=A0:type 'bool= ean
=C2=A0 =C2=A0:group 'dired)
=C2=A0
+(= defcustom dired-copy-dereference nil
+ =C2=A0"If non-nil, Di= red dereferences symlinks when copying them.
+This is similar to = the \"-L\" option for the \"cp\" shell command."
+ =C2=A0:type 'boolean
+ =C2=A0:group 'dired)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0;
=C2=A0; These variables were deleted and the replacements ar= e on files.el.
=C2=A0; We leave aliases behind for back-compatibi= lity.
=C2=A0(defvaralias 'dired-free-space-program 'direc= tory-free-space-program)
--=C2=A0
2.10.0

=
--

Kaushal Modi

--001a114e5266447b83054288895c--