bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25075: 26.0.50; [PATCH] Dired can now dereference symlinks when copy


From: Kaushal Modi
Subject: bug#25075: 26.0.50; [PATCH] Dired can now dereference symlinks when copying
Date: Thu, 01 Dec 2016 04:12:31 +0000

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.

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 <rms@gnu.org>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]