# HG changeset patch # User Stefan Monnier # Date 970250631 0 # Node ID 534b5a76bf8a930d948a2ca77a5163c9e2537153 # Parent da53436a22fe998e4375add2366cfa8655811b9d (find-change-log): New arg BUFFER-FILE. (add-log-file-name): Obey add-log-file-name-function. (add-log-buffer-file-name-function): New var. (add-change-log-entry): Use it. diff -r da53436a22fe -r 534b5a76bf8a lisp/add-log.el --- a/lisp/add-log.el Fri Sep 29 16:20:03 2000 +0000 +++ b/lisp/add-log.el Fri Sep 29 18:03:51 2000 +0000 @@ -116,6 +116,13 @@ :type 'boolean :group 'change-log) +(defcustom add-log-buffer-file-name-function nil + "*If non-nil, function to call to identify the full filename of a buffer. +This function is called with no argument. If this is nil, the default is to +use `buffer-file-name'." + :type 'function + :group 'change-log) + (defcustom add-log-file-name-function nil "*If non-nil, function to call to identify the filename for a ChangeLog entry. This function is called with one argument, the value of variable @@ -303,8 +310,7 @@ (/ size 10) size)) version) - (or (and buffer-file-name - (vc-workfile-version buffer-file-name)) + (or (and buffer-file-name (vc-workfile-version buffer-file-name)) (save-restriction (widen) (let ((regexps change-log-version-number-regexp-list)) @@ -317,7 +323,7 @@ ;;;###autoload -(defun find-change-log (&optional file-name) +(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. @@ -330,7 +336,8 @@ directory and its successive parents for a file so named. 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. +Optional arg BUFFER-FILE overrides `buffer-file-name'." ;; If user specified a file name or if this buffer knows which one to use, ;; just use that. (or file-name @@ -340,9 +347,10 @@ (progn ;; Chase links in the source file ;; and use the change log in the dir where it points. - (setq file-name (or (and buffer-file-name + (setq file-name (or (and (or buffer-file buffer-file-name) (file-name-directory - (file-chase-links buffer-file-name))) + (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))) @@ -376,18 +384,20 @@ (defun add-log-file-name (buffer-file log-file) ;; Never want to add a change log entry for the ChangeLog file itself. (unless (or (null buffer-file) (string= buffer-file log-file)) - (setq buffer-file - (if (string-match - (concat "^" (regexp-quote (file-name-directory log-file))) - buffer-file) - (substring buffer-file (match-end 0)) - (file-name-nondirectory buffer-file))) - ;; If we have a backup file, it's presumably because we're - ;; comparing old and new versions (e.g. for deleted - ;; functions) and we'll want to use the original name. - (if (backup-file-name-p buffer-file) - (file-name-sans-versions buffer-file) - buffer-file))) + (if add-log-file-name-function + (funcall add-log-file-name-function buffer-file) + (setq buffer-file + (if (string-match + (concat "^" (regexp-quote (file-name-directory log-file))) + buffer-file) + (substring buffer-file (match-end 0)) + (file-name-nondirectory buffer-file))) + ;; If we have a backup file, it's presumably because we're + ;; comparing old and new versions (e.g. for deleted + ;; functions) and we'll want to use the original name. + (if (backup-file-name-p buffer-file) + (file-name-sans-versions buffer-file) + buffer-file)))) ;;;###autoload (defun add-change-log-entry (&optional whoami file-name other-window new-entry) @@ -419,17 +429,18 @@ (setq add-log-mailing-address (read-input "Mailing address: " add-log-mailing-address)))) - (setq file-name (expand-file-name (or file-name (find-change-log file-name)))) - - (let ((defun (add-log-current-defun)) - (version (and change-log-version-info-enabled - (change-log-version-number-search))) - ;; Set ENTRY to the file name to use in the new entry. - (entry (if buffer-file-name - (add-log-file-name buffer-file-name file-name) - (if add-log-file-name-function - (funcall add-log-file-name-function file-name)))) - bound) + (let* ((defun (add-log-current-defun)) + (version (and change-log-version-info-enabled + (change-log-version-number-search))) + (buffer-file + (expand-file-name (if add-log-buffer-file-name-function + (funcall add-log-buffer-file-name-function) + buffer-file-name))) + (file-name (expand-file-name + (or file-name (find-change-log file-name buffer-file)))) + ;; Set ENTRY to the file name to use in the new entry. + (entry (add-log-file-name buffer-file file-name)) + bound) (if (or (and other-window (not (equal file-name buffer-file-name))) (window-dedicated-p (selected-window)))