Mercurial > emacs
comparison lisp/uniquify.el @ 14295:ca40593f8933
Several doc fixes.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 24 Jan 1996 23:32:14 +0000 |
parents | 83f275dcd93a |
children | d342009009c7 |
comparison
equal
deleted
inserted
replaced
14294:f8eba77ccb7f | 14295:ca40593f8933 |
---|---|
1 ;;; uniquify.el --- unique buffer names dependent on pathname | 1 ;;; uniquify.el --- unique buffer names dependent on file name |
2 | 2 |
3 ;; Copyright (c) 1989, 1995 Free Software Foundation, Inc. | 3 ;; Copyright (c) 1989, 1995 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Dick King <king@reasoning.com> | 5 ;; Author: Dick King <king@reasoning.com> |
6 ;; Maintainer: Michael Ernst <mernst@theory.lcs.mit.edu> | 6 ;; Maintainer: Michael Ernst <mernst@theory.lcs.mit.edu> |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; Emacs's standard method for making buffer names unique adds <2>, <3>, | 28 ;; Emacs's standard method for making buffer names unique adds <2>, <3>, |
29 ;; etc. to the end of (all but one of) the buffers. This file replaces | 29 ;; etc. to the end of (all but one of) the buffers. This file replaces |
30 ;; that behavior, for buffers visiting files and dired buffers, with a | 30 ;; that behavior, for buffers visiting files and dired buffers, with a |
31 ;; uniquification that adds parts of the pathname until the buffer names | 31 ;; uniquification that adds parts of the file name until the buffer names |
32 ;; are unique. For instance, buffers visiting /u/mernst/tmp/Makefile and | 32 ;; are unique. For instance, buffers visiting /u/mernst/tmp/Makefile and |
33 ;; /usr/projects/zaphod/Makefile would be named Makefile|tmp and | 33 ;; /usr/projects/zaphod/Makefile would be named Makefile|tmp and |
34 ;; Makefile|zaphod, respectively (instead of Makefile and Makefile<2>). | 34 ;; Makefile|zaphod, respectively (instead of Makefile and Makefile<2>). |
35 ;; Other buffer name styles are also available. | 35 ;; Other buffer name styles are also available. |
36 | 36 |
74 | 74 |
75 ;;; User-visible variables | 75 ;;; User-visible variables |
76 | 76 |
77 (defvar uniquify-buffer-name-style 'post-forward | 77 (defvar uniquify-buffer-name-style 'post-forward |
78 "*If non-nil, buffer names are uniquified with parts of directory name. | 78 "*If non-nil, buffer names are uniquified with parts of directory name. |
79 The value determines the buffer name style and is one of 'forward, | 79 The value determines the buffer name style and is one of `forward', |
80 'reverse, 'post-forward (the default), or 'post-forward-angle-brackets. | 80 `reverse', `post-forward' (the default), or `post-forward-angle-brackets'. |
81 For example, files /foo/bar/mumble/name and /baz/quux/mumble/name | 81 For example, files `/foo/bar/mumble/name' and `/baz/quux/mumble/name' |
82 would be in the following buffers: | 82 would have the following buffer names in the various styles: |
83 forward bar/mumble/name quux/mumble/name | 83 forward bar/mumble/name quux/mumble/name |
84 reverse name\\mumble\\bar name\\mumble\\quux | 84 reverse name\\mumble\\bar name\\mumble\\quux |
85 post-forward name|bar/mumble name|quux/mumble | 85 post-forward name|bar/mumble name|quux/mumble |
86 post-forward-angle-brackets name<bar/mumble> name<quux/mumble> | 86 post-forward-angle-brackets name<bar/mumble> name<quux/mumble> |
87 nil name name<2>") | 87 nil name name<2>") |
95 "*If non-nil, permit user to choose names for buffers with same base file. | 95 "*If non-nil, permit user to choose names for buffers with same base file. |
96 If the user chooses to name a buffer, uniquification is preempted and no | 96 If the user chooses to name a buffer, uniquification is preempted and no |
97 other buffer names are changed.") | 97 other buffer names are changed.") |
98 | 98 |
99 (defvar uniquify-min-dir-content 0 | 99 (defvar uniquify-min-dir-content 0 |
100 "*Minimum parts of directory pathname included in buffer name.") | 100 "*Minimum parts of directory name included in buffer name.") |
101 | 101 |
102 (defvar uniquify-separator nil | 102 (defvar uniquify-separator nil |
103 "*String separator for buffer name components. | 103 "*String separator for buffer name components. |
104 When `uniquify-buffer-name-style' is 'post-forward, separates | 104 When `uniquify-buffer-name-style' is `post-forward', separates |
105 base file name from directory part in buffer names (default \"|\"). | 105 base file name from directory part in buffer names (default \"|\"). |
106 When `uniquify-buffer-name-style' is 'reverse, separates all | 106 When `uniquify-buffer-name-style' is `reverse', separates all |
107 pathname components (default \"\\\").") | 107 file name components (default \"\\\").") |
108 | 108 |
109 (defvar uniquify-trailing-separator-p nil | 109 (defvar uniquify-trailing-separator-p nil |
110 "*If non-nil, add a pathname separator to dired buffer names. | 110 "*If non-nil, add a file name separator to dired buffer names. |
111 If `uniquify-buffer-name-style' is 'forward, add the separator at the end; | 111 If `uniquify-buffer-name-style' is `forward', add the separator at the end; |
112 if it's is 'reverse, add the separator at the beginning; otherwise, this | 112 if it is `reverse', add the separator at the beginning; otherwise, this |
113 variable is ignored.") | 113 variable is ignored.") |
114 | 114 |
115 | 115 |
116 ;;; Utilities | 116 ;;; Utilities |
117 | 117 |
135 (defvar uniquify-possibly-resolvable nil) | 135 (defvar uniquify-possibly-resolvable nil) |
136 | 136 |
137 ;;; Main entry point. | 137 ;;; Main entry point. |
138 | 138 |
139 (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf) | 139 (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf) |
140 "Makes file buffer names unique by adding segments from pathname. | 140 "Makes file buffer names unique by adding segments from file name. |
141 If `uniquify-min-dir-content' > 0, always pulls that many | 141 If `uniquify-min-dir-content' > 0, always pulls that many |
142 pathname elements. Arguments cause only a subset of buffers to be renamed." | 142 file name elements. Arguments cause only a subset of buffers to be renamed." |
143 (interactive) | 143 (interactive) |
144 (let (fix-list | 144 (let (fix-list |
145 uniquify-non-file-buffer-names | 145 uniquify-non-file-buffer-names |
146 (depth uniquify-min-dir-content)) | 146 (depth uniquify-min-dir-content)) |
147 (let ((buffers (buffer-list))) | 147 (let ((buffers (buffer-list))) |
314 (apply (function concat) sofar))) | 314 (apply (function concat) sofar))) |
315 | 315 |
316 | 316 |
317 ;;; Hooks from the rest of Emacs | 317 ;;; Hooks from the rest of Emacs |
318 | 318 |
319 ;; Emacs 19 (GNU Emacs or XEmacs) | 319 ;; Emacs 19 (Emacs or XEmacs) |
320 | 320 |
321 ;; The logical place to put all this code is in generate-new-buffer-name. | 321 ;; The logical place to put all this code is in generate-new-buffer-name. |
322 ;; It's written in C, so we would add a generate-new-buffer-name-function | 322 ;; It's written in C, so we would add a generate-new-buffer-name-function |
323 ;; which, if non-nil, would be called instead of the C. One problem with | 323 ;; which, if non-nil, would be called instead of the C. One problem with |
324 ;; that is that generate-new-buffer-name takes a potential buffer name as | 324 ;; that is that generate-new-buffer-name takes a potential buffer name as |