Mercurial > emacs
annotate lisp/buff-menu.el @ 20331:39baaa9c5980
Some comment and doc fixes.
(ps-print-version): New version number (3.05.2) and doc fix.
(ps-print, ps-header-lines, ps-show-n-of-n, ps-font-info-database)
(ps-font-family, ps-font-size, ps-header-font-family)
(ps-header-font-size, ps-header-title-font-size, ps-bold-faces)
(ps-italic-faces, ps-underlined-faces, ps-left-header, ps-right-header)
(ps-font, ps-font-bold, ps-font-italic, ps-font-bold-italic)
(ps-avg-char-width, ps-space-width, ps-line-height): Doc fix.
(ps-error-scale-font): New fn.
(ps-soft-lf, ps-hard-lf): Fn deleted.
(ps-get-page-dimensions, ps-set-bg, ps-face-bold-p, ps-face-italic-p)
(ps-set-color): Reindentation.
(ps-output-string-prim, ps-xemacs-face-kind-p): Internal blank lines
deleted.
(ps-set-font): Little programming improvement.
(ps-line-lengths-internal, ps-nb-pages, ps-select-font)
(ps-select-header-font): Simplify some expressions.
(ps-plot-region): Replace (- X 1) by (1- X).
(ps-generate-header): Replace (+ X 1) by (1+ X).
(ps-print-preprint, ps-plot-with-face, ps-print-ensure-fontified)
(ps-kill-emacs-check): Replace (if (and A B) C) by (and A B C).
(ps-init-output-queue, ps-gnus-article-prepare-hook, ps-jts-ps-setup):
Replace (setq a b)(setq c d) by (setq a b c d).
(ps-begin-file, ps-end-file): Replace (ps-output A)(ps-output B)
by (ps-output A B).
(ps-begin-page): Replace (ps-output A)(ps-output B) by (ps-output A B),
replace (setq a b)(setq c d) by (setq a b c d).
(ps-next-line, ps-continue-line): Replace (setq a b)(setq c d)
by (setq a b c d), and incorporates ps-soft-lf and ps-hard-lf,
respectively.
(ps-plot): Replace (setq a b)(setq c d) by (setq a b c d),
and programming improvement.
(ps-generate-postscript-with-faces): Initialization fix,
replace (setq a b)(setq c d) by (setq a b c d),
replace (if (and A B) C) by (and A B C).
(ps-generate): Doc fix, reprogramming to set the page count,
replace (setq a b)(setq c d) by (setq a b c d),
replace (if A nil B) by (or A B),
replace (if (and A B) C) by (and A B C).
(ps-info-mode-hook): Replace (list 'A 'B) by '(A B).
(ps-jack-setup): Replace (list) by nil.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sun, 23 Nov 1997 02:26:50 +0000 |
parents | f693db11df45 |
children | a259327d5333 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
1 ;;; buff-menu.el --- buffer menu main function and support functions. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
2 |
11234 | 3 ;; Copyright (C) 1985, 86, 87, 93, 94, 95 Free Software Foundation, Inc. |
845 | 4 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
5 ;; Maintainer: FSF |
194 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
735 | 11 ;; the Free Software Foundation; either version 2, or (at your option) |
194 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
194 | 23 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
24 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 ;; Edit, delete, or change attributes of all currently active Emacs |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2736
diff
changeset
|
27 ;; buffers from a list summarizing their state. A good way to browse |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; any special or scratch buffers you have loaded, since you can't find |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
29 ;; them by filename. The single entry point is `Buffer-menu-mode', |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
30 ;; normally bound to C-x C-b. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
31 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
32 ;;; Change Log: |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
33 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
34 ;; Merged by esr with recent mods to Emacs 19 buff-menu, 23 Mar 1993 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
35 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
36 ;; Modified by Bob Weiner, Motorola, Inc., 4/14/89 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
37 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
38 ;; Added optional backup argument to 'Buffer-menu-unmark' to make it undelete |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
39 ;; current entry and then move to previous one. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
40 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
41 ;; Based on FSF code dating back to 1985. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
42 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
43 ;;; Code: |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
44 |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
45 ;;;Trying to preserve the old window configuration works well in |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
46 ;;;simple scenarios, when you enter the buffer menu, use it, and exit it. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
47 ;;;But it does strange things when you switch back to the buffer list buffer |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
48 ;;;with C-x b, later on, when the window configuration is different. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
49 ;;;The choice seems to be, either restore the window configuration |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
50 ;;;in all cases, or in no cases. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
51 ;;;I decided it was better not to restore the window config at all. -- rms. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
52 |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
53 ;;;But since then, I changed buffer-menu to use the selected window, |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
54 ;;;so q now once again goes back to the previous window configuration. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
55 |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
56 ;;;(defvar Buffer-menu-window-config nil |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
57 ;;; "Window configuration saved from entry to `buffer-menu'.") |
194 | 58 |
59 ; Put buffer *Buffer List* into proper mode right away | |
60 ; so that from now on even list-buffers is enough to get a buffer menu. | |
61 | |
6640
532754d63384
(Buffer-menu-mode): Highlight only the buffer name, not the whole line.
Karl Heuer <kwzh@gnu.org>
parents:
6638
diff
changeset
|
62 (defvar Buffer-menu-buffer-column nil) |
532754d63384
(Buffer-menu-mode): Highlight only the buffer name, not the whole line.
Karl Heuer <kwzh@gnu.org>
parents:
6638
diff
changeset
|
63 |
194 | 64 (defvar Buffer-menu-mode-map nil "") |
65 | |
66 (if Buffer-menu-mode-map | |
67 () | |
68 (setq Buffer-menu-mode-map (make-keymap)) | |
69 (suppress-keymap Buffer-menu-mode-map t) | |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
70 (define-key Buffer-menu-mode-map "q" 'Buffer-menu-quit) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
71 (define-key Buffer-menu-mode-map "v" 'Buffer-menu-select) |
194 | 72 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) |
73 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) | |
74 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) | |
10269
988517b0b62a
(Buffer-menu-mode-map): Bind C-m to Buffer-menu-this-window.
Richard M. Stallman <rms@gnu.org>
parents:
10194
diff
changeset
|
75 (define-key Buffer-menu-mode-map "\C-m" 'Buffer-menu-this-window) |
194 | 76 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) |
735 | 77 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) |
194 | 78 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) |
79 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) | |
80 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) | |
81 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) | |
82 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) | |
83 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) | |
84 (define-key Buffer-menu-mode-map " " 'next-line) | |
85 (define-key Buffer-menu-mode-map "n" 'next-line) | |
86 (define-key Buffer-menu-mode-map "p" 'previous-line) | |
87 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) | |
88 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) | |
89 (define-key Buffer-menu-mode-map "?" 'describe-mode) | |
90 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) | |
91 (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark) | |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
92 (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
93 (define-key Buffer-menu-mode-map "%" 'Buffer-menu-toggle-read-only) |
18278
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
94 (define-key Buffer-menu-mode-map "b" 'Buffer-menu-bury) |
16401
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
95 (define-key Buffer-menu-mode-map "g" 'Buffer-menu-revert) |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
96 (define-key Buffer-menu-mode-map [mouse-2] 'Buffer-menu-mouse-select) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
97 ) |
194 | 98 |
99 ;; Buffer Menu mode is suitable only for specially formatted data. | |
100 (put 'Buffer-menu-mode 'mode-class 'special) | |
101 | |
102 (defun Buffer-menu-mode () | |
103 "Major mode for editing a list of buffers. | |
104 Each line describes one of the buffers in Emacs. | |
105 Letters do not insert themselves; instead, they are commands. | |
106 \\<Buffer-menu-mode-map> | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
107 \\[Buffer-menu-mouse-select] -- select buffer you click on, in place of the buffer menu. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
108 \\[Buffer-menu-this-window] -- select current line's buffer in place of the buffer menu. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
109 \\[Buffer-menu-other-window] -- select that buffer in another window, |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
110 so the buffer menu buffer remains visible in its window. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
111 \\[Buffer-menu-switch-other-window] -- make another window display that buffer. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
112 \\[Buffer-menu-mark] -- mark current line's buffer to be displayed. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
113 \\[Buffer-menu-select] -- select current line's buffer. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
114 Also show buffers marked with m, in other windows. |
777 | 115 \\[Buffer-menu-1-window] -- select that buffer in full-frame window. |
194 | 116 \\[Buffer-menu-2-window] -- select that buffer in one window, |
117 together with buffer selected before this one in another window. | |
118 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer. | |
119 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. | |
120 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down. | |
121 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down. | |
122 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up. | |
123 \\[Buffer-menu-execute] -- delete or save marked buffers. | |
124 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
125 With prefix argument, also move up one line. |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
126 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks. |
16401
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
127 \\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line. |
18280
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
128 \\[Buffer-menu-revert] -- update the list of buffers. |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
129 \\[Buffer-menu-bury] -- bury the buffer listed on this line." |
194 | 130 (kill-all-local-variables) |
131 (use-local-map Buffer-menu-mode-map) | |
6638
61e40a447c92
(Buffer-menu-mode): Add mouse-face properties.
Karl Heuer <kwzh@gnu.org>
parents:
6609
diff
changeset
|
132 (setq major-mode 'Buffer-menu-mode) |
61e40a447c92
(Buffer-menu-mode): Add mouse-face properties.
Karl Heuer <kwzh@gnu.org>
parents:
6609
diff
changeset
|
133 (setq mode-name "Buffer Menu") |
8161
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
134 (make-local-variable 'revert-buffer-function) |
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
135 (setq revert-buffer-function 'Buffer-menu-revert-function) |
194 | 136 (setq truncate-lines t) |
137 (setq buffer-read-only t) | |
138 (run-hooks 'buffer-menu-mode-hook)) | |
8161
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
139 |
16401
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
140 (defun Buffer-menu-revert () |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
141 "Update the list of buffers." |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
142 (interactive) |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
143 (revert-buffer)) |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
144 |
8161
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
145 (defun Buffer-menu-revert-function (ignore1 ignore2) |
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
146 (list-buffers)) |
194 | 147 |
148 (defun Buffer-menu-buffer (error-if-non-existent-p) | |
149 "Return buffer described by this line of buffer menu." | |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
150 (let* ((where (save-excursion |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
151 (beginning-of-line) |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
152 (+ (point) Buffer-menu-buffer-column))) |
11842
e8739cc8cd02
(Buffer-menu-buffer): Give more informative error
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
153 (name (and (not (eobp)) (get-text-property where 'buffer-name)))) |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
154 (if name |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
155 (or (get-buffer name) |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
156 (if error-if-non-existent-p |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
157 (error "No buffer named `%s'" name) |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
158 nil)) |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
159 (if error-if-non-existent-p |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
160 (error "No buffer on this line") |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
161 nil)))) |
194 | 162 |
756 | 163 (defun buffer-menu (&optional arg) |
194 | 164 "Make a menu of buffers so you can save, delete or select them. |
165 With argument, show only buffers that are visiting files. | |
166 Type ? after invocation to get help on commands available. | |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
167 Type q immediately to make the buffer menu go away." |
194 | 168 (interactive "P") |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
169 ;;; (setq Buffer-menu-window-config (current-window-configuration)) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
170 (switch-to-buffer (list-buffers-noselect arg)) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
171 (message |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
172 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
173 |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
174 (defun buffer-menu-other-window (&optional arg) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
175 "Display a list of buffers in another window. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
176 With the buffer list buffer, you can save, delete or select the buffers. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
177 With argument, show only buffers that are visiting files. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
178 Type ? after invocation to get help on commands available. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
179 Type q immediately to make the buffer menu go away." |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
180 (interactive "P") |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
181 ;;; (setq Buffer-menu-window-config (current-window-configuration)) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
182 (switch-to-buffer-other-window (list-buffers-noselect arg)) |
194 | 183 (message |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
184 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
185 |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
186 (defun Buffer-menu-quit () |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
187 "Quit the buffer menu." |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
188 (interactive) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
189 (let ((buffer (current-buffer))) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
190 ;; Switch away from the buffer menu and bury it. |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
191 (switch-to-buffer (other-buffer)) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
192 (bury-buffer buffer))) |
194 | 193 |
194 (defun Buffer-menu-mark () | |
195 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | |
196 (interactive) | |
197 (beginning-of-line) | |
198 (if (looking-at " [-M]") | |
199 (ding) | |
200 (let ((buffer-read-only nil)) | |
201 (delete-char 1) | |
202 (insert ?>) | |
203 (forward-line 1)))) | |
204 | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
205 (defun Buffer-menu-unmark (&optional backup) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
206 "Cancel all requested operations on buffer on this line and move down. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
207 Optional ARG means move up." |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
208 (interactive "P") |
194 | 209 (beginning-of-line) |
210 (if (looking-at " [-M]") | |
211 (ding) | |
212 (let* ((buf (Buffer-menu-buffer t)) | |
213 (mod (buffer-modified-p buf)) | |
214 (readonly (save-excursion (set-buffer buf) buffer-read-only)) | |
215 (buffer-read-only nil)) | |
216 (delete-char 3) | |
217 (insert (if readonly (if mod " *%" " %") (if mod " * " " "))))) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
218 (forward-line (if backup -1 1))) |
194 | 219 |
220 (defun Buffer-menu-backup-unmark () | |
221 "Move up and cancel all requested operations on buffer on line above." | |
222 (interactive) | |
223 (forward-line -1) | |
224 (Buffer-menu-unmark) | |
225 (forward-line -1)) | |
226 | |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
227 (defun Buffer-menu-delete (&optional arg) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
228 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command. |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
229 Prefix arg is how many buffers to delete. |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
230 Negative arg means delete backwards." |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
231 (interactive "p") |
194 | 232 (beginning-of-line) |
233 (if (looking-at " [-M]") ;header lines | |
234 (ding) | |
235 (let ((buffer-read-only nil)) | |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
236 (if (or (null arg) (= arg 0)) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
237 (setq arg 1)) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
238 (while (> arg 0) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
239 (delete-char 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
240 (insert ?D) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
241 (forward-line 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
242 (setq arg (1- arg))) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
243 (while (< arg 0) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
244 (delete-char 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
245 (insert ?D) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
246 (forward-line -1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
247 (setq arg (1+ arg)))))) |
194 | 248 |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
249 (defun Buffer-menu-delete-backwards (&optional arg) |
194 | 250 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
251 and then move up one line. Prefix arg means move that many lines." |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
252 (interactive "p") |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
253 (Buffer-menu-delete (- (or arg 1))) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
254 (while (looking-at " [-M]") |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
255 (forward-line 1))) |
194 | 256 |
257 (defun Buffer-menu-save () | |
258 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
259 (interactive) | |
260 (beginning-of-line) | |
261 (if (looking-at " [-M]") ;header lines | |
262 (ding) | |
263 (let ((buffer-read-only nil)) | |
10765
638d2df80894
(Buffer-menu-save): Fix the test for header line.
Richard M. Stallman <rms@gnu.org>
parents:
10593
diff
changeset
|
264 (forward-char 1) |
194 | 265 (delete-char 1) |
266 (insert ?S) | |
267 (forward-line 1)))) | |
268 | |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
269 (defun Buffer-menu-not-modified (&optional arg) |
194 | 270 "Mark buffer on this line as unmodified (no changes to save)." |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
271 (interactive "P") |
194 | 272 (save-excursion |
273 (set-buffer (Buffer-menu-buffer t)) | |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
274 (set-buffer-modified-p arg)) |
194 | 275 (save-excursion |
276 (beginning-of-line) | |
277 (forward-char 1) | |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
278 (if (= (char-after (point)) (if arg ? ?*)) |
194 | 279 (let ((buffer-read-only nil)) |
280 (delete-char 1) | |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
281 (insert (if arg ?* ? )))))) |
194 | 282 |
283 (defun Buffer-menu-execute () | |
284 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." | |
285 (interactive) | |
286 (save-excursion | |
287 (goto-char (point-min)) | |
288 (forward-line 1) | |
289 (while (re-search-forward "^.S" nil t) | |
290 (let ((modp nil)) | |
291 (save-excursion | |
292 (set-buffer (Buffer-menu-buffer t)) | |
293 (save-buffer) | |
294 (setq modp (buffer-modified-p))) | |
295 (let ((buffer-read-only nil)) | |
296 (delete-char -1) | |
297 (insert (if modp ?* ? )))))) | |
298 (save-excursion | |
299 (goto-char (point-min)) | |
300 (forward-line 1) | |
301 (let ((buff-menu-buffer (current-buffer)) | |
302 (buffer-read-only nil)) | |
303 (while (search-forward "\nD" nil t) | |
304 (forward-char -1) | |
305 (let ((buf (Buffer-menu-buffer nil))) | |
306 (or (eq buf nil) | |
307 (eq buf buff-menu-buffer) | |
308 (save-excursion (kill-buffer buf)))) | |
309 (if (Buffer-menu-buffer nil) | |
310 (progn (delete-char 1) | |
311 (insert ? )) | |
312 (delete-region (point) (progn (forward-line 1) (point))) | |
313 (forward-char -1)))))) | |
314 | |
315 (defun Buffer-menu-select () | |
316 "Select this line's buffer; also display buffers marked with `>'. | |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
317 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
318 This command deletes and replaces all the previously existing windows |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
319 in the selected frame." |
194 | 320 (interactive) |
321 (let ((buff (Buffer-menu-buffer t)) | |
322 (menu (current-buffer)) | |
323 (others ()) | |
324 tem) | |
325 (goto-char (point-min)) | |
326 (while (search-forward "\n>" nil t) | |
327 (setq tem (Buffer-menu-buffer t)) | |
328 (let ((buffer-read-only nil)) | |
329 (delete-char -1) | |
330 (insert ?\ )) | |
331 (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) | |
332 (setq others (nreverse others) | |
777 | 333 tem (/ (1- (frame-height)) (1+ (length others)))) |
194 | 334 (delete-other-windows) |
335 (switch-to-buffer buff) | |
336 (or (eq menu buff) | |
337 (bury-buffer menu)) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
338 (if (equal (length others) 0) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
339 (progn |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
340 ;;; ;; Restore previous window configuration before displaying |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
341 ;;; ;; selected buffers. |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
342 ;;; (if Buffer-menu-window-config |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
343 ;;; (progn |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
344 ;;; (set-window-configuration Buffer-menu-window-config) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
345 ;;; (setq Buffer-menu-window-config nil))) |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
346 (switch-to-buffer buff)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
347 (while others |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
348 (split-window nil tem) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
349 (other-window 1) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
350 (switch-to-buffer (car others)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
351 (setq others (cdr others))) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
352 (other-window 1) ;back to the beginning! |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
353 ))) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
354 |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
355 |
194 | 356 |
357 (defun Buffer-menu-visit-tags-table () | |
358 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | |
359 (interactive) | |
360 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | |
361 (if file | |
362 (visit-tags-table file) | |
363 (error "Specified buffer has no file")))) | |
364 | |
365 (defun Buffer-menu-1-window () | |
777 | 366 "Select this line's buffer, alone, in full frame." |
194 | 367 (interactive) |
368 (switch-to-buffer (Buffer-menu-buffer t)) | |
369 (bury-buffer (other-buffer)) | |
370 (delete-other-windows)) | |
371 | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
372 (defun Buffer-menu-mouse-select (event) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
373 "Select the buffer whose line you click on." |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
374 (interactive "e") |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
375 (let (buffer) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
376 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
377 (set-buffer (window-buffer (posn-window (event-end event)))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
378 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
379 (goto-char (posn-point (event-end event))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
380 (setq buffer (Buffer-menu-buffer t)))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
381 (select-window (posn-window (event-end event))) |
7659
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
382 (if (and (window-dedicated-p (selected-window)) |
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
383 (eq (selected-window) (frame-root-window))) |
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
384 (switch-to-buffer-other-frame buffer) |
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
385 (switch-to-buffer buffer)))) |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
386 |
194 | 387 (defun Buffer-menu-this-window () |
388 "Select this line's buffer in this window." | |
389 (interactive) | |
390 (switch-to-buffer (Buffer-menu-buffer t))) | |
391 | |
392 (defun Buffer-menu-other-window () | |
393 "Select this line's buffer in other window, leaving buffer menu visible." | |
394 (interactive) | |
395 (switch-to-buffer-other-window (Buffer-menu-buffer t))) | |
396 | |
735 | 397 (defun Buffer-menu-switch-other-window () |
398 "Make the other window select this line's buffer. | |
399 The current window remains selected." | |
400 (interactive) | |
401 (display-buffer (Buffer-menu-buffer t))) | |
402 | |
194 | 403 (defun Buffer-menu-2-window () |
404 "Select this line's buffer, with previous buffer in second window." | |
405 (interactive) | |
406 (let ((buff (Buffer-menu-buffer t)) | |
407 (menu (current-buffer)) | |
408 (pop-up-windows t)) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
409 (delete-other-windows) |
194 | 410 (switch-to-buffer (other-buffer)) |
411 (pop-to-buffer buff) | |
412 (bury-buffer menu))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
413 |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
414 (defun Buffer-menu-toggle-read-only () |
6084
d42c85701055
(Buffer-menu-toggle-read-only): Change toggle-read-only to
Karl Heuer <kwzh@gnu.org>
parents:
3591
diff
changeset
|
415 "Toggle read-only status of buffer on this line, perhaps via version control." |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
416 (interactive) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
417 (let (char) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
418 (save-excursion |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
419 (set-buffer (Buffer-menu-buffer t)) |
6084
d42c85701055
(Buffer-menu-toggle-read-only): Change toggle-read-only to
Karl Heuer <kwzh@gnu.org>
parents:
3591
diff
changeset
|
420 (vc-toggle-read-only) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
421 (setq char (if buffer-read-only ?% ? ))) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
422 (save-excursion |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
423 (beginning-of-line) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
424 (forward-char 2) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
425 (if (/= (following-char) char) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
426 (let (buffer-read-only) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
427 (delete-char 1) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
428 (insert char)))))) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
429 |
18278
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
430 (defun Buffer-menu-bury () |
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
431 "Bury the buffer listed on this line." |
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
432 (interactive) |
18280
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
433 (beginning-of-line) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
434 (if (looking-at " [-M]") ;header lines |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
435 (ding) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
436 (save-excursion |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
437 (beginning-of-line) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
438 (bury-buffer (Buffer-menu-buffer t)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
439 (let ((line (buffer-substring (point) (progn (forward-line 1) (point)))) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
440 (buffer-read-only nil)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
441 (delete-region (point) (progn (forward-line -1) (point))) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
442 (goto-char (point-max)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
443 (insert line)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
444 (message "Buried buffer moved to the end")))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
445 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
446 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
447 (define-key ctl-x-map "\C-b" 'list-buffers) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
448 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
449 (defun list-buffers (&optional files-only) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
450 "Display a list of names of existing buffers. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
451 The list is displayed in a buffer named `*Buffer List*'. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
452 Note that buffers with names starting with spaces are omitted. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
453 Non-null optional arg FILES-ONLY means mention only file buffers. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
454 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
455 The M column contains a * for buffers that are modified. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
456 The R column contains a % for buffers that are read-only." |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
457 (interactive "P") |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
458 (display-buffer (list-buffers-noselect files-only))) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
459 |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
460 (defun list-buffers-noselect (&optional files-only) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
461 "Create and return a buffer with a list of names of existing buffers. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
462 The buffer is named `*Buffer List*'. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
463 Note that buffers with names starting with spaces are omitted. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
464 Non-null optional arg FILES-ONLY means mention only file buffers. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
465 |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
466 The M column contains a * for buffers that are modified. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
467 The R column contains a % for buffers that are read-only." |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
468 (let ((old-buffer (current-buffer)) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
469 (standard-output standard-output) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
470 desired-point) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
471 (save-excursion |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
472 (set-buffer (get-buffer-create "*Buffer List*")) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
473 (setq buffer-read-only nil) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
474 (erase-buffer) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
475 (setq standard-output (current-buffer)) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
476 (princ "\ |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
477 MR Buffer Size Mode File |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
478 -- ------ ---- ---- ---- |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
479 ") |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
480 ;; Record the column where buffer names start. |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
481 (setq Buffer-menu-buffer-column 4) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
482 (let ((bl (buffer-list))) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
483 (while bl |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
484 (let* ((buffer (car bl)) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
485 (name (buffer-name buffer)) |
10593
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
486 (file (buffer-file-name buffer)) |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
487 this-buffer-line-start |
10593
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
488 this-buffer-read-only |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
489 this-buffer-size |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
490 this-buffer-mode-name |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
491 this-buffer-directory) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
492 (save-excursion |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
493 (set-buffer buffer) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
494 (setq this-buffer-read-only buffer-read-only) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
495 (setq this-buffer-size (buffer-size)) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
496 (setq this-buffer-mode-name |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
497 (if (eq buffer standard-output) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
498 "Buffer Menu" mode-name)) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
499 (or file |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
500 ;; No visited file. Check local value of |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
501 ;; list-buffers-directory. |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
502 (if (and (boundp 'list-buffers-directory) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
503 list-buffers-directory) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
504 (setq this-buffer-directory list-buffers-directory)))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
505 (cond |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
506 ;; Don't mention internal buffers. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
507 ((string= (substring name 0 1) " ")) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
508 ;; Maybe don't mention buffers without files. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
509 ((and files-only (not file))) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
510 ;; Otherwise output info. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
511 (t |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
512 (setq this-buffer-line-start (point)) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
513 ;; Identify current buffer. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
514 (if (eq buffer old-buffer) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
515 (progn |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
516 (setq desired-point (point)) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
517 (princ ".")) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
518 (princ " ")) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
519 ;; Identify modified buffers. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
520 (princ (if (buffer-modified-p buffer) "*" " ")) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
521 ;; Handle readonly status. The output buffer is special |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
522 ;; cased to appear readonly; it is actually made so at a later |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
523 ;; date. |
10593
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
524 (princ (if (or (eq buffer standard-output) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
525 this-buffer-read-only) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
526 "% " |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
527 " ")) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
528 (princ name) |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
529 ;; Put the buffer name into a text property |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
530 ;; so we don't have to extract it from the text. |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
531 ;; This way we avoid problems with unusual buffer names. |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
532 (setq this-buffer-line-start |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
533 (+ this-buffer-line-start Buffer-menu-buffer-column)) |
12243
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
534 (let ((name-end (point))) |
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
535 (indent-to 17 2) |
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
536 (put-text-property this-buffer-line-start name-end |
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
537 'buffer-name name) |
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
538 (put-text-property this-buffer-line-start name-end |
ef2749cf206f
(list-buffers-noselect): Don't let space after buf name
Richard M. Stallman <rms@gnu.org>
parents:
11842
diff
changeset
|
539 'mouse-face 'highlight)) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
540 (let (size |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
541 mode |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
542 (excess (- (current-column) 17))) |
10593
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
543 (setq size (format "%8d" this-buffer-size)) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
544 ;; Ack -- if looking at the *Buffer List* buffer, |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
545 ;; always use "Buffer Menu" mode. Otherwise the |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
546 ;; first time the buffer is created, the mode will be wrong. |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
547 (setq mode this-buffer-mode-name) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
548 (while (and (> excess 0) (= (aref size 0) ?\ )) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
549 (setq size (substring size 1)) |
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
550 (setq excess (1- excess))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
551 (princ size) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
552 (indent-to 27 1) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
553 (princ mode)) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
554 (indent-to 40 1) |
10593
7ae93c2ee7a2
(list-buffers-noselect): Handle read-only properly.
Richard M. Stallman <rms@gnu.org>
parents:
10592
diff
changeset
|
555 (or file (setq file this-buffer-directory)) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
556 (if file |
10420 | 557 (princ file)) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
558 (princ "\n")))) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
559 (setq bl (cdr bl)))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
560 (Buffer-menu-mode) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
561 ;; DESIRED-POINT doesn't have to be set; it is not when the |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
562 ;; current buffer is not displayed for some reason. |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
563 (and desired-point |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
564 (goto-char desired-point)) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
565 (current-buffer)))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
566 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
567 ;;; buff-menu.el ends here |