Mercurial > emacs
comparison lisp/add-log.el @ 98055:04b7a6119a88
(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).
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Sep 2008 19:38:35 +0000 |
parents | 1e478a6e3dd0 |
children | a780e9687b4e |
comparison
equal
deleted
inserted
replaced
98054:61484749c2c0 | 98055:04b7a6119a88 |
---|---|
663 (when (re-search-forward (pop regexps) limit t) | 663 (when (re-search-forward (pop regexps) limit t) |
664 (setq version (match-string 1) | 664 (setq version (match-string 1) |
665 regexps nil)))) | 665 regexps nil)))) |
666 version))))) | 666 version))))) |
667 | 667 |
668 (declare-function diff-find-source-location "diff-mode" | |
669 (&optional other-file reverse)) | |
668 | 670 |
669 ;;;###autoload | 671 ;;;###autoload |
670 (defun find-change-log (&optional file-name buffer-file) | 672 (defun find-change-log (&optional file-name buffer-file) |
671 "Find a change log file for \\[add-change-log-entry] and return the name. | 673 "Find a change log file for \\[add-change-log-entry] and return the name. |
672 | 674 |
680 directory and its successive parents for a file so named. | 682 directory and its successive parents for a file so named. |
681 | 683 |
682 Once a file is found, `change-log-default-name' is set locally in the | 684 Once a file is found, `change-log-default-name' is set locally in the |
683 current buffer to the complete file name. | 685 current buffer to the complete file name. |
684 Optional arg BUFFER-FILE overrides `buffer-file-name'." | 686 Optional arg BUFFER-FILE overrides `buffer-file-name'." |
685 ;; If user specified a file name or if this buffer knows which one to use, | 687 ;; If we are called from a diff, first switch to the source buffer; |
686 ;; just use that. | 688 ;; in order to respect buffer-local settings of change-log-default-name, etc. |
687 (or file-name | 689 (let ((buff (if (eq major-mode 'diff-mode) |
688 (setq file-name (and change-log-default-name | 690 (car (ignore-errors (diff-find-source-location)))))) |
689 (file-name-directory change-log-default-name) | 691 (with-current-buffer (if (buffer-live-p buff) buff |
690 change-log-default-name)) | 692 (current-buffer)) |
693 ;; If user specified a file name or if this buffer knows which one to use, | |
694 ;; just use that. | |
695 (or file-name | |
696 (setq file-name (and change-log-default-name | |
697 (file-name-directory change-log-default-name) | |
698 change-log-default-name))) | |
691 (progn | 699 (progn |
692 ;; Chase links in the source file | 700 ;; Chase links in the source file |
693 ;; and use the change log in the dir where it points. | 701 ;; and use the change log in the dir where it points. |
694 (setq file-name (or (and (or buffer-file buffer-file-name) | 702 (setq file-name (or (and (or buffer-file buffer-file-name) |
695 (file-name-directory | 703 (file-name-directory |
718 (setq file1 (expand-file-name | 726 (setq file1 (expand-file-name |
719 (file-name-nondirectory (change-log-name)) | 727 (file-name-nondirectory (change-log-name)) |
720 parent-dir))) | 728 parent-dir))) |
721 ;; If we found a change log in a parent, use that. | 729 ;; If we found a change log in a parent, use that. |
722 (if (or (get-file-buffer file1) (file-exists-p file1)) | 730 (if (or (get-file-buffer file1) (file-exists-p file1)) |
723 (setq file-name file1))))) | 731 (setq file-name file1)))) |
724 ;; Make a local variable in this buffer so we needn't search again. | 732 ;; Make a local variable in this buffer so we needn't search again. |
725 (set (make-local-variable 'change-log-default-name) file-name) | 733 (set (make-local-variable 'change-log-default-name) file-name))) |
726 file-name) | 734 file-name) |
727 | 735 |
728 (defun add-log-file-name (buffer-file log-file) | 736 (defun add-log-file-name (buffer-file log-file) |
729 ;; Never want to add a change log entry for the ChangeLog file itself. | 737 ;; Never want to add a change log entry for the ChangeLog file itself. |
730 (unless (or (null buffer-file) (string= buffer-file log-file)) | 738 (unless (or (null buffer-file) (string= buffer-file log-file)) |