HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix doc strings of version-* functions and variables.
[bpt/emacs.git]
/
lisp
/
uniquify.el
diff --git
a/lisp/uniquify.el
b/lisp/uniquify.el
index
492918c
..
ddf15e2
100644
(file)
--- a/
lisp/uniquify.el
+++ b/
lisp/uniquify.el
@@
-1,7
+1,7
@@
;;; uniquify.el --- unique buffer names dependent on file name
;; Copyright (C) 1989, 1995, 1996, 1997, 2001, 2002, 2003,
;;; 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, 2009, 2010
Free Software Foundation, Inc.
;; Author: Dick King <king@reasoning.com>
;; Maintainer: FSF
;; Author: Dick King <king@reasoning.com>
;; Maintainer: FSF
@@
-10,10
+10,10
@@
;; This file is part of GNU Emacs.
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software
;
you can redistribute it and/or modify
+;; GNU Emacs is free software
:
you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation
; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation
, either version 3 of the License, or
+;;
(at your option)
any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-21,14
+21,12
@@
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Emacs's standard method for making buffer names unique adds <2>, <3>,
;;; 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
;; 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
+70,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
;; 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>,
;; Valuable feedback was provided by
;; Paul Smith <psmith@baynetworks.com>,
@@
-168,7
+166,7
@@
This can be handy when you have deep parallel hierarchies."
:type 'boolean
:group 'uniquify)
:type 'boolean
:group 'uniquify)
-(defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode)
+(defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode
vc-dir-mode
)
"List of modes for which uniquify should obey `list-buffers-directory'.
That means that when `buffer-file-name' is set to nil, `list-buffers-directory'
contains the name of the directory which the buffer is visiting.")
"List of modes for which uniquify should obey `list-buffers-directory'.
That means that when `buffer-file-name' is set to nil, `list-buffers-directory'
contains the name of the directory which the buffer is visiting.")
@@
-191,6
+189,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)
(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)
;;; Main entry point.
(defun uniquify-rationalize-file-buffer-names (base dirname newbuf)
@@
-322,7
+327,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.
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
(setq proposed (uniquify-item-proposed item))
(unless (equal proposed old-proposed)
(uniquify-rationalize-conflicting-sublist conflicting-sublist
@@
-355,7
+360,8
@@
in `uniquify-list-buffers-directory-modes', otherwise returns nil."
(setq dirname (directory-file-name dirname)))
(setq n (1- n))
(push (if (zerop (length file)) ;nil or "".
(setq dirname (directory-file-name dirname)))
(setq n (1- n))
(push (if (zerop (length file)) ;nil or "".
- (prog1 "" (setq dirname nil)) ;Could be `dirname' iso "".
+ (prog1 (or (file-remote-p dirname) "")
+ (setq dirname nil)) ;Could be `dirname' iso "".
file)
extra-string)))
(when (zerop n)
file)
extra-string)))
(when (zerop n)
@@
-421,22
+427,27
@@
in `uniquify-list-buffers-directory-modes', otherwise returns nil."
;;; Hooks from the rest of Emacs
;;; Hooks from the rest of Emacs
+(defun uniquify-maybe-rerationalize-w/o-cb ()
+ "Re-rationalize buffer names, ignoring current buffer."
+ (and (cdr uniquify-managed)
+ uniquify-buffer-name-style
+ (uniquify-rerationalize-w/o-cb uniquify-managed)))
+
;; Buffer deletion
;; Rerationalize after a buffer is killed, to reduce coinciding buffer names.
;; This mechanism uses `kill-buffer-hook', which runs *before* deletion, so
;; it calls `uniquify-rerationalize-w/o-cb' to rerationalize the buffer list
;; ignoring the current buffer (which is going to be deleted anyway).
;; Buffer deletion
;; Rerationalize after a buffer is killed, to reduce coinciding buffer names.
;; This mechanism uses `kill-buffer-hook', which runs *before* deletion, so
;; it calls `uniquify-rerationalize-w/o-cb' to rerationalize the buffer list
;; ignoring the current buffer (which is going to be deleted anyway).
-(defun uniquify-
maybe-rerationalize-w/o-cb
()
+(defun uniquify-
kill-buffer-function
()
"Re-rationalize buffer names, ignoring current buffer.
For use on `kill-buffer-hook'."
"Re-rationalize buffer names, ignoring current buffer.
For use on `kill-buffer-hook'."
- (if (and (cdr uniquify-managed)
- uniquify-buffer-name-style
- uniquify-after-kill-buffer-p)
- (uniquify-rerationalize-w/o-cb uniquify-managed)))
+ (and uniquify-after-kill-buffer-p
+ (uniquify-maybe-rerationalize-w/o-cb)))
;; Ideally we'd like to add it buffer-locally, but that doesn't work
;; because kill-buffer-hook is not permanent-local :-(
;; Ideally we'd like to add it buffer-locally, but that doesn't work
;; because kill-buffer-hook is not permanent-local :-(
-(add-hook 'kill-buffer-hook 'uniquify-maybe-rerationalize-w/o-cb)
+;; FIXME kill-buffer-hook _is_ permanent-local in 22+.
+(add-hook 'kill-buffer-hook 'uniquify-kill-buffer-function)
;; The logical place to put all this code is in generate-new-buffer-name.
;; It's written in C, so we would add a generate-new-buffer-name-function
;; The logical place to put all this code is in generate-new-buffer-name.
;; It's written in C, so we would add a generate-new-buffer-name-function
@@
-491,7
+502,7
@@
For use on `kill-buffer-hook'."
(dolist (buf buffers)
(set-buffer (car buf))
(rename-buffer (cdr buf) t))))
(dolist (buf buffers)
(set-buffer (car buf))
(rename-buffer (cdr buf) t))))
- ;; continue standard u
p
loading
+ ;; continue standard u
n
loading
nil)
(provide 'uniquify)
nil)
(provide 'uniquify)