From: Glenn Morris Date: Tue, 2 Feb 2016 02:08:21 +0000 (-0500) Subject: Make find-change-log prefer a VCS root, if no ChangeLog exists. X-Git-Tag: emacs-26.0.90~2760 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc435af152e6df3d85b0c21eaf9ff39dce0091bb;p=emacs.git 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. --- diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 3f1a9c07e91..72d428af8fb 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 2fdcc7eca08..31504325587 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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. diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index d1a1ba057ef..ceb0d4207c9 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -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))