Make find-change-log prefer a VCS root, if no ChangeLog exists.

* lisp/vc/add-log.el (change-log-directory-files): New option.
(find-change-log): Respect change-log-directory-files.
* doc/emacs/maintaining.texi (Change Log Commands):
Mention change-log-directory-files.
; * etc/NEWS: Mention this.
This commit is contained in:
Glenn Morris 2016-02-01 21:08:21 -05:00
parent a39a03a3bf
commit dc435af152
3 changed files with 35 additions and 6 deletions

View file

@ -1590,6 +1590,13 @@ also creates a new item for the current file. For many languages, it
can even guess the name of the function or other object that was
changed.
@c Not worth it.
@c @vindex change-log-directory-files
To find the change log file, Emacs searches up the directory tree from
the file you are editing. By default, it stops if it finds a
directory that seems to be the root of a version-control repository.
To change this, customize @code{change-log-directory-files}.
@vindex add-log-keep-changes-together
When the variable @code{add-log-keep-changes-together} is
non-@code{nil}, @kbd{C-x 4 a} adds to any existing item for the file

View file

@ -52,6 +52,11 @@ in these situations.
* Changes in Specialized Modes and Packages in Emacs 25.2
+++
** The commands that add ChangeLog entries now prefer a VCS root directory
for the ChangeLog file, if none already exists. Customize
`change-log-directory-files' to nil for the old behavior.
---
** Support for non-string values of `time-stamp-format' has been removed.

View file

@ -171,6 +171,14 @@ Note: The search is conducted only within 10%, at the beginning of the file."
:type '(repeat regexp)
:group 'change-log)
(defcustom change-log-directory-files '(".bzr" ".git" ".hg" ".svn")
"List of files that cause ChangeLog search to stop in containing directory.
This applies if no pre-existing ChangeLog is found. If nil, then in such
a case simply use the directory containing the changed file."
:version "25.2"
:type '(repeat file)
:group 'change-log)
(defface change-log-date
'((t (:inherit font-lock-string-face)))
"Face used to highlight dates in date lines."
@ -726,15 +734,24 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'."
(setq file-name (expand-file-name file-name))
(let* ((cbase (file-name-nondirectory (change-log-name)))
(root
;; TODO stopping at VCS root dir (if present) is appropriate
;; for Emacs these days (we used to have per-directory
;; ChangeLogs), and probably most others too.
;; But it could be optional behavior.
(locate-dominating-file
file-name
(lambda (dir)
(let ((clog (expand-file-name cbase dir)))
(or (get-file-buffer clog) (file-exists-p clog)))))))
(or
(let ((clog (expand-file-name cbase dir)))
(or (get-file-buffer clog) (file-exists-p clog)))
;; Stop at VCS root?
(and change-log-directory-files
(let ((files change-log-directory-files)
found)
(while
(and
(not
(setq found
(file-exists-p
(expand-file-name (car files) dir))))
(setq files (cdr files))))
found)))))))
(if root (setq file-name (expand-file-name cbase root))))))
;; Make a local variable in this buffer so we needn't search again.
(set (make-local-variable 'change-log-default-name) file-name))