HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use define-derived-mode (and derived-mode-p).
[bpt/emacs.git]
/
lisp
/
uniquify.el
diff --git
a/lisp/uniquify.el
b/lisp/uniquify.el
index
a654b2d
..
546796b
100644
(file)
--- a/
lisp/uniquify.el
+++ b/
lisp/uniquify.el
@@
-1,7
+1,7
@@
-;;; uniquify.el --- unique buffer names dependent on file name
+;;; uniquify.el --- unique buffer names dependent on file name
-*- lexical-binding: t -*-
-;; Copyright (C) 1989, 1995
, 1996, 1997, 2001, 2002, 2003
,
-;;
2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
Inc.
+;; Copyright (C) 1989, 1995
-1997, 2001-2013 Free Software Foundation
,
+;; Inc.
;; Author: Dick King <king@reasoning.com>
;; Maintainer: FSF
;; Author: Dick King <king@reasoning.com>
;; Maintainer: FSF
@@
-84,7
+84,7
@@
;;; Code:
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl
-lib
))
;;; User-visible variables
;;; User-visible variables
@@
-175,7
+175,7
@@
contains the name of the directory which the buffer is visiting.")
;;; Utilities
;; uniquify-fix-list data structure
;;; Utilities
;; uniquify-fix-list data structure
-(defstruct (uniquify-item
+(
cl-
defstruct (uniquify-item
(:constructor nil) (:copier nil)
(:constructor uniquify-make-item
(base dirname buffer &optional proposed)))
(:constructor nil) (:copier nil)
(:constructor uniquify-make-item
(base dirname buffer &optional proposed)))
@@
-184,10
+184,9
@@
contains the name of the directory which the buffer is visiting.")
;; Internal variables used free
(defvar uniquify-possibly-resolvable nil)
;; Internal variables used free
(defvar uniquify-possibly-resolvable nil)
-(defvar uniquify-managed nil
+(defvar
-local
uniquify-managed nil
"Non-nil if the name of this buffer is managed by uniquify.
It actually holds the list of `uniquify-item's corresponding to the conflict.")
"Non-nil if the name of this buffer is managed by uniquify.
It actually holds the list of `uniquify-item's corresponding to the conflict.")
-(make-variable-buffer-local 'uniquify-managed)
(put 'uniquify-managed 'permanent-local t)
;; Used in desktop.el to save the non-uniquified buffer name
(put 'uniquify-managed 'permanent-local t)
;; Used in desktop.el to save the non-uniquified buffer name
@@
-341,7
+340,7
@@
in `uniquify-list-buffers-directory-modes', otherwise returns nil."
(defun uniquify-get-proposed-name (base dirname &optional depth)
(unless depth (setq depth uniquify-min-dir-content))
(defun uniquify-get-proposed-name (base dirname &optional depth)
(unless depth (setq depth uniquify-min-dir-content))
- (
assert (equal (directory-file-name dirname) dirname))
;No trailing slash.
+ (
cl-assert (equal (directory-file-name dirname) dirname))
;No trailing slash.
;; Distinguish directories by adding extra separator.
(if (and uniquify-trailing-separator-p
;; Distinguish directories by adding extra separator.
(if (and uniquify-trailing-separator-p
@@
-465,27
+464,34
@@
For use on `kill-buffer-hook'."
;; rename-buffer and create-file-buffer. (Setting find-file-hook isn't
;; sufficient.)
;; rename-buffer and create-file-buffer. (Setting find-file-hook isn't
;; sufficient.)
-(defadvice rename-buffer (after rename-buffer-uniquify activate)
+(advice-add 'rename-buffer :around #'uniquify--rename-buffer-advice)
+(defun uniquify--rename-buffer-advice (rb-fun newname &optional unique &rest args)
"Uniquify buffer names with parts of directory name."
"Uniquify buffer names with parts of directory name."
+ (let ((retval (apply rb-fun newname unique args)))
(uniquify-maybe-rerationalize-w/o-cb)
(uniquify-maybe-rerationalize-w/o-cb)
- (if (null (ad-get-arg 1)) ; no UNIQUE argument.
+ (if (null unique)
;; Mark this buffer so it won't be renamed by uniquify.
(setq uniquify-managed nil)
(when uniquify-buffer-name-style
;; Rerationalize w.r.t the new name.
(uniquify-rationalize-file-buffer-names
;; Mark this buffer so it won't be renamed by uniquify.
(setq uniquify-managed nil)
(when uniquify-buffer-name-style
;; Rerationalize w.r.t the new name.
(uniquify-rationalize-file-buffer-names
- (ad-get-arg 0)
+ newname
(uniquify-buffer-file-name (current-buffer))
(current-buffer))
(uniquify-buffer-file-name (current-buffer))
(current-buffer))
- (setq ad-return-value (buffer-name (current-buffer))))))
+ (setq retval (buffer-name (current-buffer)))))
+ retval))
-(defadvice create-file-buffer (after create-file-buffer-uniquify activate)
+
+(advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice)
+(defun uniquify--create-file-buffer-advice (cfb-fun filename &rest args)
"Uniquify buffer names with parts of directory name."
"Uniquify buffer names with parts of directory name."
+ (let ((retval (apply cfb-fun filename args)))
(if uniquify-buffer-name-style
(if uniquify-buffer-name-style
-
(let ((filename (expand-file-name (directory-file-name (ad-get-arg 0)
))))
+
(let ((filename (expand-file-name (directory-file-name filename
))))
(uniquify-rationalize-file-buffer-names
(file-name-nondirectory filename)
(uniquify-rationalize-file-buffer-names
(file-name-nondirectory filename)
- (file-name-directory filename) ad-return-value))))
+ (file-name-directory filename) retval)))
+ retval))
;;; The End
;;; The End
@@
-497,9
+503,8
@@
For use on `kill-buffer-hook'."
(set-buffer buf)
(when uniquify-managed
(push (cons buf (uniquify-item-base (car uniquify-managed))) buffers)))
(set-buffer buf)
(when uniquify-managed
(push (cons buf (uniquify-item-base (car uniquify-managed))) buffers)))
- (dolist (fun '(rename-buffer create-file-buffer))
- (ad-remove-advice fun 'after (intern (concat (symbol-name fun) "-uniquify")))
- (ad-update fun))
+ (advice-remove 'rename-buffer #'uniquify--rename-buffer-advice)
+ (advice-remove 'create-file-buffer #'uniquify--create-file-buffer-advice)
(dolist (buf buffers)
(set-buffer (car buf))
(rename-buffer (cdr buf) t))))
(dolist (buf buffers)
(set-buffer (car buf))
(rename-buffer (cdr buf) t))))
@@
-508,5
+513,4
@@
For use on `kill-buffer-hook'."
(provide 'uniquify)
(provide 'uniquify)
-;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065
;;; uniquify.el ends here
;;; uniquify.el ends here