[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/uniquify.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/uniquify.el |
Date: |
Mon, 05 May 2003 12:55:38 -0400 |
Index: emacs/lisp/uniquify.el
diff -c emacs/lisp/uniquify.el:1.42 emacs/lisp/uniquify.el:1.43
*** emacs/lisp/uniquify.el:1.42 Sun May 4 17:30:25 2003
--- emacs/lisp/uniquify.el Mon May 5 12:55:38 2003
***************
*** 109,130 ****
(const post-forward)
(const post-forward-angle-brackets)
(const :tag "standard Emacs behavior (nil)" nil))
! :require 'uniquify
! :group 'uniquify)
(defcustom uniquify-after-kill-buffer-p nil
"*If non-nil, rerationalize buffer names after a buffer has been killed.
This can be dangerous if Emacs Lisp code is keeping track of buffers by their
names (rather than keeping pointers to the buffers themselves)."
! :type 'boolean
! :group 'uniquify)
(defcustom uniquify-ask-about-buffer-names-p nil
"*If non-nil, permit user to choose names for buffers with same base file.
If the user chooses to name a buffer, uniquification is preempted and no
other buffer names are changed."
! :type 'boolean
! :group 'uniquify)
;; The default value matches certain Gnus buffers.
(defcustom uniquify-ignore-buffers-re "^\\*\\(un\\)?sent "
--- 109,127 ----
(const post-forward)
(const post-forward-angle-brackets)
(const :tag "standard Emacs behavior (nil)" nil))
! :require 'uniquify)
(defcustom uniquify-after-kill-buffer-p nil
"*If non-nil, rerationalize buffer names after a buffer has been killed.
This can be dangerous if Emacs Lisp code is keeping track of buffers by their
names (rather than keeping pointers to the buffers themselves)."
! :type 'boolean)
(defcustom uniquify-ask-about-buffer-names-p nil
"*If non-nil, permit user to choose names for buffers with same base file.
If the user chooses to name a buffer, uniquification is preempted and no
other buffer names are changed."
! :type 'boolean)
;; The default value matches certain Gnus buffers.
(defcustom uniquify-ignore-buffers-re "^\\*\\(un\\)?sent "
***************
*** 132,144 ****
For instance, set this to \"^draft-[0-9]+$\" to avoid having uniquify rename
draft buffers even if `uniquify-after-kill-buffer-p' is non-nil and the
visited file name isn't the same as that of the buffer."
! :type '(choice (const :tag "Uniquify all buffers" nil) regexp)
! :group 'uniquify)
(defcustom uniquify-min-dir-content 0
"*Minimum number of directory name components included in buffer name."
! :type 'integer
! :group 'uniquify)
(defcustom uniquify-separator nil
"*String separator for buffer name components.
--- 129,139 ----
For instance, set this to \"^draft-[0-9]+$\" to avoid having uniquify rename
draft buffers even if `uniquify-after-kill-buffer-p' is non-nil and the
visited file name isn't the same as that of the buffer."
! :type '(choice (const :tag "Uniquify all buffers" nil) regexp))
(defcustom uniquify-min-dir-content 0
"*Minimum number of directory name components included in buffer name."
! :type 'integer)
(defcustom uniquify-separator nil
"*String separator for buffer name components.
***************
*** 146,161 ****
base file name from directory part in buffer names (default \"|\").
When `uniquify-buffer-name-style' is `reverse', separates all
file name components (default \"\\\")."
! :type '(choice (const nil) string)
! :group 'uniquify)
(defcustom uniquify-trailing-separator-p nil
"*If non-nil, add a file name separator to dired buffer names.
If `uniquify-buffer-name-style' is `forward', add the separator at the end;
if it is `reverse', add the separator at the beginning; otherwise, this
variable is ignored."
! :type 'boolean
! :group 'uniquify)
(defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode)
"List of modes for which uniquify should obey `list-buffers-directory'.
--- 141,154 ----
base file name from directory part in buffer names (default \"|\").
When `uniquify-buffer-name-style' is `reverse', separates all
file name components (default \"\\\")."
! :type '(choice (const nil) string))
(defcustom uniquify-trailing-separator-p nil
"*If non-nil, add a file name separator to dired buffer names.
If `uniquify-buffer-name-style' is `forward', add the separator at the end;
if it is `reverse', add the separator at the beginning; otherwise, this
variable is ignored."
! :type 'boolean)
(defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode)
"List of modes for which uniquify should obey `list-buffers-directory'.
***************
*** 164,173 ****
;;; Utilities
- ;; For directories, return the last component, not the empty string.
- (defun uniquify-file-name-nondirectory (file-name)
- (file-name-nondirectory (directory-file-name file-name)))
-
;; uniquify-fix-list data structure
(defstruct (uniquify-item
(:constructor nil) (:copier nil)
--- 157,162 ----
***************
*** 185,209 ****
file name elements.
Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
(interactive)
! (let (fix-list
! (newbuffile-nd (and newbuffile
! (uniquify-file-name-nondirectory newbuffile))))
(dolist (buffer (buffer-list))
(let ((bufname (buffer-name buffer))
! bfn rawname proposed)
! (if (and (not (and uniquify-ignore-buffers-re
! (string-match uniquify-ignore-buffers-re
! bufname)))
! (setq bfn (if (eq buffer newbuf)
! (when newbuffile
! (expand-file-name
! (directory-file-name newbuffile)))
! (uniquify-buffer-file-name buffer)))
! (setq rawname (uniquify-file-name-nondirectory bfn))
! (or (not newbuffile)
! (equal rawname newbuffile-nd))
! (setq proposed (uniquify-get-proposed-name rawname bfn)))
! (push (uniquify-make-item rawname bfn buffer proposed) fix-list))))
;; selects buffers whose names may need changing, and others that
;; may conflict, then bring conflicting names together
(uniquify-rationalize-a-list fix-list)))
--- 174,198 ----
file name elements.
Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
(interactive)
! (when newbuffile
! (setq newbuffile (expand-file-name (directory-file-name newbuffile))))
! (let ((fix-list nil)
! (base (and newbuffile (file-name-nondirectory newbuffile))))
(dolist (buffer (buffer-list))
(let ((bufname (buffer-name buffer))
! bfn rawname)
! (when (and (not (and uniquify-ignore-buffers-re
! (string-match uniquify-ignore-buffers-re
! bufname)))
! (setq bfn (if (eq buffer newbuf) newbuffile
! (uniquify-buffer-file-name buffer)))
! (setq rawname (file-name-nondirectory bfn))
! (or (null base) (equal rawname base)))
! (when (setq bfn (file-name-directory bfn)) ;Strip off the `base'.
! (setq bfn (directory-file-name bfn))) ;Strip trailing slash.
! (push (uniquify-make-item rawname bfn buffer
! (uniquify-get-proposed-name rawname bfn))
! fix-list))))
;; selects buffers whose names may need changing, and others that
;; may conflict, then bring conflicting names together
(uniquify-rationalize-a-list fix-list)))
***************
*** 252,263 ****
(defun uniquify-get-proposed-name (base filename &optional depth)
(unless depth (setq depth uniquify-min-dir-content))
! (assert (equal base (uniquify-file-name-nondirectory filename)))
! (assert (equal (directory-file-name filename) filename))
;; Distinguish directories by adding extra separator.
(if (and uniquify-trailing-separator-p
! (file-directory-p filename)
(not (string-equal base "")))
(cond ((eq uniquify-buffer-name-style 'forward)
(setq base (file-name-as-directory base)))
--- 241,251 ----
(defun uniquify-get-proposed-name (base filename &optional depth)
(unless depth (setq depth uniquify-min-dir-content))
! (assert (equal (directory-file-name filename) filename)) ;No trailing
slash.
;; Distinguish directories by adding extra separator.
(if (and uniquify-trailing-separator-p
! (file-directory-p (expand-file-name base filename))
(not (string-equal base "")))
(cond ((eq uniquify-buffer-name-style 'forward)
(setq base (file-name-as-directory base)))
***************
*** 267,276 ****
(let ((extra-string nil)
(n depth))
! (while (and (> n 0) filename
! (setq filename (file-name-directory filename))
! (setq filename (directory-file-name filename)))
(let ((file (file-name-nondirectory filename)))
(setq n (1- n))
(push (if (zerop (length file)) ;nil or "".
(prog1 "" (setq filename nil)) ;Could be `filename' iso "".
--- 255,264 ----
(let ((extra-string nil)
(n depth))
! (while (and (> n 0) filename)
(let ((file (file-name-nondirectory filename)))
+ (when (setq filename (file-name-directory filename))
+ (setq filename (directory-file-name filename)))
(setq n (1- n))
(push (if (zerop (length file)) ;nil or "".
(prog1 "" (setq filename nil)) ;Could be `filename' iso "".
***************
*** 278,286 ****
extra-string)))
(when (zerop n)
(if (and filename extra-string
! (setq filename (file-name-directory filename))
! (equal filename
! (file-name-directory (directory-file-name filename))))
;; We're just before the root. Let's add the leading / already.
;; With "/a/b"+"/c/d/b" this leads to "/a/b" and "d/b" but with
;; "/a/b"+"/c/a/b" this leads to "/a/b" and "a/b".
--- 266,272 ----
extra-string)))
(when (zerop n)
(if (and filename extra-string
! (equal filename (file-name-directory filename)))
;; We're just before the root. Let's add the leading / already.
;; With "/a/b"+"/c/d/b" this leads to "/a/b" and "d/b" but with
;; "/a/b"+"/c/a/b" this leads to "/a/b" and "a/b".
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Richard M. Stallman, 2003/05/03
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/04
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/06
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/07
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/07
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/07
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/08
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/09
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/10
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/10
- [Emacs-diffs] Changes to emacs/lisp/uniquify.el, Stefan Monnier, 2003/05/13