/[emacs]/emacs/lisp/uniquify.el
ViewVC logotype

Diff of /emacs/lisp/uniquify.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43 by monnier, Mon May 5 16:55:38 2003 UTC revision 1.44 by monnier, Tue May 6 14:29:39 2003 UTC
# Line 166  contains the name of the directory which Line 166  contains the name of the directory which
166  ;; Internal variables used free  ;; Internal variables used free
167  (defvar uniquify-possibly-resolvable nil)  (defvar uniquify-possibly-resolvable nil)
168    
169    (defvar uniquify-managed nil
170      "Non-nil if the name of this buffer is managed by uniquify.")
171    (make-variable-buffer-local 'uniquify-managed)
172    (put 'uniquify-managed 'permanent-local t)
173    
174  ;;; Main entry point.  ;;; Main entry point.
175    
176  (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf)  (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf)
# Line 184  Arguments NEWBUFFILE and NEWBUF cause on Line 189  Arguments NEWBUFFILE and NEWBUF cause on
189          (when (and (not (and uniquify-ignore-buffers-re          (when (and (not (and uniquify-ignore-buffers-re
190                               (string-match uniquify-ignore-buffers-re                               (string-match uniquify-ignore-buffers-re
191                                             bufname)))                                             bufname)))
192                       ;; Only try to rename buffers we actually manage.
193                       (or (buffer-local-value 'uniquify-managed buffer)
194                           (eq buffer newbuf))
195                     (setq bfn (if (eq buffer newbuf) newbuffile                     (setq bfn (if (eq buffer newbuf) newbuffile
196                                 (uniquify-buffer-file-name buffer)))                                 (uniquify-buffer-file-name buffer)))
197                     (setq rawname (file-name-nondirectory bfn))                     (setq rawname (file-name-nondirectory bfn))
# Line 193  Arguments NEWBUFFILE and NEWBUF cause on Line 201  Arguments NEWBUFFILE and NEWBUF cause on
201            (push (uniquify-make-item rawname bfn buffer            (push (uniquify-make-item rawname bfn buffer
202                                      (uniquify-get-proposed-name rawname bfn))                                      (uniquify-get-proposed-name rawname bfn))
203                  fix-list))))                  fix-list))))
204        ;; Mark the new buffer as managed.
205        (when newbuf
206          (with-current-buffer newbuf
207            (setq uniquify-managed t)))
208      ;; selects buffers whose names may need changing, and others that      ;; selects buffers whose names may need changing, and others that
209      ;; may conflict, then bring conflicting names together      ;; may conflict, then bring conflicting names together
210      (uniquify-rationalize-a-list fix-list)))      (uniquify-rationalize-a-list fix-list)))
# Line 322  in `uniquify-list-buffers-directory-mode Line 334  in `uniquify-list-buffers-directory-mode
334      (unless (equal newname (buffer-name buffer))      (unless (equal newname (buffer-name buffer))
335        (with-current-buffer buffer        (with-current-buffer buffer
336          (let ((uniquify-buffer-name-style nil)) ;Avoid hooks on rename-buffer.          (let ((uniquify-buffer-name-style nil)) ;Avoid hooks on rename-buffer.
337            ;; Pass the `unique' arg, just in case.            ;; Pass the `unique' arg, so the advice doesn't mark it as unmanaged.
338            (rename-buffer newname t))))))            (rename-buffer newname t))))))
339    
340  ;;; Hooks from the rest of Emacs  ;;; Hooks from the rest of Emacs
# Line 344  in `uniquify-list-buffers-directory-mode Line 356  in `uniquify-list-buffers-directory-mode
356    
357  (defadvice rename-buffer (after rename-buffer-uniquify activate)  (defadvice rename-buffer (after rename-buffer-uniquify activate)
358    "Uniquify buffer names with parts of directory name."    "Uniquify buffer names with parts of directory name."
359    (if (and uniquify-buffer-name-style    (if (null (ad-get-arg 1))             ; no UNIQUE argument.
360             ;; UNIQUE argument        ;; Mark this buffer so it won't be renamed by uniquify.
361             (ad-get-arg 1))        (setq uniquify-managed nil)
362        (progn      (when uniquify-buffer-name-style
363          (if uniquify-after-kill-buffer-p        (if uniquify-after-kill-buffer-p
364              ;; call with no argument; rationalize vs. old name as well as new            ;; call with no argument; rationalize vs. old name as well as new
365              (uniquify-rationalize-file-buffer-names)            (progn (setq uniquify-managed t)
366            ;; call with argument: rationalize vs. new name only                   (uniquify-rationalize-file-buffer-names))
367            (uniquify-rationalize-file-buffer-names          ;; call with argument: rationalize vs. new name only
368             (uniquify-buffer-file-name (current-buffer)) (current-buffer)))          (uniquify-rationalize-file-buffer-names
369          (setq ad-return-value (buffer-name (current-buffer))))))           (uniquify-buffer-file-name (current-buffer)) (current-buffer)))
370          (setq ad-return-value (buffer-name (current-buffer))))))
371    
372  (defadvice create-file-buffer (after create-file-buffer-uniquify activate)  (defadvice create-file-buffer (after create-file-buffer-uniquify activate)
373    "Uniquify buffer names with parts of directory name."    "Uniquify buffer names with parts of directory name."
# Line 375  in `uniquify-list-buffers-directory-mode Line 388  in `uniquify-list-buffers-directory-mode
388  (defun uniquify-delay-rationalize-file-buffer-names ()  (defun uniquify-delay-rationalize-file-buffer-names ()
389    "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'.    "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'.
390  For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion."  For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion."
391    (if (and uniquify-buffer-name-style    (if (and uniquify-managed
392               uniquify-buffer-name-style
393             uniquify-after-kill-buffer-p             uniquify-after-kill-buffer-p
394             ;; Rationalizing is costly, so don't do it for temp buffers.             ;; Rationalizing is costly, so don't do it for temp buffers.
395             (uniquify-buffer-file-name (current-buffer)))             (uniquify-buffer-file-name (current-buffer)))

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26