From 2eb7ccf4eaed0f77183bca1975355abeaddf7336 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed, 20 Sep 2000 22:21:52 +0000
Subject: (add-log-file-name): New function (split out of
 add-change-log-entry). (add-change-log-entry): Use it. Call
 add-log-file-name-function with the changelog file name if the current buffer
 is not associated with any file. Avoid find-file if the selected window is
 dedicated.

---
 lisp/add-log.el | 53 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

(limited to 'lisp/add-log.el')

diff --git a/lisp/add-log.el b/lisp/add-log.el
index 0d253614945..baed50419ee 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -326,6 +326,22 @@ current buffer to the complete file name."
   (set (make-local-variable 'change-log-default-name) file-name)
   file-name)
 
+(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)))
+
 ;;;###autoload
 (defun add-change-log-entry (&optional whoami file-name other-window new-entry)
   "Find change log file and add an entry for today.
@@ -355,34 +371,21 @@ non-nil, otherwise in local time."
 	 ;; s/he can edit the full name field in prompter if s/he wants.
 	(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)))
-	bound entry)
-
-    (setq file-name (expand-file-name (find-change-log file-name)))
-
-    ;; Set ENTRY to the file name to use in the new entry.
-    (and buffer-file-name
-	 ;; Never want to add a change log entry for the ChangeLog file itself.
-	 (not (string= buffer-file-name file-name))
-	 (if add-log-file-name-function
-	     (setq entry
-		   (funcall add-log-file-name-function buffer-file-name))
-	   (setq entry
-		 (if (string-match
-		      (concat "^" (regexp-quote (file-name-directory
-						 file-name)))
-		      buffer-file-name)
-		     (substring buffer-file-name (match-end 0))
-		   (file-name-nondirectory buffer-file-name)))
-	   ;; 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 entry)
-	       (setq entry (file-name-sans-versions entry)))))
-
-    (if (and other-window (not (equal file-name buffer-file-name)))
+	;; 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)
+
+    (if (or (and other-window (not (equal file-name buffer-file-name)))
+	    (window-dedicated-p (selected-window)))
 	(find-file-other-window file-name)
       (find-file file-name))
     (or (eq major-mode 'change-log-mode)
-- 
cgit v1.2.3