diff options
| author | Stefan Monnier | 2003-05-09 13:21:05 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-09 13:21:05 +0000 |
| commit | 75e2fcb63a6fcea329ad2e701d171a0d33235ef1 (patch) | |
| tree | deafee39118401b6e8016e29a2aedd4e760b6ecc | |
| parent | 9b60c729b415a16414fc13afb290d66f11817683 (diff) | |
| download | emacs-75e2fcb63a6fcea329ad2e701d171a0d33235ef1.tar.gz emacs-75e2fcb63a6fcea329ad2e701d171a0d33235ef1.zip | |
Use the original buffer-name as `base' in place of the
nondirectory part of the file name.
(uniquify-rationalize-file-buffer-names):
Split the `newbuffile' arg into `base' and `dirname'.
Reuse old uniquify-items to avoid recomputing their base&dirname.
(uniquify-buffer-file-name): Only return the directory part.
(uniquify-rerationalize-w/o-cb): Don't bother reseting proposed names.
(rename-buffer): Use the `newname' arg as base.
(create-file-buffer): Split the file name into base and dirname.
| -rw-r--r-- | lisp/ChangeLog | 54 | ||||
| -rw-r--r-- | lisp/uniquify.el | 62 |
2 files changed, 42 insertions, 74 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3a42d83ef62..96e96693124 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2003-05-09 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * uniquify.el: Use the original buffer-name as `base' in place of the | ||
| 4 | nondirectory part of the file name. | ||
| 5 | (uniquify-rationalize-file-buffer-names): | ||
| 6 | Split the `newbuffile' arg into `base' and `dirname'. | ||
| 7 | Reuse old uniquify-items to avoid recomputing their base&dirname. | ||
| 8 | (uniquify-buffer-file-name): Only return the directory part. | ||
| 9 | (uniquify-rerationalize-w/o-cb): Don't bother reseting proposed names. | ||
| 10 | (rename-buffer): Use the `newname' arg as base. | ||
| 11 | (create-file-buffer): Split the file name into base and dirname. | ||
| 12 | |||
| 1 | 2003-05-09 Jesper Harder <harder@ifa.au.dk> (tiny change) | 13 | 2003-05-09 Jesper Harder <harder@ifa.au.dk> (tiny change) |
| 2 | 14 | ||
| 3 | * mail/smtpmail.el (smtpmail-send-queued-mail): Don't use kill-line. | 15 | * mail/smtpmail.el (smtpmail-send-queued-mail): Don't use kill-line. |
| @@ -1015,48 +1027,6 @@ | |||
| 1015 | * language/ind-util.el (indian-2-column-to-ucs-region): Fix for | 1027 | * language/ind-util.el (indian-2-column-to-ucs-region): Fix for |
| 1016 | the case of replacing multibyte characters. | 1028 | the case of replacing multibyte characters. |
| 1017 | 1029 | ||
| 1018 | 2003-04-09 Stefan Monnier <monnier@cs.yale.edu> | ||
| 1019 | |||
| 1020 | * textmodes/bibtex.el: Update copyright and Author list. | ||
| 1021 | Don't require `compile' since it seems unnecessary. | ||
| 1022 | (bibtex-version): Remove. | ||
| 1023 | (bibtex-sort-ignore-string-entries, bibtex-maintain-sorted-entries) | ||
| 1024 | (bibtex-field-name-for-parsing): Don't make auto-buffer-local. | ||
| 1025 | (bibtex-comment-start): Don't include the space. | ||
| 1026 | (zmacs-regions, reporter-prompt-for-summary-p): | ||
| 1027 | Declare to quieten the byte-compiler. | ||
| 1028 | (bibtex-reference-key, bibtex-mode-syntax-table): Remove = | ||
| 1029 | because it can't be part of a string's key. | ||
| 1030 | (bibtex-parse-field-name): Use prog1. | ||
| 1031 | (bibtex-font-lock-syntactic-keywords): New var. | ||
| 1032 | (bibtex-font-lock-keywords): Remove the entry for @Comment. | ||
| 1033 | (bibtex-search-entry): Simplify. | ||
| 1034 | (bibtex-empty-re): New var. | ||
| 1035 | (bibtex-format-entry): Slightly restructure some loops to avoid code | ||
| 1036 | duplication. Use looking-at rather than `substring + string-match'. | ||
| 1037 | Use bibtex-empty-re (which removes unnecessary \(..\) in regexps). | ||
| 1038 | Remove now unused end-name. Use bibtex-find-crossref. | ||
| 1039 | Don't downcase since case-fold-search is t. | ||
| 1040 | (bibtex-autokey-get-yearfield): Use bibtex-find-crossref. | ||
| 1041 | (bibtex-parse-keys): Use unless and push. | ||
| 1042 | Parse even if bibtex-maintain-sorted-entries is nil. | ||
| 1043 | (bibtex-complete): Use push. Don't sort completions. | ||
| 1044 | (bibtex-mode): Use push. Update comment-start-skip. | ||
| 1045 | Improve defun-prompt-regexp and outline-regexp. | ||
| 1046 | Add bibtex-font-lock-syntactic-keywords to font-lock-defaults. | ||
| 1047 | (bibtex-end-of-entry): Remove unused \(...\). | ||
| 1048 | (bibtex-sort-key): New fun. | ||
| 1049 | (bibtex-sort-buffer, bibtex-validate): Use it. | ||
| 1050 | (bibtex-find-crossref): New fun. | ||
| 1051 | (bibtex-validate): Use push & dolist; remove \(...\). | ||
| 1052 | (bibtex-clean-entry): Use unless and friends. | ||
| 1053 | Don't add the key to the list if the list hasn't been built yet. | ||
| 1054 | (bibtex-fill-entry): Remove unused begin-name and end-name. | ||
| 1055 | (bibtex-reformat): Kill local var instead of setting it to nil. | ||
| 1056 | (bibtex-convert-alien): Use deactivate-mark rather than the | ||
| 1057 | non-existent bibtex-mark-active variable. | ||
| 1058 | (bibtex-String): Simplify. | ||
| 1059 | |||
| 1060 | 2003-04-09 Richard M. Stallman <rms@gnu.org> | 1030 | 2003-04-09 Richard M. Stallman <rms@gnu.org> |
| 1061 | 1031 | ||
| 1062 | * files.el (file-chase-links): Fix previous change. | 1032 | * files.el (file-chase-links): Fix previous change. |
diff --git a/lisp/uniquify.el b/lisp/uniquify.el index 17a3e740f28..3f621532ad9 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el | |||
| @@ -182,47 +182,44 @@ It actually holds the list of `uniquify-item's corresponding to the conflict.") | |||
| 182 | 182 | ||
| 183 | ;;; Main entry point. | 183 | ;;; Main entry point. |
| 184 | 184 | ||
| 185 | (defun uniquify-rationalize-file-buffer-names (newbuffile newbuf) | 185 | (defun uniquify-rationalize-file-buffer-names (base dirname newbuf) |
| 186 | "Make file buffer names unique by adding segments from file name. | 186 | "Make file buffer names unique by adding segments from file name. |
| 187 | If `uniquify-min-dir-content' > 0, always pulls that many | 187 | If `uniquify-min-dir-content' > 0, always pulls that many |
| 188 | file name elements. | 188 | file name elements. |
| 189 | Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed." | 189 | Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed." |
| 190 | (interactive) | 190 | (interactive) |
| 191 | (if (null newbuffile) | 191 | (if (null dirname) |
| 192 | (with-current-buffer newbuf (setq uniquify-managed nil)) | 192 | (with-current-buffer newbuf (setq uniquify-managed nil)) |
| 193 | (setq newbuffile (expand-file-name (directory-file-name newbuffile))) | 193 | (setq dirname (expand-file-name (directory-file-name dirname))) |
| 194 | (let ((fix-list nil) | 194 | (let ((fix-list (list (uniquify-make-item base dirname newbuf))) |
| 195 | (base (file-name-nondirectory newbuffile))) | 195 | items) |
| 196 | (dolist (buffer (buffer-list)) | 196 | (dolist (buffer (buffer-list)) |
| 197 | (let ((bufname (buffer-name buffer)) | 197 | (when (and (not (and uniquify-ignore-buffers-re |
| 198 | bfn) | 198 | (string-match uniquify-ignore-buffers-re |
| 199 | (when (and (not (and uniquify-ignore-buffers-re | 199 | (buffer-name buffer)))) |
| 200 | (string-match uniquify-ignore-buffers-re | 200 | ;; Only try to rename buffers we actually manage. |
| 201 | bufname))) | 201 | (setq items (buffer-local-value 'uniquify-managed buffer)) |
| 202 | ;; Only try to rename buffers we actually manage. | 202 | (equal base (uniquify-item-base (car items))) |
| 203 | (or (buffer-local-value 'uniquify-managed buffer) | 203 | ;; Don't re-add stuff we already have. Actually this |
| 204 | (eq buffer newbuf)) | 204 | ;; whole `and' test should only match at most once. |
| 205 | (setq bfn (if (eq buffer newbuf) newbuffile | 205 | (not (memq (car items) fix-list))) |
| 206 | (uniquify-buffer-file-name buffer))) | 206 | (setq fix-list (append fix-list items)))) |
| 207 | (equal (file-name-nondirectory bfn) base)) | ||
| 208 | (when (setq bfn (file-name-directory bfn)) ;Strip off the `base'. | ||
| 209 | (setq bfn (directory-file-name bfn))) ;Strip trailing slash. | ||
| 210 | (push (uniquify-make-item base bfn buffer) | ||
| 211 | fix-list)))) | ||
| 212 | ;; selects buffers whose names may need changing, and others that | 207 | ;; selects buffers whose names may need changing, and others that |
| 213 | ;; may conflict, then bring conflicting names together | 208 | ;; may conflict, then bring conflicting names together |
| 214 | (uniquify-rationalize fix-list)))) | 209 | (uniquify-rationalize fix-list)))) |
| 215 | 210 | ||
| 216 | ;; uniquify's version of buffer-file-name; result never contains trailing slash | 211 | ;; uniquify's version of buffer-file-name; result never contains trailing slash |
| 217 | (defun uniquify-buffer-file-name (buffer) | 212 | (defun uniquify-buffer-file-name (buffer) |
| 218 | "Return name of file BUFFER is visiting, or nil if none. | 213 | "Return name of directory, file BUFFER is visiting, or nil if none. |
| 219 | Works on ordinary file-visiting buffers and buffers whose mode is mentioned | 214 | Works on ordinary file-visiting buffers and buffers whose mode is mentioned |
| 220 | in `uniquify-list-buffers-directory-modes', otherwise returns nil." | 215 | in `uniquify-list-buffers-directory-modes', otherwise returns nil." |
| 221 | (or (buffer-file-name buffer) | 216 | (with-current-buffer buffer |
| 222 | (with-current-buffer buffer | 217 | (let ((filename |
| 223 | (if (memq major-mode uniquify-list-buffers-directory-modes) | 218 | (or buffer-file-name |
| 224 | (and list-buffers-directory | 219 | (if (memq major-mode uniquify-list-buffers-directory-modes) |
| 225 | (directory-file-name list-buffers-directory)))))) | 220 | list-buffers-directory)))) |
| 221 | (when filename | ||
| 222 | (file-name-directory (expand-file-name (directory-file-name filename))))))) | ||
| 226 | 223 | ||
| 227 | (defun uniquify-rerationalize-w/o-cb (fix-list) | 224 | (defun uniquify-rerationalize-w/o-cb (fix-list) |
| 228 | "Re-rationalize the buffers in FIX-LIST, but ignoring current-buffer." | 225 | "Re-rationalize the buffers in FIX-LIST, but ignoring current-buffer." |
| @@ -230,10 +227,6 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil." | |||
| 230 | (dolist (item fix-list) | 227 | (dolist (item fix-list) |
| 231 | (let ((buf (uniquify-item-buffer item))) | 228 | (let ((buf (uniquify-item-buffer item))) |
| 232 | (unless (or (eq buf (current-buffer)) (not (buffer-live-p buf))) | 229 | (unless (or (eq buf (current-buffer)) (not (buffer-live-p buf))) |
| 233 | ;; Reset the proposed names. | ||
| 234 | (setf (uniquify-item-proposed item) | ||
| 235 | (uniquify-get-proposed-name (uniquify-item-base item) | ||
| 236 | (uniquify-item-dirname item))) | ||
| 237 | (push item new-fix-list)))) | 230 | (push item new-fix-list)))) |
| 238 | (when new-fix-list | 231 | (when new-fix-list |
| 239 | (uniquify-rationalize new-fix-list)))) | 232 | (uniquify-rationalize new-fix-list)))) |
| @@ -409,13 +402,18 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil." | |||
| 409 | (when uniquify-buffer-name-style | 402 | (when uniquify-buffer-name-style |
| 410 | ;; Rerationalize w.r.t the new name. | 403 | ;; Rerationalize w.r.t the new name. |
| 411 | (uniquify-rationalize-file-buffer-names | 404 | (uniquify-rationalize-file-buffer-names |
| 412 | (uniquify-buffer-file-name (current-buffer)) (current-buffer)) | 405 | (ad-get-arg 0) |
| 406 | (uniquify-buffer-file-name (current-buffer)) | ||
| 407 | (current-buffer)) | ||
| 413 | (setq ad-return-value (buffer-name (current-buffer)))))) | 408 | (setq ad-return-value (buffer-name (current-buffer)))))) |
| 414 | 409 | ||
| 415 | (defadvice create-file-buffer (after create-file-buffer-uniquify activate) | 410 | (defadvice create-file-buffer (after create-file-buffer-uniquify activate) |
| 416 | "Uniquify buffer names with parts of directory name." | 411 | "Uniquify buffer names with parts of directory name." |
| 417 | (if uniquify-buffer-name-style | 412 | (if uniquify-buffer-name-style |
| 418 | (uniquify-rationalize-file-buffer-names (ad-get-arg 0) ad-return-value))) | 413 | (let ((filename (expand-file-name (directory-file-name (ad-get-arg 0))))) |
| 414 | (uniquify-rationalize-file-buffer-names | ||
| 415 | (file-name-nondirectory filename) | ||
| 416 | (file-name-directory filename) ad-return-value)))) | ||
| 419 | 417 | ||
| 420 | ;; Buffer deletion | 418 | ;; Buffer deletion |
| 421 | ;; Rerationalize after a buffer is killed, to reduce coinciding buffer names. | 419 | ;; Rerationalize after a buffer is killed, to reduce coinciding buffer names. |