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: Thu, 01 Dec 2016 06:06:21 +0000 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f403045dd562831ecd0542929f02 X-Trace: blaine.gmane.org 1480572437 19690 195.159.176.226 (1 Dec 2016 06:07:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Dec 2016 06:07:17 +0000 (UTC) Cc: 25075@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 01 07:07:12 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 1cCKWV-0004Bd-Ot for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2016 07:07:12 +0100 Original-Received: from localhost ([::1]:48379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCKWZ-0000GE-GV for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2016 01:07:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCKWQ-0000G9-7e for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 01:07:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCKWM-00065C-4L for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 01:07:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCKWL-00064z-W5 for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 01:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cCKWL-0008Dh-Ld for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 01:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2016 06:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25075 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 25075-submit@debbugs.gnu.org id=B25075.148057240131548 (code B ref 25075); Thu, 01 Dec 2016 06:07:01 +0000 Original-Received: (at 25075) by debbugs.gnu.org; 1 Dec 2016 06:06:41 +0000 Original-Received: from localhost ([127.0.0.1]:48021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCKW0-0008Ck-V8 for submit@debbugs.gnu.org; Thu, 01 Dec 2016 01:06:41 -0500 Original-Received: from mail-ua0-f179.google.com ([209.85.217.179]:33877) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCKVy-0008CV-4I for 25075@debbugs.gnu.org; Thu, 01 Dec 2016 01:06:38 -0500 Original-Received: by mail-ua0-f179.google.com with SMTP id 51so237729077uai.1 for <25075@debbugs.gnu.org>; Wed, 30 Nov 2016 22:06:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dN/Q9h6DdBHvLd3/Z4UUuFRpcVoc3egvA82e6Owduag=; b=cwm1SpAxwynldjfDIZSB/QJmcg8oI/g0Fb0qpypu+wHHSMh1nFo9U5tCdFIHIYhqhL xFP8mlHJZjpVN6La+7sH3yYVqbJUkOQ9/vdVhBs3BxVItaki8raoNWfxLQxsLmcAvzvx 1ntFZuehGUF9q9kNfEKArzN6in+bhfWJ1flV+p4cYxRi9G+aEk8dfv8YXiUgrMUcL5qJ KCAQxkuVva5M2qfP9w62/sFpfF5g4i+nNGoVw2g+4KRHSwmJNszdLulVghgQfPGBmjyP CTgFEhk4jneAbs0LWWneqVftFYKwfcgH9gvVoSKlRRIU10Oo4QVqc+nAoH5jUSaEC8ac qpiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dN/Q9h6DdBHvLd3/Z4UUuFRpcVoc3egvA82e6Owduag=; b=BB3yFXwYmFCoku8wcWmtQmvMkishxljXLd+hqKOhe3tDR2IEHyKHfMSPopG7Zaj7sA 2d0Xd/Yyj53PmYVgsGdzuPWLBen2Rtm4V/3hEB2K9myD7nuYfTG7NObsMnoPUUk2LYcZ UeqE/PegXNCuWCzMMzsvsPWgHA9RXht5ifWVvmwXUD9xr5/1aqbw38D1NEcBUakLtDe6 BtSJ5HBhz9XKlStM1ENe0bBOwaZb5IU8tFvbGBxhPVRhGlly/0uZdyuszHBFJF4MBC26 kyyRxmbcIcRaIjwqC/HaIfwpIQUD4Z56jKN8GYnOSLgy6jGaFHh8z0Z/7GYeD7yjj46e 0H6g== X-Gm-Message-State: AKaTC01nmiEbbT1ZPLDvGzGxcW9gdSq0E2+T3r7hUU8BPvRLBEV4el1GN+XO0Gl+f5KloSgonYuaZNak2bHItw== X-Received: by 10.176.87.10 with SMTP id s10mr26676834uaa.52.1480572392380; Wed, 30 Nov 2016 22:06:32 -0800 (PST) In-Reply-To: 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:126347 Archived-At: --f403045dd562831ecd0542929f02 Content-Type: text/plain; charset=UTF-8 Copying with symlinks dereferenced is almost always the case for me, because of the version control system we use. It is a central VCS. So we need to check out the files before editing them. In checked-in state, all files are just symlinks to the physical versions in a central cache server. So almost always "cp -L" is what I want to do when copying files from one place to another without checking them out. My cp is aliased to "cp -L". That said, here's the revised patch with updated documentation and "Revisited Option 1" I mentioned above. This allows the flexibility of *not* dereferencing symlinks for few selected cases when I would have set dired-copy-dereference to t by default in my config. >From 28b9a7c41c168daec6645638c06d5333e8b642aa 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 (dired-do-copy): Invert the value of `dired-copy-dereference' in lexical scope when prefix argument is '(4). Update function documentation for the new defcustom. * doc/emacs/dired.texi (Operating on Files): Mention the new defcustom. --- doc/emacs/dired.texi | 8 ++++++++ lisp/dired-aux.el | 25 +++++++++++++++++++------ lisp/dired.el | 6 ++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 2cda51a82f..62042c5c1e 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -638,6 +638,14 @@ Operating on Files directories recursively (like @samp{cp -r}). The default is @code{top}, which means to ask before recursively copying a directory. +@vindex dired-copy-dereference +@cindex follow symbolic links +@cindex dereference symbolic links +The variable @code{dired-copy-dereference} controls whether to copy +symbolic links as links or after dereferencing (like @samp{cp -L}). +The default is @code{nil}, which means that the symbolic links are +copied by creating new ones. + @item D @findex dired-do-delete @kindex D @r{(Dired)} diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index f94e0537aa..1b9009c744 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)) @@ -1963,6 +1965,9 @@ dired-copy-how-to-fn ;;;###autoload (defun dired-do-copy (&optional arg) "Copy all marked (or next ARG) files, or copy the current file. +ARG has to be numeric for above functionality. See +`dired-get-marked-files' for more details. + When operating on just the current file, prompt for the new name. When operating on multiple or marked files, prompt for a target @@ -1976,10 +1981,18 @@ dired-do-copy the modification time of each old file in the copy, similar to the \"-p\" option for the \"cp\" shell command. -This command copies symbolic links by creating new ones, similar -to the \"-d\" option for the \"cp\" shell command." +This command copies symbolic links by creating new ones, +similar to the \"-d\" option for the \"cp\" shell command. +But if `dired-copy-dereference' is non-nil, the symbolic +links are dereferenced and then copied, similar to the \"-L\" +option for the \"cp\" shell command. If ARG is a cons with +element 4 (`\\[universal-argument]'), inverted value of +`dired-copy-dereference' will be used." (interactive "P") - (let ((dired-recursive-copies dired-recursive-copies)) + (let ((dired-recursive-copies dired-recursive-copies) + (dired-copy-dereference (if (equal arg '(4)) + (not dired-copy-dereference) + dired-copy-dereference))) (dired-do-create-files 'copy (function dired-copy-file) "Copy" arg dired-keep-marker-copy diff --git a/lisp/dired.el b/lisp/dired.el index daa6d776a9..ca7ab2813b 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.11.0 On Wed, Nov 30, 2016 at 11:12 PM Kaushal Modi wrote: > On Wed, Nov 30, 2016 at 7:38 PM Glenn Morris wrote: > > > I can't imagine anyone needing this as an option they can set for all > future uses. Surely what someone might need is a way to make one > specific copy command dereference? As a prefix argument or a separate > command, or whatever. > > > Hi Glenn, > > I thought of various options: > > Option 1: Make a prefix do copy with dereferencing. But for > `dired-do-copy' (bound to 'C' by default in dired-mode), numeric ARG > already has a meaning.. M-4 C will copy the next ARG files. Is the > dired-copy-dereference option special enough for a "C-u" prefix? I don't > know. > > Option 2: Let-bind dired-copy-dereference to t in a separate command and > have that call `dired-do-copy'. But then the single-letter binding space is > pretty crowded in dired-mode-map, and probably not worthy for this niche > command. > > Option 3 (is what I did): Have a defcustom available. User can choose to > either set it to a t by default, or use it in a wrapper command and bind > that to a binding of their liking. > > --- > > Re-visiting option 1: Do you think it would be a better idea to have C-u C > toggle the global value of `dired-copy-dereference' in a let binding and > then proceed with the copy? So if `dired-copy-dereference' is nil by > default, plain 'C' will copy symbolic links as links. But "C-u C" will copy > after dereferencing. Similarly if the user has set `dired-copy-dereference' > to t, the behavior of "C" and "C-u C" will reverse. > > On a separate note, if you look at the dired-do-copy definition, why is > the global value of dired-recursive-copies assigned to the let-bound > variable? Does this do anything different than not having that let form > altogether? > > (let ((dired-recursive-copies dired-recursive-copies)) ; > <--------------------------------- > (dired-do-create-files 'copy (function dired-copy-file) > "Copy" > arg dired-keep-marker-copy > nil dired-copy-how-to-fn)) > > The commit history says: > > (dired-do-copy): Bind `dired-recursive-copies' to preserve it. > Use dired-copy-how-to-fn as how-to argument to dired-do-create-files. > > But I did not understand that. > > Here's the vc region history for that line: > > commit ba1acd68768ac49d98afbf781851ab95c0263048 > Author: Richard M. Stallman > Date: Thu Sep 16 19:29:30 1999 +0000 > > (dired-recursive-copies): New custom variable. > (dired-handle-overwrite): Broke a long line. > (dired-copy-file): Call `dired-copy-file-recursive' instead of > `copy-file'. > (dired-copy-file-recursive): New function. Copy directories > recursively. > (dired-do-create-files): Added support for generalized directory > target. How-to function may now return a function. New fluid > variable `dired-one-file'. > (dired-copy-how-to-fn): New variable. > (dired-do-copy): Bind `dired-recursive-copies' to preserve it. > Use dired-copy-how-to-fn as how-to argument to dired-do-create-files. > (dired-do-copy-regexp): No recursive copies. > > diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el > --- a/lisp/dired-aux.el > +++ b/lisp/dired-aux.el > @@ -1261,3 +1315,1 @@ > - (dired-do-create-files 'copy (function dired-copy-file) > - (if dired-copy-preserve-time "Copy [-p]" "Copy") > - arg dired-keep-marker-copy)) > +n (let ((dired-recursive-copies dired-recursive-copies)) > > -- > > Kaushal Modi > -- Kaushal Modi --f403045dd562831ecd0542929f02 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Copying with symlinks dereferenced is almost always t= he case for me, because of the version control system we use. It is a centr= al VCS. So we need to check out the files before editing them. In checked-i= n state, all files are just symlinks to the physical versions in a central = cache server. So almost always "cp -L" is what I want to do when = copying files from one place to another without checking them out. My cp is= aliased to "cp -L".

That said, here'= ;s the revised patch with updated documentation and "Revisited Option = 1" I mentioned above. This allows the flexibility of *not* dereferenci= ng symlinks for few selected cases when I would have set dired-copy-derefer= ence to t by default in my config.

From 28b9a= 7c41c168daec6645638c06d5333e8b642aa Mon Sep 17 00:00:00 2001
From= : Kaushal Modi <kaushal.modi@g= mail.com>
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, def= aults to
nil.

* lisp/dired-aux.el (dired= -copy-file-recursive): Add new optional
argument `dereference'= ;.

* lisp/dired-aux.el (dired-copy-file): Use `dir= ed-copy-dereference' as
the `dereference' argument to `di= red-copy-file-recursive'.

* lisp/dired-aux.el = (dired-do-copy): Invert the value of
=C2=A0 `dired-copy-dereferen= ce' in lexical scope when prefix argument is
=C2=A0 '(4).= Update function documentation for the new defcustom.

<= div>* doc/emacs/dired.texi (Operating on Files): Mention the new defcustom.=
---
=C2=A0doc/emacs/dired.texi | =C2=A08 ++++++++
=C2=A0lisp/dired-aux.el =C2=A0 =C2=A0| 25 +++++++++++++++++++------
=C2=A0lisp/dired.el =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A06 ++++++
=C2=A03 files changed, 33 insertions(+), 6 deletions(-)
<= br>
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 2cda51a82f..62042c5c1e 100644
--- a/doc/emacs/dired.t= exi
+++ b/doc/emacs/dired.texi
@@ -638,6 +638,14 @@ Ope= rating on Files
=C2=A0directories recursively (like @samp{cp -r})= .=C2=A0 The default is
=C2=A0@code{top}, which means to ask befor= e recursively copying a directory.
=C2=A0
+@vindex dire= d-copy-dereference
+@cindex follow symbolic links
+@cin= dex dereference symbolic links
+The variable @code{dired-copy-der= eference} controls whether to copy
+symbolic links as links or af= ter dereferencing (like @samp{cp -L}).
+The default is @code{nil}= , which means that the symbolic links are
+copied by creating new= ones.
+
=C2=A0@item D
=C2=A0@findex dired-do= -delete
=C2=A0@kindex D @r{(Dired)}
diff --git a/lisp/d= ired-aux.el b/lisp/dired-aux.el
index f94e0537aa..1b9009c744 1006= 44
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1507,12 +1507,13 @@ dired-handle-overwrite
=C2=A0(defun= dired-copy-file (from to ok-flag)
=C2=A0 =C2=A0(dired-handle-ove= rwrite to)
=C2=A0 =C2=A0(dired-copy-file-recursive from to ok-fla= g dired-copy-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&= quot;)
=C2=A0
=C2=A0(defun dired-copy-file-recursive (f= rom to ok-flag &optional
- =C2=A0 =C2=A0 =C2=A0 preserve-time top re= cursive)
+ =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 "Cannot copy `%s' into its subdirectory `%s'" from= to))
@@ -1524,7 +1525,8 @@ dired-copy-file-recursive
= =C2=A0 (cop= y-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(con= dition-case err
- =C2=A0(if (stringp (car attrs))
+ =C2=A0(if (and (not der= eference)
+ =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 sym= link
=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))
@= @ -1963,6 +1965,9 @@ dired-copy-how-to-fn
=C2=A0;;;###autoload
=C2=A0(defun dired-do-copy (&optional arg)
=C2=A0 =C2= =A0"Copy all marked (or next ARG) files, or copy the current file.
+ARG has to be numeric for above functionality.=C2=A0 See
= +`dired-get-marked-files' for more details.
+
=C2= =A0When operating on just the current file, prompt for the new name.
<= div>=C2=A0
=C2=A0When operating on multiple or marked files, prom= pt for a target
@@ -1976,10 +1981,18 @@ dired-do-copy
= =C2=A0the modification time of each old file in the copy, similar to
<= div>=C2=A0the \"-p\" option for the \"cp\" shell comman= d.
=C2=A0
-This command copies symbolic links by creati= ng new ones, similar
-to the \"-d\" option for the \&qu= ot;cp\" shell command."
+This command copies symbolic l= inks by creating new ones,
+similar to the \"-d\" optio= n for the \"cp\" shell command.
+But if `dired-copy-der= eference' is non-nil, the symbolic
+links are dereferenced an= d then copied, similar to the \"-L\"
+option for the \&= quot;cp\" shell command.=C2=A0 If ARG is a cons with
+elemen= t 4 (`\\[universal-argument]'), inverted value of
+`dired-cop= y-dereference' will be used."
=C2=A0 =C2=A0(interactive = "P")
- =C2=A0(let ((dired-recursive-copies dired-recurs= ive-copies))
+ =C2=A0(let ((dired-recursive-copies dired-recursiv= e-copies)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(dired-copy-dereference (i= f (equal arg '(4))
+ =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(not dired-copy-dereference)
+ =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=A0dired-copy-dereference)))
=C2=A0 =C2=A0 = =C2=A0(dired-do-create-files 'copy (function dired-copy-file)
=C2=A0 = =C2=A0 "Copy"
=C2=A0 =C2=A0 arg dired-keep-marker-copy
diff --git a/lisp/dired.el b/lisp/dired.el
index daa6d776a9..ca= 7ab2813b 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el=
@@ -191,6 +191,12 @@ dired-copy-preserve-time
=C2=A0 = =C2=A0:type 'boolean
=C2=A0 =C2=A0:group 'dired)
=C2=A0
+(defcustom dired-copy-dereference nil
+ =C2= =A0"If non-nil, Dired 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 an= d the replacements are on files.el.
=C2=A0; We leave aliases behi= nd for back-compatibility.
=C2=A0(defvaralias 'dired-free-spa= ce-program 'directory-free-space-program)
--=C2=A0
= 2.11.0


On Wed, Nov 30, 2016 at 11:12 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
On Wed,= Nov 30, 2016 at 7:38 PM Glenn Morris <rgm@gnu.org> wrote:

I can't imagine anyone needing this as an option they can set for all future uses. Surely what someone might need is a way to make one
specific copy command dereference? As a prefix argument or a separate
command, or whatever.

H= i Glenn,

I thought of various options:

Option 1: Make a= prefix do copy with dereferencing. But for `dired-do-copy' (bound to &= #39;C' by default in dired-mode), numeric ARG already has a meaning.. M= -4 C will copy the next ARG files. Is the dired-copy-dereference option spe= cial enough for a "C-u" prefix? I don't know.

Optio= n 2: Let-bind dired-copy-dereference to t in a separate command and have th= at call `dired-do-copy'. But then the single-letter binding space is pr= etty crowded in dired-mode-map, and probably not worthy for this niche comm= and.

Option 3 (is what I did): Have a defcustom available. User c= an choose to either set it to a t by default, or use it in a wrapper comman= d and bind that to a binding of their liking.

---

Re-vi= siting option 1: Do you think it would be a better idea to have C-u C toggl= e the global value of `dired-copy-dereference' in a let binding and the= n proceed with the copy? So if `dired-copy-dereference' is nil by defau= lt, plain 'C' will copy symbolic links as links. But "C-u C&qu= ot; will copy after dereferencing. Similarly if the user has set `dired-cop= y-dereference' to t, the behavior of "C" and "C-u C"= ; will reverse.

On a separate note, if you look at the dired-do-c= opy definition, why is the global value of dired-recursive-copies assigned = to the let-bound variable? Does this do anything different than not having = that let form altogether?=C2=A0

=C2=A0 (= let ((dired-recursive-copies dired-recursive-copies)) =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ; <---------------------------------
=C2=A0 =C2=A0 (dired-do-create-files 'copy (function dired-copy-file)=
=C2=A0 "Co= py"
=C2=A0 = arg dired-keep-marker-copy
= =C2=A0 nil dired-copy-how-to-fn))

The commit his= tory says:

(dired-do-copy): Bind `dired-= recursive-copies' to preserve it.
=C2=A0 = =C2=A0 Use dired-copy-how-to-fn as how-to argument to dired-do-create-files= .

But I did not understand that.

Here's the v= c region history for that line:

commit b= a1acd68768ac49d98afbf781851ab95c0263048
Autho= r: Richard M. Stallman <rms@gnu.org>
Date= : =C2=A0 Thu Sep 16 19:29:30 1999 +0000

=C2=A0 =C2=A0 (dired-recu= rsive-copies): New custom variable.
=C2=A0 = =C2=A0 (dired-handle-overwrite): Broke a long line.
=C2=A0 =C2=A0 (dired-copy-file): Call `dired-copy-file-recursive'= ; instead of `copy-file'.
=C2=A0 =C2=A0 (= dired-copy-file-recursive): New function.=C2=A0 Copy directories recursivel= y.
=C2=A0 =C2=A0 (dired-do-create-files): Add= ed support for generalized directory
=C2=A0 = =C2=A0 target.=C2=A0 How-to function may now return a function.=C2=A0 New f= luid
=C2=A0 =C2=A0 variable `dired-one-file&#= 39;.
=C2=A0 =C2=A0 (dired-copy-how-to-fn): Ne= w variable.
=C2=A0 =C2=A0 (dired-do-copy): Bi= nd `dired-recursive-copies' to preserve it.
=C2=A0 =C2=A0 Use dired-copy-how-to-fn as how-to argument to dired-do-cr= eate-files.
=C2=A0 =C2=A0 (dired-do-copy-rege= xp): No recursive copies.

diff --git a/lisp/dired-aux.el b/lisp/d= ired-aux.el
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
= @@ -1261,3 +1315,1 @@
- =C2=A0(dired-do-creat= e-files 'copy (function dired-copy-file)
= - =C2=A0 (if dired-copy-preserve-time "Cop= y [-p]" "Copy")
- =C2=A0 arg dired-keep-marker-copy))
+n =C2=A0(let ((dired-recursive-copies dired-recursive-copies))

--

Kaushal Modi

--

Kaushal Modi

--f403045dd562831ecd0542929f02--