GNU bug report logs - #66260
29.0.92; project.el should support copying a file path relative to the project root

Previous Next

Package: emacs;

Reported by: sbaugh <at> catern.com

Date: Thu, 28 Sep 2023 23:28:02 UTC

Severity: wishlist

Found in version 29.0.92

Full log


Message #22 received at 66260 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: sbaugh <at> catern.com, 66260 <at> debbugs.gnu.org
Subject: Re: bug#66260: 29.0.92; project.el should support copying a file path
 relative to the project root
Date: Mon, 2 Oct 2023 01:44:38 +0300
On 29/09/2023 02:26, sbaugh <at> catern.com wrote:
> When communicating with others, it is often useful to copy a file path
> to the current file which is relative to the project root.  For example
> I'd rather send someone the path lisp/progmodes/project.el than
> ~/src/emacs/trunk/lisp/progmodes/project.el.
> 
> project.el should have a way to copy this file path.
> 
> Almost good enough is:
> 
>   C-x p f       ;; project-find-file
>   M-n	       ;; next-history-element
>   C-k	       ;; kill-line
> 
> but with project--read-file-cpd-relative, if all the files in
> project-files start with a common-parent-directory which is a
> subdirectory of project-root, the resulting file path will not be
> relative to the project-root but to the subdirectory.

A problem with modifying the above function's behavior like that is that 
sometimes it is passed a wider range of file names, where not all of 
them are inside the project root (M-x project-or-external-find-file).

> Maybe the thing to do is just make project--read-file-cpd-relative use
> project-root instead of calculating a common-parent-directory?  I would
> be happy to make that patch if that's acceptable.  I think that's
> probably the best option.
> 
> Alternatively, it might be cool if there was a variation on:
> 
>   C-x C-j     ;; dired-jump
>   M-0	     ;; digit-argument
>   w	     ;; dired-copy-filename-as-kill
> 
> (which copies an absolute path) to instead copy a project-root-relative
> path.

This is unfortunately less discoverable, but sounds good otherwise.

Regarding the potential binding (discussed further downthread), I have 
no opinion: copying the relative name doesn't happen too often for me, 
and when it does, I can usually do that from the VC-Dir buffer (where 
the file in question would usually be 'edited'). Should we add 'w' to 
vc-dir-mode too?

'C-x p w' does make sense as such, but it would be unfortunate if we 
find a more important command later which fits the 'w' mnemonics. Maybe 
'C-x p W' would be a more conservative choice.




This bug report was last modified 1 year and 292 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.