]> code.delx.au - gnu-emacs/commitdiff
Make find-change-log prefer a VCS root, if no ChangeLog exists.
authorGlenn Morris <rgm@gnu.org>
Tue, 2 Feb 2016 02:08:21 +0000 (21:08 -0500)
committerGlenn Morris <rgm@gnu.org>
Tue, 2 Feb 2016 02:08:56 +0000 (21:08 -0500)
* 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.

doc/emacs/maintaining.texi
etc/NEWS
lisp/vc/add-log.el

index 3f1a9c07e91ff7c6e995819ff0a01dc2787dc6b6..72d428af8fbf3fa9187182832134496131f04df8 100644 (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
index 2fdcc7eca08e74498432575f176ac1dc52119ce4..31504325587fff6d5e2f85a11b7c94b486578958 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -52,6 +52,11 @@ in these situations.
 \f
 * 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.
 
index d1a1ba057ef59f7ff905c34c72a8a9ff3195b886..ceb0d4207c9addbe2c4973208050aa00494da467 100644 (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))