|
From: | Dmitry Gutov |
Subject: | 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 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 29/09/2023 02:26, sbaugh@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.
[Prev in Thread] | Current Thread | [Next in Thread] |