1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Add new user option 'diff-add-log-use-relative-names'

* .dir-locals.el: Set new option to t
* etc/NEWS: Mention new option.
* lisp/vc/diff-mode.el (diff-add-log-use-relative-names): Add new option.
(diff-add-log-current-defuns): Use new option.
* doc/emacs/maintaining.texi (Log Buffer): Mention new option.
This commit is contained in:
Philip Kaludercic 2022-09-06 22:06:29 +02:00 committed by Philip Kaludercic
parent 56f3cdef6b
commit 740a1a3d0e
4 changed files with 30 additions and 4 deletions

View file

@ -5,7 +5,8 @@
(sentence-end-double-space . t) (sentence-end-double-space . t)
(fill-column . 70) (fill-column . 70)
(emacs-lisp-docstring-fill-column . 65) (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-mode . ((c-file-style . "GNU")
(c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" "UNINIT" "CALLBACK" "ALIGN_STACK")) (c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" "UNINIT" "CALLBACK" "ALIGN_STACK"))
(electric-quote-comment . nil) (electric-quote-comment . nil)

View file

@ -690,11 +690,15 @@ started editing (@pxref{Old Revisions}), type @kbd{C-c C-d}
@kindex C-c C-w @r{(Log Edit mode)} @kindex C-c C-w @r{(Log Edit mode)}
@findex log-edit-generate-changelog-from-diff @findex log-edit-generate-changelog-from-diff
@vindex diff-add-log-use-relative-names
To help generate ChangeLog entries, type @kbd{C-c C-w} To help generate ChangeLog entries, type @kbd{C-c C-w}
(@code{log-edit-generate-changelog-from-diff}), to generate skeleton (@code{log-edit-generate-changelog-from-diff}), to generate skeleton
ChangeLog entries, listing all changed file and function names based ChangeLog entries, listing all changed file and function names based
on the diff of the VC fileset. Consecutive entries left empty will be 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
skeleton will just include the file name, without any leading
directories. If you wish to prepend the leading directories up to the
VC root, customize @code{diff-add-log-use-relative-names}.
@kindex C-c C-a @r{(Log Edit mode)} @kindex C-c C-a @r{(Log Edit mode)}
@findex log-edit-insert-changelog @findex log-edit-insert-changelog

View file

@ -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)', 'diff-mode' buffers. By default, this variable is '(face trailing)',
which preserves behavior from previous Emacs versions. 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 ** Ispell
--- ---

View file

@ -2336,10 +2336,21 @@ Call FUN with two args (BEG and END) for each hunk."
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(undo arg))) (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 () (defun diff-add-log-current-defuns ()
"Return an alist of defun names for the current diff. "Return an alist of defun names for the current diff.
The elements of the alist are of the form (FILE . (DEFUN...)), 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 (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(let* ((defuns nil) (let* ((defuns nil)
@ -2373,7 +2384,12 @@ where DEFUN... is a list of function names found in FILE."
;; hunks (e.g., "diff --git ..." etc). ;; hunks (e.g., "diff --git ..." etc).
(re-search-forward diff-hunk-header-re nil t) (re-search-forward diff-hunk-header-re nil t)
(setq hunk-end (save-excursion (diff-end-of-hunk))) (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) (+lines 0)
(-lines 0) (-lines 0)