From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#35367: 26.2; `dired-copy-how-to-fn' and HOW-TO arg of `dired-create-files' Date: Tue, 09 Jul 2019 16:21:24 +0200 Message-ID: <87wogrthjv.fsf@mouse.gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="50756"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 35367@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 09 16:29:48 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hkr7p-000Ckf-Ne for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jul 2019 16:29:45 +0200 Original-Received: from localhost ([::1]:50442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkr0e-0006XM-Sn for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jul 2019 10:22:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57404) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkr0O-0006TI-6c for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 10:22:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkr0M-0000b0-RU for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 10:22:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53056) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkr0M-0000aZ-CU for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 10:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hkr0M-0006lB-7d for bug-gnu-emacs@gnu.org; Tue, 09 Jul 2019 10:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Jul 2019 14:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35367 X-GNU-PR-Package: emacs Original-Received: via spool by 35367-submit@debbugs.gnu.org id=B35367.156268209425839 (code B ref 35367); Tue, 09 Jul 2019 14:22:02 +0000 Original-Received: (at 35367) by debbugs.gnu.org; 9 Jul 2019 14:21:34 +0000 Original-Received: from localhost ([127.0.0.1]:33616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkqzt-0006ib-8N for submit@debbugs.gnu.org; Tue, 09 Jul 2019 10:21:33 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:46854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkqzo-0006iE-US for 35367@debbugs.gnu.org; Tue, 09 Jul 2019 10:21:29 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hkqzk-00065L-TD; Tue, 09 Jul 2019 16:21:27 +0200 In-Reply-To: (Drew Adams's message of "Sun, 21 Apr 2019 12:30:14 -0700 (PDT)") 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: 209.51.188.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:162464 Archived-At: Drew Adams writes: > 1. I believe `dired-copy-how-to-fn' was added to Emacs quite a while ago > (1991[1]). But it's not clear to me what it's really for, and there > seem to be no uses of it in the distributed Emacs code, apart from > `dired-do-copy', which just passes it on to `dired-create-files'. > The variable's doc just says to "See HOW-TO argument for > `dired-create-files'." > > So why was this variable created? I hoped that the code might throw some light on this variable, but: (defun dired-into-dir-with-symlinks (target) (and (file-directory-p target) (not (file-symlink-p target)))) ;; This may not always be what you want, especially if target is your ;; home directory and it happens to be a symbolic link, as is often the ;; case with NFS and automounters. Or if you want to make symlinks ;; into directories that themselves are only symlinks, also quite ;; common. ;; So we don't use this function as value for HOW-TO in ;; dired-do-symlink, which has the minor disadvantage of ;; making links *into* a symlinked-dir, when you really wanted to ;; *overwrite* that symlink. In that (rare, I guess) case, you'll ;; just have to remove that symlink by hand before making your marked ;; symlinks. (defvar dired-copy-how-to-fn nil "Either nil or a function used by `dired-do-copy' to determine target. See HOW-TO argument for `dired-do-create-files'.") It's still clear as mud to me. > 2. Apart from the variable, why was the HOW-TO arg of > `dired-do-create-files' added? I find no uses of it, apart from > `dired-do-copy' (which just passes it along). > > Presumably someone thought that someone might want to pass such a > thing to `dired-do-copy', but why? > > Half the doc of `dired-do-create-files' is for this parameter. And > its description, although probably correct and complete, reads like > gobbledygook, to me. > > For one thing, the nil case should not be described under this > parameter; it should be described as the function's default behavior, > up above the parameter list. (That's already 4 lines of its > description.) Well... I think it makes sense (in so far as this parameter makes any sense) to keep it where it is: Optional arg HOW-TO determines how to treat the target. If HOW-TO is nil, use `file-directory-p' to determine if the target is a directory. If so, the marked file(s) are created inside that directory. Otherwise, the target is a plain file; an error is raised unless there is exactly one marked file. If HOW-TO is t, target is always treated as a plain file. Otherwise, HOW-TO should be a function of one argument, TARGET. If its return value is nil, TARGET is regarded as a plain file. If it return value is a list, TARGET is a generalized directory (e.g. some sort of archive). The first element of this list must be a function with at least four arguments: operation - as OPERATION above. rfn-list - list of the relative names for the marked files. fn-list - list of the absolute names for the marked files. target - the name of the target itself. The rest of elements of the list returned by HOW-TO are optional arguments for the function that is the first element of the list. For any other return value, TARGET is treated as a directory." > Beyond that: > > * A value of `t' is unclear to me. What does it mean to target a > plain file - is this the same as using a `nil' value? What happens > with `t' if the target is a directory or if there are multiple > marked files? Is that where the difference lies somehow (how)? My interpretation of t is that all files you copy will up in the same file if it's t, which is a supremely useless thing, you'd think... > It was apparently RMS who added this [1]. I'm surprised that it's > not more clear what good it is. Does anybody know what this parameter and variable was meant to do, and whether it's used anywhere out-of-tree? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no