From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Michalis V." Newsgroups: gmane.emacs.bugs Subject: bug#46913: dired-do-compress doesn't work on files in inserted subdirectories Date: Tue, 21 Sep 2021 11:35:57 +0300 Message-ID: <87h7eeqqaa.fsf@cnu407c2zx.nsn-intra.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8517"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46913@debbugs.gnu.org To: Okam Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 21 10:37:32 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSbHQ-0001zM-7A for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Sep 2021 10:37:32 +0200 Original-Received: from localhost ([::1]:59354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSbHP-00055H-8B for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Sep 2021 04:37:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSbGz-000529-18 for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 04:37:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSbGv-0006Fo-Tn for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 04:37:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mSbGv-0000n4-Rk for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2021 04:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Michalis V." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Sep 2021 08:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46913 X-GNU-PR-Package: emacs Original-Received: via spool by 46913-submit@debbugs.gnu.org id=B46913.16322133662947 (code B ref 46913); Tue, 21 Sep 2021 08:37:01 +0000 Original-Received: (at 46913) by debbugs.gnu.org; 21 Sep 2021 08:36:06 +0000 Original-Received: from localhost ([127.0.0.1]:44842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSbG2-0000lT-F6 for submit@debbugs.gnu.org; Tue, 21 Sep 2021 04:36:06 -0400 Original-Received: from mail-ed1-f54.google.com ([209.85.208.54]:39706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSbG0-0000kr-I3 for 46913@debbugs.gnu.org; Tue, 21 Sep 2021 04:36:05 -0400 Original-Received: by mail-ed1-f54.google.com with SMTP id h17so71522676edj.6 for <46913@debbugs.gnu.org>; Tue, 21 Sep 2021 01:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ywLH9PZieV1JG7w+8Y4noS1tBk6mFVnkVARKNzlwA3k=; b=l5amz/3qZJAF+kLPb0CmGElCrK/UmWpmENe76Gp3EX3etjmniagNR7PtTYPlbGznHw lrlAzqvyxeF6PyaF5KeNHvtrSPXXEH3N1YllB4djYz7cO+Ynd61pZAbU0Zs+bH6EKFCm l6NTt4FVI+elbMgcE7SvPf5tJXkrU469SqnJBzeS4jdSk5OUqvZPQ94SQXiGbygr4Uf3 aMxYCaAU1wkgsjZhbMf7wROsV32J38nnUvEXPyioCnA6Q8Zl3h5Xcky/NFvSru9MgWwx zgGrN8nLJAD+GJ3KZhRpG1MsmNIK7W/wRp298VAkMK/HEmyW+1NYRCtnD1/4cqJyulXy wxkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ywLH9PZieV1JG7w+8Y4noS1tBk6mFVnkVARKNzlwA3k=; b=kVpzFkV4Nw8QCbnzpDRC8vQtwQT0eqPW3McfZ7HS6Bv9GDlbtIoucCuuhnGuxcbXnO GtclOvIZ6TFXAW3ywmIVEo272U69sB9NETyozrsvJjlfWqU9guQujXD6+sda2uHhqPDK MZ0n7eQO/q05R9V3epwH+bPgHUfBR5N1e53I20CX36gARa8ogASD34TLylPI99ZE9Z15 9ruKqso1YP0vqM6EuMtIf1R6kY6Rr/5ohjcIwVpat9WxCLa7/OD9N2rhYV1fYp8ezTL1 hFjV7gcjFRTfqc/UUS1mZf5UYTxZFZ6GPvdiHUbvmpeN9ouw0Z8JhUwIuFItR6CZLGzy 5oMA== X-Gm-Message-State: AOAM530oNqY2+cQp+beVD0c3ieexqA5HtIIC73euVsa8vh1JupF89Sw9 H8zZ0dgr3FGb63+X1SgQj/LLEHsxWIuIPtWxx9E= X-Google-Smtp-Source: ABdhPJx9S6IMTn0rjstT9BBQM2DgK3hoheqCxq7/RSNCdn8ALpEcPq1yCbuoLWXtrMwWxy2Ds61mGw== X-Received: by 2002:a50:fa89:: with SMTP id w9mr34932574edr.113.1632213358685; Tue, 21 Sep 2021 01:35:58 -0700 (PDT) Original-Received: from cnu407c2zx.nsn-intra.net ([2a02:2149:8842:bf00:fe15:b4ff:fee9:4f35]) by smtp.gmail.com with ESMTPSA id h13sm8165975edr.4.2021.09.21.01.35.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Sep 2021 01:35:58 -0700 (PDT) X-Google-Original-From: "Michalis V." In-Reply-To: (Okam's message of "Thu, 04 Mar 2021 01:53:08 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214927 Archived-At: --=-=-= Content-Type: text/plain Okam writes: > Hello, > > If I insert a sub-directory into the current Dired buffer using > `dired-maybe-insert-subdir`, I am able to mark files in this > sub-directory and the current directory. > > If I try to compress these marked files using `dired-do-compress`, such > as into a Zip file, only the files in the current directory, and not any > in the sub-directory, will be entered into the archive. > > Thank you. hi, i'm assuming you meant "dired-do-compress-to" since "dired-do-compress" will just compress the files themselves (i.e. it won't compress them into a single archive) the root cause seems to be in dired-do-compress-to map function: when (zerop (dired-shell-command (format-spec (cdr rule) `((?o . ,(shell-quote-argument out-file)) (?i . ,(mapconcat (lambda (in-file) (shell-quote-argument (file-name-nondirectory in-file))) in-files " ")))))) in-files is a list with all marked files including their full path, e.g. ("/home/mvar/m/a" "/home/mvar/m/b" "/home/mvar/m/n/c") file-name-nondirectory will strip the whole path and leave just the filenames and the final command for dired-shell-command will be something like this: tar -cf - a b c | gzip -c9 > /home/varagoul/m/a.tar.gz and since dired-shell-command is executed from within the parent dired-directory (/home/mvar/m in this case), file c won't be found so it won't be included in the resulting archive. A workaround for this is to include the whole path, i.e. (lambda (in-file) (shell-quote-argument (expand-file-name in-file))) but if you untar the file later, the files will be extracted with the full path (in our example under home/mvar/m) and i don't think we want the full path in there. So another solution which is a bit more hackish is the following (and also attached as a patch) (shell-quote-argument (replace-regexp-in-string (expand-file-name dired-directory) "" in-file))) which removes the base dired-directory from the filename and leaves only the relative path for any marked files inside subdirectories of the dired-directory expand-file-name is also applied because dired-directory might be something like "~/" which does not seem to work very well with shell-quote-argument cheers, Michalis --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=dired-aux.patch diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index f2cb745ad4..1b73f098e3 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1246,7 +1246,9 @@ dired-do-compress-to (?i . ,(mapconcat (lambda (in-file) (shell-quote-argument - (file-name-nondirectory in-file))) + (replace-regexp-in-string + (expand-file-name dired-directory) "" + in-file))) in-files " ")))))) (message (ngettext "Compressed %d file to %s" "Compressed %d files to %s" --=-=-=--