From: Philip Kaludercic <philipk@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 55039@debbugs.gnu.org
Subject: bug#55039: [PATCH] Use VC-relative file names in ChangeLog entries
Date: Wed, 07 Sep 2022 15:53:29 +0000 [thread overview]
Message-ID: <87h71jnpty.fsf@posteo.net> (raw)
In-Reply-To: <83wnafgvre.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 07 Sep 2022 16:27:17 +0300")
[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Philip Kaludercic <philipk@posteo.net>
>> Cc: Eli Zaretskii <eliz@gnu.org>, 55039@debbugs.gnu.org
>> Date: Tue, 06 Sep 2022 20:10:41 +0000
>>
>> --- a/doc/emacs/maintaining.texi
>> +++ b/doc/emacs/maintaining.texi
>> @@ -694,7 +694,10 @@ Log Buffer
>> (@code{log-edit-generate-changelog-from-diff}), to generate skeleton
>> ChangeLog entries, listing all changed file and function names based
>> on the diff of the VC fileset. Consecutive entries left empty will be
>> -combined by @kbd{C-q} (@code{fill-paragraph}).
>> +combined by @kbd{C-q} (@code{fill-paragraph}). By default the
>> +inserted file names will just be the files without a path. If
>> +@code{diff-add-log-relative-names} is non-nil, a partial path relative
>> +to the VC root directory will be inserted instead.
>
> GNU Coding Standards frown on using "path" for anything but PATH-style
> directory lists. Please use "leading directories" or somesuch here,
> as that's what you mean.
I've just remove the changes to the manual from my patch.
>> +*** New user option 'diff-relative-names-in-changelog'.
>> +If non-nil insert file names in ChangeLog skeletons relative to the
> ^
> Comma missing there.
Done.
>> +(defcustom diff-add-log-relative-names nil
>> + "Use relative file names when generating ChangeLog messages."
>
> This doesn't say relative to what. It also doesn't mention the
> commands which are affected.
Added.
>> (defun diff-add-log-current-defuns ()
>> "Return an alist of defun names for the current diff.
>> The elements of the alist are of the form (FILE . (DEFUN...)),
>> -where DEFUN... is a list of function names found in FILE."
>> +where DEFUN... is a list of function names found in FILE. If
>> +`diff-add-log-relative-names' is non-nil, insert file names
>> +relative to the VC root directory."
>
> The "insert" part is out of place here, since there's no insertion.
>
> How about
>
> If `diff-add-log-relative-names' is non-nil, file names in the alist
> are relative to the root directory of the VC repository.
>
> instead?
I like it.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-new-user-option-diff-add-log-use-relative-names.patch --]
[-- Type: text/x-diff, Size: 3545 bytes --]
From 8ef441e5d5340b06dd04d294a384ae05bf7f5615 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Tue, 6 Sep 2022 22:06:29 +0200
Subject: [PATCH] Add new user option 'diff-add-log-use-relative-names'
* .dir-locals.el: Set 'diff-add-log-use-relative-names' to t
* etc/NEWS: Mention 'diff-add-log-relative-names'
* lisp/vc/diff-mode.el (diff-add-log-use-relative-names): Add new option.
(diff-add-log-current-defuns): Use new option.
---
.dir-locals.el | 3 ++-
etc/NEWS | 5 +++++
lisp/vc/diff-mode.el | 20 ++++++++++++++++++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
index 1c90ddcf56..9882a19f85 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -5,7 +5,8 @@
(sentence-end-double-space . t)
(fill-column . 70)
(emacs-lisp-docstring-fill-column . 65)
- (bug-reference-url-format . "https://debbugs.gnu.org/%s")))
+ (bug-reference-url-format . "https://debbugs.gnu.org/%s")
+ (diff-add-log-use-relative-names . t)))
(c-mode . ((c-file-style . "GNU")
(c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" "UNINIT" "CALLBACK" "ALIGN_STACK"))
(electric-quote-comment . nil)
diff --git a/etc/NEWS b/etc/NEWS
index b61b88d6fb..76c66a8e39 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1340,6 +1340,11 @@ Sets the value of the buffer-local variable 'whitespace-style' in
'diff-mode' buffers. By default, this variable is '(face trailing)',
which preserves behavior from previous Emacs versions.
++++
+*** New user option 'diff-add-log-use-relative-names'.
+If non-nil insert file names in ChangeLog skeletons relative to the
+VC root directory.
+
** Ispell
---
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index a01943437c..1d2fbca0e5 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2336,10 +2336,21 @@ diff-undo
(let ((inhibit-read-only t))
(undo arg)))
+(defcustom diff-add-log-use-relative-names nil
+ "Use relative file names when generating ChangeLog skeletons.
+The files will be relative to the root directory of the VC
+repository. This option affects the behaviour of
+`diff-add-log-current-defuns'."
+ :type 'boolean
+ :safe #'booleanp
+ :version "29.1")
+
(defun diff-add-log-current-defuns ()
"Return an alist of defun names for the current diff.
The elements of the alist are of the form (FILE . (DEFUN...)),
-where DEFUN... is a list of function names found in FILE."
+where DEFUN... is a list of function names found in FILE. If
+`diff-add-log-use-relative-names' is non-nil, file names in the alist
+are relative to the root directory of the VC repository."
(save-excursion
(goto-char (point-min))
(let* ((defuns nil)
@@ -2373,7 +2384,12 @@ diff-add-log-current-defuns
;; hunks (e.g., "diff --git ..." etc).
(re-search-forward diff-hunk-header-re nil t)
(setq hunk-end (save-excursion (diff-end-of-hunk)))
- (pcase-let* ((filename (substring-no-properties (diff-find-file-name)))
+ (pcase-let* ((filename (substring-no-properties
+ (if diff-add-log-use-relative-names
+ (file-relative-name
+ (diff-find-file-name)
+ (vc-root-dir))
+ (diff-find-file-name))))
(=lines 0)
(+lines 0)
(-lines 0)
--
2.30.2
next prev parent reply other threads:[~2022-09-07 15:53 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 14:19 bug#55039: [PATCH] Use VC-relative file names in ChangeLog entries Philip Kaludercic
2022-04-20 16:01 ` Eli Zaretskii
2022-09-06 11:13 ` Lars Ingebrigtsen
2022-09-06 11:24 ` Eli Zaretskii
2022-09-06 11:30 ` Lars Ingebrigtsen
2022-09-06 12:45 ` Philip Kaludercic
2022-09-06 14:34 ` Philip Kaludercic
2022-09-06 14:39 ` Lars Ingebrigtsen
2022-09-06 14:58 ` Robert Pluim
2022-09-06 15:02 ` Philip Kaludercic
2022-09-06 15:46 ` Eli Zaretskii
2022-09-06 20:11 ` Philip Kaludercic
2022-09-08 7:07 ` Eli Zaretskii
2022-09-08 8:45 ` Philip Kaludercic
2022-09-08 9:20 ` Eli Zaretskii
2022-09-08 12:11 ` Lars Ingebrigtsen
2022-09-08 12:19 ` Visuwesh
2022-09-08 12:33 ` Lars Ingebrigtsen
2022-09-08 12:43 ` Philip Kaludercic
2022-09-08 12:44 ` Lars Ingebrigtsen
2022-09-08 12:53 ` Philip Kaludercic
2022-09-08 12:56 ` Lars Ingebrigtsen
2022-09-11 8:16 ` Philip Kaludercic
2022-09-11 11:08 ` Lars Ingebrigtsen
2022-09-08 12:56 ` Robert Pluim
2022-09-08 13:10 ` Lars Ingebrigtsen
2022-09-08 13:13 ` Visuwesh
2022-09-08 12:52 ` Robert Pluim
2022-09-06 16:13 ` Juri Linkov
2022-09-06 20:10 ` Philip Kaludercic
2022-09-07 10:08 ` Robert Pluim
2022-09-07 12:48 ` Lars Ingebrigtsen
2022-09-07 13:27 ` Eli Zaretskii
2022-09-07 15:53 ` Philip Kaludercic [this message]
2022-09-07 18:12 ` Eli Zaretskii
2022-09-07 18:27 ` Philip Kaludercic
2022-09-07 18:46 ` Eli Zaretskii
2022-09-07 21:23 ` Philip Kaludercic
2022-09-08 5:38 ` Eli Zaretskii
2022-09-08 6:22 ` Philip Kaludercic
2022-09-08 2:58 ` Richard Stallman
2022-09-08 6:18 ` Philip Kaludercic
2022-04-22 3:03 ` Richard Stallman
2022-04-22 5:29 ` Eli Zaretskii
2022-04-23 3:46 ` Richard Stallman
2022-04-23 6:17 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h71jnpty.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=55039@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).