;;; add-log.el --- change log maintenance commands for Emacs
-;; Copyright (C) 1985-1986, 1988, 1993-1994, 1997-1998, 2000-2015 Free
+;; Copyright (C) 1985-1986, 1988, 1993-1994, 1997-1998, 2000-2016 Free
;; Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
:type '(repeat regexp)
:group 'change-log)
+(defcustom change-log-directory-files '(".bzr" ".git" ".hg" ".svn")
+ "List of files that cause `find-change-log' 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."
(apply 'change-log-goto-source-1
(append change-log-find-head change-log-find-tail))
(error
- "Cannot find more matches for tag `%s' in file `%s'"
- (car change-log-find-head)
- (nth 2 change-log-find-head))))
+ (format-message
+ "Cannot find more matches for tag `%s' in file `%s'"
+ (car change-log-find-head)
+ (nth 2 change-log-find-head)))))
(save-excursion
(let* ((at (point))
(tag-at (change-log-search-tag-name))
(condition-case nil
(setq change-log-find-tail
(apply 'change-log-goto-source-1 change-log-find-head))
- (error "Cannot find matches for tag `%s' in file `%s'"
- tag file))))))))
+ (error
+ (format-message "Cannot find matches for tag `%s' in file `%s'"
+ tag file)))))))))
(defun change-log-next-error (&optional argp reset)
"Move to the Nth (default 1) next match in a ChangeLog buffer.
If `change-log-default-name' contains a leading directory component, then
simply find it in the current directory. Otherwise, search in the current
-directory and its successive parents for a file so named.
+directory and its successive parents for a file so named. Stop at the first
+such file that exists (or has a buffer visiting it), or the first directory
+that contains any of `change-log-directory-files'. If no match is found,
+use the current directory. To override the choice of this function,
+simply create an empty ChangeLog file first by hand in the desired place.
Once a file is found, `change-log-default-name' is set locally in the
current buffer to the complete file name.
;; for several related directories.
(setq file-name (file-chase-links file-name))
(setq file-name (expand-file-name file-name))
- ;; Move up in the dir hierarchy till we find a change log file.
- (let ((file1 file-name)
- parent-dir)
- (while (and (not (or (get-file-buffer file1) (file-exists-p file1)))
- (progn (setq parent-dir
- (file-name-directory
- (directory-file-name
- (file-name-directory file1))))
- ;; Give up if we are already at the root dir.
- (not (string= (file-name-directory file1)
- parent-dir))))
- ;; Move up to the parent dir and try again.
- (setq file1 (expand-file-name
- (file-name-nondirectory (change-log-name))
- parent-dir)))
- ;; If we found a change log in a parent, use that.
- (if (or (get-file-buffer file1) (file-exists-p file1))
- (setq file-name file1)))))
+ (let* ((cbase (file-name-nondirectory (change-log-name)))
+ (root
+ (locate-dominating-file
+ file-name
+ (lambda (dir)
+ (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))
file-name)
"\\(\\s \\|[(),:]\\)")
bound t)))
;; Add to the existing item for the same file.
- (re-search-forward "^\\s *$\\|^\\s \\*")
- (goto-char (match-beginning 0))
+ (if (re-search-forward "^\\s *$\\|^\\s \\*" nil t)
+ (goto-char (match-beginning 0))
+ (goto-char (point-max))
+ (insert "\n"))
;; Delete excess empty lines; make just 2.
(while (and (not (eobp)) (looking-at "^\\s *$"))
(delete-region (point) (line-beginning-position 2)))