summaryrefslogtreecommitdiff
path: root/lisp/add-log.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2008-09-06 19:38:44 +0000
committerGlenn Morris <rgm@gnu.org>2008-09-06 19:38:44 +0000
commit89631590457a0f40306cd1a207a6d8dad3a2c776 (patch)
tree724236f31c1e7f31b7ca1207096cbe56b29d67f3 /lisp/add-log.el
parent2ca2ebe6f1a1e675e2e27afaaa0d9f114d83167b (diff)
downloademacs-89631590457a0f40306cd1a207a6d8dad3a2c776.tar.gz
emacs-89631590457a0f40306cd1a207a6d8dad3a2c776.tar.bz2
emacs-89631590457a0f40306cd1a207a6d8dad3a2c776.zip
(diff-find-source-location): Declare.
(find-change-log): If called from a diff buffer, try to switch to the source buffer (e.g. to respect change-log-default-name there).
Diffstat (limited to 'lisp/add-log.el')
-rw-r--r--lisp/add-log.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 6bb1178fe52..98aa9109528 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -665,6 +665,8 @@ nil, by matching `change-log-version-number-regexp-list'."
regexps nil))))
version)))))
+(declare-function diff-find-source-location "diff-mode"
+ (&optional other-file reverse))
;;;###autoload
(defun find-change-log (&optional file-name buffer-file)
@@ -682,12 +684,18 @@ 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.
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
- (setq file-name (and change-log-default-name
- (file-name-directory change-log-default-name)
- change-log-default-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.
+ (let ((buff (if (eq major-mode 'diff-mode)
+ (car (ignore-errors (diff-find-source-location))))))
+ (with-current-buffer (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.
@@ -720,9 +728,9 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'."
parent-dir)))
;; If we found a change log in a parent, use that.
(if (or (get-file-buffer file1) (file-exists-p file1))
- (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)
+ (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)
(defun add-log-file-name (buffer-file log-file)