From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.bugs Subject: bug#66260: 29.0.92; project.el should support copying a file path relative to the project root Date: Sat, 30 Sep 2023 13:50:33 +0000 (UTC) Message-ID: <8734yv22jb.fsf@catern.com> References: <875y3t2827.fsf@catern.com> <86il7tihzl.fsf@mail.linkov.net> 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="38508"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66260@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 30 15:52:07 2023 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 1qmaO6-0009ce-7E for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Sep 2023 15:52:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmaNp-0000KF-LM; Sat, 30 Sep 2023 09:51:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmaNn-0000JY-Bc for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 09:51:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qmaNm-0005rK-Ef for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 09:51:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qmaO1-0003SV-Pq for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 09:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Sep 2023 13:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66260 X-GNU-PR-Package: emacs Original-Received: via spool by 66260-submit@debbugs.gnu.org id=B66260.169608186213213 (code B ref 66260); Sat, 30 Sep 2023 13:52:01 +0000 Original-Received: (at 66260) by debbugs.gnu.org; 30 Sep 2023 13:51:02 +0000 Original-Received: from localhost ([127.0.0.1]:57863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmaN4-0003R3-9T for submit@debbugs.gnu.org; Sat, 30 Sep 2023 09:51:02 -0400 Original-Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:2992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmaMy-0003QR-0l for 66260@debbugs.gnu.org; Sat, 30 Sep 2023 09:51:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=ycrKjgIrgy/YbmoYkSfUsAW4qi9QI5BMC0aFviQmJ94=; b=Ulo3VQKhKM3MOwi7GNMGeYMcg99VuY06PNx8PSPz0ivhGkghBvmW0JvHkcR+2maQdFal +32xTcqiaKQhRDvm9quGKRccoZSkC4aY1ICaBG862hD11HczOIIx7p5hfcO9cvq9frBup6 xr9RSjLYskfsV77yWsXiYek/q85bqJfAhJgcD9S7Z/v5RV6ffsWT04AFOetqckOnfTuKDU n+39NSHT3OA6kuH1wIV2FWf86VVzibrnHP2j4kLcMnXCxv/EO7Cn23obJr55azLcZZ33pk 5t9df01VZfoz1m/mqTaL0c04OfPU0glCQsdrnLHryZd08Mis4HQi9s6mtvFfQqag== Original-Received: by filterdrecv-8684c58db7-5vsrj with SMTP id filterdrecv-8684c58db7-5vsrj-1-651827A9-16 2023-09-30 13:50:33.555806704 +0000 UTC m=+238988.294772895 Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-32 (SG) with ESMTP id RhOrKL30Q0iwGjFdxyR5DA Sat, 30 Sep 2023 13:50:33.227 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=linkov.net Original-Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 890A36584B; Sat, 30 Sep 2023 09:50:32 -0400 (EDT) In-Reply-To: <86il7tihzl.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 29 Sep 2023 09:57:50 +0300") X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbLDZ4OA+uecRKF6HGxytE24Dlu5Y8Kx/B/AIOFnAkTqGjOAkCaZUnuNmmpqgSfainFy4ifqxV74vsDj40xFG/niYAGvv9kRyLmmNulGm/xYgmZX/lGOqXvqgkNyPZNwjbHfk2jW47YjdbCiAK60KY/Am16UitvD5+yyMNTN3bnGog== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271543 Archived-At: --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Juri Linkov writes: > Sometimes an absolute path is needed too even in project directories. > Maybe it's possible to find a new prefix argument to copy > a project-root-relative path like 'C-u C-u w'? I initially considered M-1 w, but that loses the ability to mark files and then only copy one of them. C-u C-u seems good. Here's the implementation. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Project-support-in-dired-copy-filename-as-kill.patch >From 95bd0a8775284dc59119198b02fcc64b904c4d7f Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 30 Sep 2023 09:49:03 -0400 Subject: [PATCH] Project support in dired-copy-filename-as-kill It is often useful to get a filename relative to project-root; now it is easier. * lisp/dired.el (dired-get-filename): Support 'project. (dired-copy-filename-as-kill): Make C-u C-u pass 'project. --- lisp/dired.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/dired.el b/lisp/dired.el index cc8c74839b9..cc2cf24fac2 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3016,6 +3016,12 @@ dired-get-filename (if (and handler (not (get handler 'safe-magic))) (concat "/:" file) file))) + ((eq localp 'project) + (if-let ((project (project-current nil (dired-current-directory)))) + (file-relative-name + (concat (dired-current-directory) file) + (project-root project)) + (concat (dired-current-directory t) file))) (t (concat (dired-current-directory localp) file))))) @@ -3240,6 +3246,7 @@ dired-copy-filename-as-kill With a zero prefix arg, use the absolute file name of each marked file. With \\[universal-argument], use the file name relative to the Dired buffer's `default-directory'. (This still may contain slashes if in a subdirectory.) +With \\[universal-argument] \\[universal-argument], use the file name relative to `project-root'. If on a subdir headerline, use absolute subdirname instead; prefix arg and marked files are ignored in this case. @@ -3251,8 +3258,10 @@ dired-copy-filename-as-kill (if arg (cond ((zerop (prefix-numeric-value arg)) (dired-get-marked-files)) - ((consp arg) + ((and (consp arg) (= 4 (prefix-numeric-value arg))) (dired-get-marked-files t)) + ((and (consp arg) (>= 16 (prefix-numeric-value arg))) + (dired-get-marked-files 'project)) (t (dired-get-marked-files 'no-dir (prefix-numeric-value arg)))) -- 2.41.0 --=-=-=--