changeset 50883:7b95d60a7574

(uniquify-rationalize-file-buffer-names): Don't uniquify if there is no filename.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 07 May 2003 21:56:43 +0000
parents f48074afcf3c
children 4d3efb8f1498
files lisp/uniquify.el
diffstat 1 files changed, 25 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/uniquify.el	Wed May 07 17:27:31 2003 +0000
+++ b/lisp/uniquify.el	Wed May 07 21:56:43 2003 +0000
@@ -180,29 +180,31 @@
 file name elements.
 Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
   (interactive)
-  (setq newbuffile (expand-file-name (directory-file-name newbuffile)))
-  (let ((fix-list nil)
-	(base (file-name-nondirectory newbuffile)))
-    (dolist (buffer (buffer-list))
-      (let ((bufname (buffer-name buffer))
-	    bfn)
-	(when (and (not (and uniquify-ignore-buffers-re
-			     (string-match uniquify-ignore-buffers-re
-					   bufname)))
-		   ;; Only try to rename buffers we actually manage.
-		   (or (buffer-local-value 'uniquify-managed buffer)
-		       (eq buffer newbuf))
-		   (setq bfn (if (eq buffer newbuf) newbuffile
-			       (uniquify-buffer-file-name buffer)))
-		   (equal (file-name-nondirectory bfn) base))
-	  (when (setq bfn (file-name-directory bfn)) ;Strip off the `base'.
-	    (setq bfn (directory-file-name bfn)))    ;Strip trailing slash.
-	  (push (uniquify-make-item base bfn buffer
-				    (uniquify-get-proposed-name base bfn))
-		fix-list))))
-    ;; selects buffers whose names may need changing, and others that
-    ;; may conflict, then bring conflicting names together
-    (uniquify-rationalize fix-list)))
+  (if (null newbuffile)
+      (with-current-buffer newbuf (setq uniquify-managed nil))
+    (setq newbuffile (expand-file-name (directory-file-name newbuffile)))
+    (let ((fix-list nil)
+	  (base (file-name-nondirectory newbuffile)))
+      (dolist (buffer (buffer-list))
+	(let ((bufname (buffer-name buffer))
+	      bfn)
+	  (when (and (not (and uniquify-ignore-buffers-re
+			       (string-match uniquify-ignore-buffers-re
+					     bufname)))
+		     ;; Only try to rename buffers we actually manage.
+		     (or (buffer-local-value 'uniquify-managed buffer)
+			 (eq buffer newbuf))
+		     (setq bfn (if (eq buffer newbuf) newbuffile
+				 (uniquify-buffer-file-name buffer)))
+		     (equal (file-name-nondirectory bfn) base))
+	    (when (setq bfn (file-name-directory bfn)) ;Strip off the `base'.
+	      (setq bfn (directory-file-name bfn)))    ;Strip trailing slash.
+	    (push (uniquify-make-item base bfn buffer
+				      (uniquify-get-proposed-name base bfn))
+		  fix-list))))
+      ;; selects buffers whose names may need changing, and others that
+      ;; may conflict, then bring conflicting names together
+      (uniquify-rationalize fix-list))))
 
 ;; uniquify's version of buffer-file-name; result never contains trailing slash
 (defun uniquify-buffer-file-name (buffer)