diff options
| author | Roland McGrath | 1993-04-05 23:48:01 +0000 |
|---|---|---|
| committer | Roland McGrath | 1993-04-05 23:48:01 +0000 |
| commit | 45a13f0da338254460e6b0875ae7578b4446b5bb (patch) | |
| tree | 0197e14743b00928a5b008c6b4132b84cb2143dd | |
| parent | 773c1fd398fd3506f0d2bc6c28e65a51b392715d (diff) | |
| download | emacs-45a13f0da338254460e6b0875ae7578b4446b5bb.tar.gz emacs-45a13f0da338254460e6b0875ae7578b4446b5bb.zip | |
(find-change-log): New function.
(add-change-log-entry): FILE-NAME frobnicating code moved there; call it.
| -rw-r--r-- | lisp/add-log.el | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el index 7b3b6d26c67..1a4a6561455 100644 --- a/lisp/add-log.el +++ b/lisp/add-log.el | |||
| @@ -42,6 +42,46 @@ | |||
| 42 | nil default)))) | 42 | nil default)))) |
| 43 | 43 | ||
| 44 | ;;;###autoload | 44 | ;;;###autoload |
| 45 | (defun find-change-log (&optional file-name) | ||
| 46 | "Find a change log file for \\[add-change-log-entry] and return the name. | ||
| 47 | Optional arg FILE-NAME is a name to try first. | ||
| 48 | If FILE-NAME is nil, use the value of `change-log-default-name' if non-nil. | ||
| 49 | Failing that, use \"ChangeLog\" in the current directory. | ||
| 50 | If the file does not exist in the named directory, successive parent | ||
| 51 | directories are tried. | ||
| 52 | |||
| 53 | Once a file is found, `change-log-default-name' is set locally in the | ||
| 54 | current buffer to the complete file name." | ||
| 55 | (or file-name | ||
| 56 | (setq file-name (or change-log-default-name | ||
| 57 | default-directory))) | ||
| 58 | (if (file-directory-p file-name) | ||
| 59 | (setq file-name (expand-file-name (change-log-name) file-name))) | ||
| 60 | ;; Chase links before visiting the file. | ||
| 61 | ;; This makes it easier to use a single change log file | ||
| 62 | ;; for several related directories. | ||
| 63 | (setq file-name | ||
| 64 | (expand-file-name (or (file-symlink-p file-name) file-name))) | ||
| 65 | ;; Move up in the dir hierarchy till we find a change log file. | ||
| 66 | (let ((file1 file-name) | ||
| 67 | parent-dir) | ||
| 68 | (while (and (not (file-exists-p file1)) | ||
| 69 | (progn (setq parent-dir | ||
| 70 | (file-name-directory | ||
| 71 | (directory-file-name | ||
| 72 | (file-name-directory file1)))) | ||
| 73 | ;; Give up if we are already at the root dir. | ||
| 74 | (not (string= (file-name-directory file1) parent-dir)))) | ||
| 75 | ;; Move up to the parent dir and try again. | ||
| 76 | (setq file1 (expand-file-name (change-log-name) parent-dir))) | ||
| 77 | ;; If we found a change log in a parent, use that. | ||
| 78 | (if (file-exists-p file1) | ||
| 79 | (setq file-name file1))) | ||
| 80 | ;; Make a local variable in this buffer so we needn't search again. | ||
| 81 | (set (make-local-variable 'change-log-default-name) file-name) | ||
| 82 | file-name) | ||
| 83 | |||
| 84 | ;;;###autoload | ||
| 45 | (defun add-change-log-entry (&optional whoami file-name other-window) | 85 | (defun add-change-log-entry (&optional whoami file-name other-window) |
| 46 | "Find change log file and add an entry for today. | 86 | "Find change log file and add an entry for today. |
| 47 | Optional arg (interactive prefix) non-nil means prompt for user name and site. | 87 | Optional arg (interactive prefix) non-nil means prompt for user name and site. |
| @@ -64,34 +104,8 @@ Third arg OTHER-WINDOW non-nil means visit in other window." | |||
| 64 | (system-name))) | 104 | (system-name))) |
| 65 | (defun (add-log-current-defun)) | 105 | (defun (add-log-current-defun)) |
| 66 | paragraph-end entry) | 106 | paragraph-end entry) |
| 67 | (or file-name | ||
| 68 | (setq file-name (or change-log-default-name | ||
| 69 | default-directory))) | ||
| 70 | (setq file-name (if (file-directory-p file-name) | ||
| 71 | (expand-file-name (change-log-name) file-name) | ||
| 72 | (expand-file-name file-name))) | ||
| 73 | ;; Chase links before visiting the file. | ||
| 74 | ;; This makes it easier to use a single change log file | ||
| 75 | ;; for several related directories. | ||
| 76 | (setq file-name | ||
| 77 | (expand-file-name (or (file-symlink-p file-name) file-name))) | ||
| 78 | ;; Move up in the dir hierarchy till we find a change log file. | ||
| 79 | (let ((file1 file-name) | ||
| 80 | parent-dir) | ||
| 81 | (while (and (not (file-exists-p file1)) | ||
| 82 | (progn (setq parent-dir | ||
| 83 | (file-name-directory | ||
| 84 | (directory-file-name | ||
| 85 | (file-name-directory file1)))) | ||
| 86 | ;; Give up if we are already at the root dir. | ||
| 87 | (not (string= (file-name-directory file1) parent-dir)))) | ||
| 88 | ;; Move up to the parent dir and try again. | ||
| 89 | (setq file1 (expand-file-name (change-log-name) parent-dir))) | ||
| 90 | ;; If we found a change log in a parent, use that. | ||
| 91 | (if (file-exists-p file1) | ||
| 92 | (setq file-name file1))) | ||
| 93 | 107 | ||
| 94 | (set (make-local-variable 'change-log-default-name) file-name) | 108 | (setq file-name (find-change-log file-name)) |
| 95 | 109 | ||
| 96 | ;; Set ENTRY to the file name to use in the new entry. | 110 | ;; Set ENTRY to the file name to use in the new entry. |
| 97 | (and buffer-file-name | 111 | (and buffer-file-name |