Mercurial > emacs
comparison lisp/add-log.el @ 2712:8291de1718d4
(find-change-log): If there is a buffer-local value of
change-log-default-name, just return it with no searching. Previously a if
it was set to a nonexistent file name, we would loop forever.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Sun, 09 May 1993 23:16:19 +0000 |
parents | d3c9f0ad5964 |
children | 6ae7487f1a3d |
comparison
equal
deleted
inserted
replaced
2711:2c2052ec537d | 2712:8291de1718d4 |
---|---|
53 Once a file is found, `change-log-default-name' is set locally in the | 53 Once a file is found, `change-log-default-name' is set locally in the |
54 current buffer to the complete file name." | 54 current buffer to the complete file name." |
55 (or file-name | 55 (or file-name |
56 (setq file-name (or change-log-default-name | 56 (setq file-name (or change-log-default-name |
57 default-directory))) | 57 default-directory))) |
58 (if (file-directory-p file-name) | 58 (if (and (eq file-name change-log-default-name) |
59 (setq file-name (expand-file-name (change-log-name) file-name))) | 59 (assq 'change-log-default-name (buffer-local-variables))) |
60 ;; Chase links before visiting the file. | 60 ;; Don't do the searching if we already have a buffer-local value. |
61 ;; This makes it easier to use a single change log file | 61 file-name |
62 ;; for several related directories. | 62 |
63 (setq file-name | 63 (if (file-directory-p file-name) |
64 (expand-file-name (or (file-symlink-p file-name) file-name))) | 64 (setq file-name (expand-file-name (change-log-name) file-name))) |
65 ;; Move up in the dir hierarchy till we find a change log file. | 65 ;; Chase links before visiting the file. |
66 (let ((file1 file-name) | 66 ;; This makes it easier to use a single change log file |
67 parent-dir) | 67 ;; for several related directories. |
68 (while (and (not (file-exists-p file1)) | 68 (setq file-name |
69 (progn (setq parent-dir | 69 (expand-file-name (or (file-symlink-p file-name) file-name))) |
70 (file-name-directory | 70 ;; Move up in the dir hierarchy till we find a change log file. |
71 (directory-file-name | 71 (let ((file1 file-name) |
72 (file-name-directory file1)))) | 72 parent-dir) |
73 ;; Give up if we are already at the root dir. | 73 (while (and (not (file-exists-p file1)) |
74 (not (string= (file-name-directory file1) parent-dir)))) | 74 (progn (setq parent-dir |
75 ;; Move up to the parent dir and try again. | 75 (file-name-directory |
76 (setq file1 (expand-file-name (change-log-name) parent-dir))) | 76 (directory-file-name |
77 ;; If we found a change log in a parent, use that. | 77 (file-name-directory file1)))) |
78 (if (file-exists-p file1) | 78 ;; Give up if we are already at the root dir. |
79 (setq file-name file1))) | 79 (not (string= (file-name-directory file1) |
80 ;; Make a local variable in this buffer so we needn't search again. | 80 parent-dir)))) |
81 (set (make-local-variable 'change-log-default-name) file-name) | 81 ;; Move up to the parent dir and try again. |
82 file-name) | 82 (setq file1 (expand-file-name (change-log-name) parent-dir))) |
83 ;; If we found a change log in a parent, use that. | |
84 (if (file-exists-p file1) | |
85 (setq file-name file1))) | |
86 ;; Make a local variable in this buffer so we needn't search again. | |
87 (set (make-local-variable 'change-log-default-name) file-name) | |
88 file-name)) | |
83 | 89 |
84 ;;;###autoload | 90 ;;;###autoload |
85 (defun add-change-log-entry (&optional whoami file-name other-window) | 91 (defun add-change-log-entry (&optional whoami file-name other-window) |
86 "Find change log file and add an entry for today. | 92 "Find change log file and add an entry for today. |
87 Optional arg (interactive prefix) non-nil means prompt for user name and site. | 93 Optional arg (interactive prefix) non-nil means prompt for user name and site. |