Function: find-change-log
find-change-log is an autoloaded and byte-compiled function defined in
add-log.el.gz.
Signature
(find-change-log &optional FILE-NAME BUFFER-FILE)
Documentation
Find a change log file for M-x add-change-log-entry (add-change-log-entry) and return the name.
Optional arg FILE-NAME specifies the file to use.
If FILE-NAME is nil, use the value of change-log-default-name.
If change-log-default-name is nil, behave as though it were "ChangeLog"
(or whatever we use on this operating system).
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. 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.
Optional arg BUFFER-FILE overrides buffer-file-name(var)/buffer-file-name(fun).
Source Code
;; Defined in /usr/src/emacs/lisp/vc/add-log.el.gz
;;;###autoload
(defun find-change-log (&optional file-name buffer-file)
"Find a change log file for \\[add-change-log-entry] and return the name.
Optional arg FILE-NAME specifies the file to use.
If FILE-NAME is nil, use the value of `change-log-default-name'.
If `change-log-default-name' is nil, behave as though it were \"ChangeLog\"
\(or whatever we use on this operating system).
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. 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.
Optional arg BUFFER-FILE overrides `buffer-file-name'."
;; If we are called from a diff, first switch to the source buffer;
;; in order to respect buffer-local settings of change-log-default-name, etc.
(with-current-buffer (let ((buff (if (derived-mode-p 'diff-mode)
(car (ignore-errors
(diff-find-source-location))))))
(if (buffer-live-p buff) buff
(current-buffer)))
;; If user specified a file name or if this buffer knows which one to use,
;; just use that.
(or file-name
(setq file-name (and change-log-default-name
(file-name-directory change-log-default-name)
change-log-default-name))
(progn
;; Chase links in the source file
;; and use the change log in the dir where it points.
(setq file-name (or (and (or buffer-file buffer-file-name)
(file-name-directory
(file-chase-links
(or buffer-file buffer-file-name))))
default-directory))
(if (file-directory-p file-name)
(setq file-name (expand-file-name (change-log-name) file-name)))
;; Chase links before visiting the file.
;; This makes it easier to use a single change log file
;; for several related directories.
(setq file-name (file-chase-links file-name))
(setq file-name (expand-file-name file-name))
(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.
(setq-local change-log-default-name file-name))
file-name)