Commit a82e2ed5 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(find-change-log): If file name specified, just use it.

parent 4ced3209
...@@ -67,55 +67,53 @@ an `@' character, followed by the value returned by `system-name'.") ...@@ -67,55 +67,53 @@ an `@' character, followed by the value returned by `system-name'.")
;;;###autoload ;;;###autoload
(defun find-change-log (&optional file-name) (defun find-change-log (&optional file-name)
"Find a change log file for \\[add-change-log-entry] and return the name. "Find a change log file for \\[add-change-log-entry] and return the name.
Optional arg FILE-NAME is a name to try first.
Optional arg FILE-NAME specifies the file to use.
If FILE-NAME is nil, use the value of `change-log-default-name' if non-nil. If FILE-NAME is nil, use the value of `change-log-default-name' if non-nil.
Failing that, use \"ChangeLog\" in the current directory. Otherwise, search in the current directory and its successive parents
If the file does not exist in the named directory, successive parent for a file named `ChangeLog' (or whatever we use on this operating system).
directories are tried.
Once a file is found, `change-log-default-name' is set locally in the Once a file is found, `change-log-default-name' is set locally in the
current buffer to the complete file name." current buffer to the complete file name."
;; If user specified a file name or if this buffer knows which one to use,
;; just use that.
(or file-name (or file-name
(setq file-name (or change-log-default-name (setq file-name change-log-default-name)
;; Chase links in the source file (progn
;; and use the change log in the dir where it points. ;; Chase links in the source file
(and buffer-file-name ;; and use the change log in the dir where it points.
(file-name-directory (setq file-name (or (and buffer-file-name
(file-chase-links buffer-file-name))) (file-name-directory
default-directory))) (file-chase-links buffer-file-name)))
(if (and (eq file-name change-log-default-name) default-directory))
(assq 'change-log-default-name (buffer-local-variables))) (if (file-directory-p file-name)
;; Don't do the searching if we already have a buffer-local value. (setq file-name (expand-file-name (change-log-name) file-name)))
file-name ;; Chase links before visiting the file.
;; This makes it easier to use a single change log file
(if (file-directory-p file-name) ;; for several related directories.
(setq file-name (expand-file-name (change-log-name) file-name))) (setq file-name (file-chase-links file-name))
;; Chase links before visiting the file. (setq file-name (expand-file-name file-name))
;; This makes it easier to use a single change log file ;; Move up in the dir hierarchy till we find a change log file.
;; for several related directories. (let ((file1 file-name)
(setq file-name (file-chase-links file-name)) parent-dir)
(setq file-name (expand-file-name file-name)) (while (and (not (or (get-file-buffer file1) (file-exists-p file1)))
;; Move up in the dir hierarchy till we find a change log file. (progn (setq parent-dir
(let ((file1 file-name) (file-name-directory
parent-dir) (directory-file-name
(while (and (not (or (get-file-buffer file1) (file-exists-p file1))) (file-name-directory file1))))
(progn (setq parent-dir ;; Give up if we are already at the root dir.
(file-name-directory (not (string= (file-name-directory file1)
(directory-file-name parent-dir))))
(file-name-directory file1)))) ;; Move up to the parent dir and try again.
;; Give up if we are already at the root dir. (setq file1 (expand-file-name
(not (string= (file-name-directory file1) (file-name-nondirectory (change-log-name))
parent-dir)))) parent-dir)))
;; Move up to the parent dir and try again. ;; If we found a change log in a parent, use that.
(setq file1 (expand-file-name (if (or (get-file-buffer file1) (file-exists-p file1))
(file-name-nondirectory (change-log-name)) (setq file-name file1)))))
parent-dir))) ;; Make a local variable in this buffer so we needn't search again.
;; If we found a change log in a parent, use that. (set (make-local-variable 'change-log-default-name) file-name)
(if (or (get-file-buffer file1) (file-exists-p file1)) file-name)
(setq file-name file1)))
;; 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))
;;;###autoload ;;;###autoload
(defun add-change-log-entry (&optional whoami file-name other-window new-entry) (defun add-change-log-entry (&optional whoami file-name other-window new-entry)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment