Mercurial > emacs
comparison lisp/uniquify.el @ 50876:3311a93359a2
(uniquify-item, uniquify-get-proposed-name)
(uniquify-rationalize-conflicting-sublist): Rename filename -> dirname.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 07 May 2003 15:53:08 +0000 |
parents | 86903fed9f75 |
children | c701779986a1 |
comparison
equal
deleted
inserted
replaced
50875:aa7fb55b784f | 50876:3311a93359a2 |
---|---|
158 ;;; Utilities | 158 ;;; Utilities |
159 | 159 |
160 ;; uniquify-fix-list data structure | 160 ;; uniquify-fix-list data structure |
161 (defstruct (uniquify-item | 161 (defstruct (uniquify-item |
162 (:constructor nil) (:copier nil) | 162 (:constructor nil) (:copier nil) |
163 (:constructor uniquify-make-item (base filename buffer proposed))) | 163 (:constructor uniquify-make-item (base dirname buffer proposed))) |
164 base filename buffer proposed) | 164 base dirname buffer proposed) |
165 | 165 |
166 ;; Internal variables used free | 166 ;; Internal variables used free |
167 (defvar uniquify-possibly-resolvable nil) | 167 (defvar uniquify-possibly-resolvable nil) |
168 | 168 |
169 (defvar uniquify-managed nil | 169 (defvar uniquify-managed nil |
249 (push item conflicting-sublist) | 249 (push item conflicting-sublist) |
250 (setq old-proposed proposed)) | 250 (setq old-proposed proposed)) |
251 (uniquify-rationalize-conflicting-sublist conflicting-sublist | 251 (uniquify-rationalize-conflicting-sublist conflicting-sublist |
252 old-proposed depth))) | 252 old-proposed depth))) |
253 | 253 |
254 (defun uniquify-get-proposed-name (base filename &optional depth) | 254 (defun uniquify-get-proposed-name (base dirname &optional depth) |
255 (unless depth (setq depth uniquify-min-dir-content)) | 255 (unless depth (setq depth uniquify-min-dir-content)) |
256 (assert (equal (directory-file-name filename) filename)) ;No trailing slash. | 256 (assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. |
257 | 257 |
258 ;; Distinguish directories by adding extra separator. | 258 ;; Distinguish directories by adding extra separator. |
259 (if (and uniquify-trailing-separator-p | 259 (if (and uniquify-trailing-separator-p |
260 (file-directory-p (expand-file-name base filename)) | 260 (file-directory-p (expand-file-name base dirname)) |
261 (not (string-equal base ""))) | 261 (not (string-equal base ""))) |
262 (cond ((eq uniquify-buffer-name-style 'forward) | 262 (cond ((eq uniquify-buffer-name-style 'forward) |
263 (setq base (file-name-as-directory base))) | 263 (setq base (file-name-as-directory base))) |
264 ;; (setq base (concat base "/"))) | 264 ;; (setq base (concat base "/"))) |
265 ((eq uniquify-buffer-name-style 'reverse) | 265 ((eq uniquify-buffer-name-style 'reverse) |
266 (setq base (concat (or uniquify-separator "\\") base))))) | 266 (setq base (concat (or uniquify-separator "\\") base))))) |
267 | 267 |
268 (let ((extra-string nil) | 268 (let ((extra-string nil) |
269 (n depth)) | 269 (n depth)) |
270 (while (and (> n 0) filename) | 270 (while (and (> n 0) dirname) |
271 (let ((file (file-name-nondirectory filename))) | 271 (let ((file (file-name-nondirectory dirname))) |
272 (when (setq filename (file-name-directory filename)) | 272 (when (setq dirname (file-name-directory dirname)) |
273 (setq filename (directory-file-name filename))) | 273 (setq dirname (directory-file-name dirname))) |
274 (setq n (1- n)) | 274 (setq n (1- n)) |
275 (push (if (zerop (length file)) ;nil or "". | 275 (push (if (zerop (length file)) ;nil or "". |
276 (prog1 "" (setq filename nil)) ;Could be `filename' iso "". | 276 (prog1 "" (setq dirname nil)) ;Could be `dirname' iso "". |
277 file) | 277 file) |
278 extra-string))) | 278 extra-string))) |
279 (when (zerop n) | 279 (when (zerop n) |
280 (if (and filename extra-string | 280 (if (and dirname extra-string |
281 (equal filename (file-name-directory filename))) | 281 (equal dirname (file-name-directory dirname))) |
282 ;; We're just before the root. Let's add the leading / already. | 282 ;; We're just before the root. Let's add the leading / already. |
283 ;; With "/a/b"+"/c/d/b" this leads to "/a/b" and "d/b" but with | 283 ;; With "/a/b"+"/c/d/b" this leads to "/a/b" and "d/b" but with |
284 ;; "/a/b"+"/c/a/b" this leads to "/a/b" and "a/b". | 284 ;; "/a/b"+"/c/a/b" this leads to "/a/b" and "a/b". |
285 (push "" extra-string)) | 285 (push "" extra-string)) |
286 (setq uniquify-possibly-resolvable t)) | 286 (setq uniquify-possibly-resolvable t)) |
320 depth (1+ depth)) | 320 depth (1+ depth)) |
321 (dolist (item conf-list) | 321 (dolist (item conf-list) |
322 (setf (uniquify-item-proposed item) | 322 (setf (uniquify-item-proposed item) |
323 (uniquify-get-proposed-name | 323 (uniquify-get-proposed-name |
324 (uniquify-item-base item) | 324 (uniquify-item-base item) |
325 (uniquify-item-filename item) | 325 (uniquify-item-dirname item) |
326 depth))) | 326 depth))) |
327 (uniquify-rationalize-a-list conf-list depth)) | 327 (uniquify-rationalize-a-list conf-list depth)) |
328 (unless (string= old-name "") | 328 (unless (string= old-name "") |
329 (uniquify-rename-buffer (car conf-list) old-name))))) | 329 (uniquify-rename-buffer (car conf-list) old-name))))) |
330 | 330 |