Bug fix for vc-dispatcher split.
[bpt/emacs.git] / lisp / uniquify.el
index 492918c..03e54b5 100644 (file)
@@ -1,7 +1,7 @@
 ;;; uniquify.el --- unique buffer names dependent on file name
 
 ;; Copyright (C) 1989, 1995, 1996, 1997, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Dick King <king@reasoning.com>
 ;; Maintainer: FSF
@@ -28,7 +28,7 @@
 ;;; Commentary:
 
 ;; Emacs's standard method for making buffer names unique adds <2>, <3>,
-;; etc.. to the end of (all but one of) the buffers.  This file replaces
+;; etc. to the end of (all but one of) the buffers.  This file replaces
 ;; that behavior, for buffers visiting files and dired buffers, with a
 ;; uniquification that adds parts of the file name until the buffer names
 ;; are unique.  For instance, buffers visiting /u/mernst/tmp/Makefile and
@@ -72,7 +72,7 @@
 ;; Add uniquify-list-buffers-directory-modes
 ;;   Stefan Monnier <monnier@cs.yale.edu> 17 Nov 2000
 ;; Algorithm and data structure changed to reduce consing with lots of buffers
-;;   Francesco Potortì <pot@gnu.org> (ideas by rms and monnier) 2001-07-18
+;;   Francesco Potortì <pot@gnu.org> (ideas by rms and monnier) 2001-07-18
 
 ;; Valuable feedback was provided by
 ;; Paul Smith <psmith@baynetworks.com>,
@@ -191,6 +191,13 @@ It actually holds the list of `uniquify-item's corresponding to the conflict.")
 (make-variable-buffer-local 'uniquify-managed)
 (put 'uniquify-managed 'permanent-local t)
 
+;; Used in desktop.el to save the non-uniquified buffer name
+(defun uniquify-buffer-base-name ()
+  "Return the base name of the current buffer.
+Return nil if the buffer is not managed by uniquify."
+  (and uniquify-managed
+       (uniquify-item-base (car uniquify-managed))))
+
 ;;; Main entry point.
 
 (defun uniquify-rationalize-file-buffer-names (base dirname newbuf)
@@ -322,7 +329,7 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
        proposed)
     ;; Divide fix-list into items with same proposed names and pass them
     ;; to uniquify-rationalize-conflicting-sublist.
-    (dolist (item (sort fix-list 'uniquify-item-greaterp))
+    (dolist (item (sort (copy-sequence fix-list) 'uniquify-item-greaterp))
       (setq proposed (uniquify-item-proposed item))
       (unless (equal proposed old-proposed)
        (uniquify-rationalize-conflicting-sublist conflicting-sublist
@@ -491,7 +498,7 @@ For use on `kill-buffer-hook'."
       (dolist (buf buffers)
        (set-buffer (car buf))
        (rename-buffer (cdr buf) t))))
-  ;; continue standard uploading
+  ;; continue standard unloading
   nil)
 
 (provide 'uniquify)