emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master dc435af: Make find-change-log prefer a VCS root, if


From: Glenn Morris
Subject: [Emacs-diffs] master dc435af: Make find-change-log prefer a VCS root, if no ChangeLog exists.
Date: Tue, 02 Feb 2016 02:09:05 +0000

branch: master
commit dc435af152e6df3d85b0c21eaf9ff39dce0091bb
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    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.
---
 doc/emacs/maintaining.texi |    7 +++++++
 etc/NEWS                   |    5 +++++
 lisp/vc/add-log.el         |   29 +++++++++++++++++++++++------
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 3f1a9c0..72d428a 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.
 
address@hidden Not worth it.
address@hidden @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
 address@hidden, @kbd{C-x 4 a} adds to any existing item for the file
diff --git a/etc/NEWS b/etc/NEWS
index 2fdcc7e..3150432 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 d1a1ba0..ceb0d42 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]