all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: sbaugh@catern.com, 66260@debbugs.gnu.org
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	[thread overview]
Message-ID: <15010505-0b2f-5dc3-e16a-228183779d43@gutov.dev> (raw)
In-Reply-To: <875y3t2827.fsf@catern.com>

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.





  parent reply	other threads:[~2023-10-01 22:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 23:26 bug#66260: 29.0.92; project.el should support copying a file path relative to the project root sbaugh
2023-09-29  6:57 ` Juri Linkov
2023-09-30 13:50   ` sbaugh
2023-09-30 14:47     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-30 15:17       ` sbaugh
2023-10-01 22:44 ` Dmitry Gutov [this message]
2023-10-02  5:57   ` Eli Zaretskii
2023-10-02  6:53     ` Juri Linkov
2023-10-02 11:46       ` Dmitry Gutov
2023-10-03 20:49         ` sbaugh
2023-10-03 21:17           ` Dmitry Gutov
2023-10-02 11:13     ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 13:13   ` sbaugh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15010505-0b2f-5dc3-e16a-228183779d43@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=66260@debbugs.gnu.org \
    --cc=sbaugh@catern.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.