comparison lisp/uniquify.el @ 13851:922f62608a55

(uniquify-fix-list-filename-lessp): Renamed from uniquify-filename-sort.
author Richard M. Stallman <rms@gnu.org>
date Mon, 25 Dec 1995 18:45:37 +0000
parents f683f93b94e9
children 41802d268ffb
comparison
equal deleted inserted replaced
13850:979209bb1aed 13851:922f62608a55
35 35
36 ;; To use this file, just load it. 36 ;; To use this file, just load it.
37 ;; To disable it after loading, set variable uniquify-buffer-name-style to nil. 37 ;; To disable it after loading, set variable uniquify-buffer-name-style to nil.
38 ;; For other options, see "User-visible variables", below. 38 ;; For other options, see "User-visible variables", below.
39 39
40 ;; uniquify.el works under Emacs, XEmacs, and InfoDock. 40 ;; A version of uniquify.el that works under Emacs 18, Emacs 19, XEmacs,
41 41 ;; and InfoDock is available from the maintainer.
42 ;; Doesn't correctly handle buffer names created by M-x write-file in Emacs 18.
43 42
44 ;;; Change Log: 43 ;;; Change Log:
45 44
46 ;; Originally by Dick King <king@reasoning.com> 15 May 86 45 ;; Originally by Dick King <king@reasoning.com> 15 May 86
47 ;; Converted for Emacs 18 by Stephen Gildea <gildea@lcs.mit.edu> 46 ;; Converted for Emacs 18 by Stephen Gildea <gildea@lcs.mit.edu>
161 uniquify-non-file-buffer-names))) 160 uniquify-non-file-buffer-names)))
162 (setq buffers (cdr buffers)))) 161 (setq buffers (cdr buffers))))
163 ;; selects buffers whose names may need changing, and others that 162 ;; selects buffers whose names may need changing, and others that
164 ;; may conflict. 163 ;; may conflict.
165 (setq fix-list 164 (setq fix-list
166 (sort fix-list 'uniquify-filename-sort)) 165 (sort fix-list 'uniquify-fix-list-filename-lessp))
167 ;; bringing conflicting names together 166 ;; bringing conflicting names together
168 (uniquify-rationalize-a-list fix-list depth) 167 (uniquify-rationalize-a-list fix-list depth)
169 (mapcar 'uniquify-unrationalized-buffer fix-list))) 168 (mapcar 'uniquify-unrationalized-buffer fix-list)))
170 169
170 ;; uniquify's version of buffer-file-name
171 (defun uniquify-buffer-file-name (buffer) 171 (defun uniquify-buffer-file-name (buffer)
172 "Return name of file BUFFER is visiting, or nil if none. 172 "Return name of file BUFFER is visiting, or nil if none.
173 Works on dired buffers as well as ordinary file-visiting buffers." 173 Works on dired buffers as well as ordinary file-visiting buffers."
174 (or (buffer-file-name buffer) 174 (or (buffer-file-name buffer)
175 (save-excursion 175 (save-excursion
176 (set-buffer buffer) 176 (set-buffer buffer)
177 list-buffers-directory))) 177 list-buffers-directory)))
178 178
179 (defun uniquify-filename-sort (s1 s2) 179 (defun uniquify-fix-list-filename-lessp (fixlist1 fixlist2)
180 (uniquify-filename-lessp 180 (uniquify-filename-lessp
181 (uniquify-fix-list-filename s1) (uniquify-fix-list-filename s2))) 181 (uniquify-fix-list-filename fixlist1) (uniquify-fix-list-filename fixlist2)))
182 182
183 ;; This examines the filename components in reverse order.
183 (defun uniquify-filename-lessp (s1 s2) 184 (defun uniquify-filename-lessp (s1 s2)
184 (let ((s1f (file-name-nondirectory s1)) 185 (let ((s1f (file-name-nondirectory s1))
185 (s2f (file-name-nondirectory s2))) 186 (s2f (file-name-nondirectory s2)))
186 (and (not (equal s2f "")) 187 (and (not (equal s2f ""))
187 (or (string-lessp s1f s2f) 188 (or (string-lessp s1f s2f)