comparison lisp/files.el @ 20218:84d1bec9ac4b

(rename-uniquely): Simplify.
author Karl Heuer <kwzh@gnu.org>
date Fri, 07 Nov 1997 21:44:16 +0000
parents 496ecb0c5e68
children 96eee1e730a1
comparison
equal deleted inserted replaced
20217:815e934f5ffc 20218:84d1bec9ac4b
2403 "Rename current buffer to a similar name not already taken. 2403 "Rename current buffer to a similar name not already taken.
2404 This function is useful for creating multiple shell process buffers 2404 This function is useful for creating multiple shell process buffers
2405 or multiple mail buffers, etc." 2405 or multiple mail buffers, etc."
2406 (interactive) 2406 (interactive)
2407 (save-match-data 2407 (save-match-data
2408 (let* ((base-name (if (and (string-match "<[0-9]+>\\'" (buffer-name)) 2408 (let ((base-name (buffer-name)))
2409 (not (and buffer-file-name 2409 (and (string-match "<[0-9]+>\\'" base-name)
2410 (string= (buffer-name) 2410 (not (and buffer-file-name
2411 (file-name-nondirectory 2411 (string= base-name
2412 buffer-file-name))))) 2412 (file-name-nondirectory buffer-file-name))))
2413 ;; If the existing buffer name has a <NNN>, 2413 ;; If the existing buffer name has a <NNN>,
2414 ;; which isn't part of the file name (if any), 2414 ;; which isn't part of the file name (if any),
2415 ;; then get rid of that. 2415 ;; then get rid of that.
2416 (substring (buffer-name) 0 (match-beginning 0)) 2416 (setq base-name (substring base-name 0 (match-beginning 0))))
2417 (buffer-name))) 2417 (rename-buffer (generate-new-buffer-name base-name))
2418 (new-buf (generate-new-buffer base-name))
2419 (name (buffer-name new-buf)))
2420 (kill-buffer new-buf)
2421 (rename-buffer name)
2422 (force-mode-line-update)))) 2418 (force-mode-line-update))))
2423 2419
2424 (defun make-directory (dir &optional parents) 2420 (defun make-directory (dir &optional parents)
2425 "Create the directory DIR and any nonexistent parent dirs. 2421 "Create the directory DIR and any nonexistent parent dirs.
2426 Interactively, the default choice of directory to create 2422 Interactively, the default choice of directory to create