Mercurial > emacs
annotate lisp/buff-menu.el @ 63382:9cbfa983c1cf
(read-face-name): Use complete-in-turn complete non-aliases
in preference to face aliases.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 13 Jun 2005 20:47:08 +0000 |
parents | 23e016b887bb |
children | bdac7d2ca09e 5b029ff3b08d |
rev | line source |
---|---|
58425
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
1 ;;; buff-menu.el --- buffer menu main function and support functions -*- coding:utf-8 -*- |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
2 |
58299
40fc4ca7acc0
(list-buffers-noselect): Massage to fit in 80 columns.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58276
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 2000, 2001, 2002, 2003, |
62708
23e016b887bb
Update copyright years.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62703
diff
changeset
|
4 ;; 2004, 2005 Free Software Foundation, Inc. |
845 | 5 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
6 ;; Maintainer: FSF |
39012 | 7 ;; Keywords: convenience |
194 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
735 | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
194 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
194 | 25 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; 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
|
29 ;; 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
|
30 ;; any special or scratch buffers you have loaded, since you can't find |
39012 | 31 ;; them by filename. The single entry point is `list-buffers', |
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
|
32 ;; 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
|
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 ;;; 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
|
35 |
25166
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
36 ;; Buffer-menu-view: New function |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
37 ;; Buffer-menu-view-other-window: New function |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
38 |
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
|
39 ;; 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
|
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 ;; 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
|
42 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
43 ;; 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
|
44 ;; 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
|
45 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
46 ;; 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
|
47 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
48 ;;; Code: |
30851
f9233f642b88
* buff-menu.el (list-buffers-noselect): Use `dolist' instead of
Sam Steingold <sds@gnu.org>
parents:
30828
diff
changeset
|
49 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
50 ;;Trying to preserve the old window configuration works well in |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
51 ;;simple scenarios, when you enter the buffer menu, use it, and exit it. |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
52 ;;But it does strange things when you switch back to the buffer list buffer |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
53 ;;with C-x b, later on, when the window configuration is different. |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
54 ;;The choice seems to be, either restore the window configuration |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
55 ;;in all cases, or in no cases. |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
56 ;;I decided it was better not to restore the window config at all. -- rms. |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
57 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
58 ;;But since then, I changed buffer-menu to use the selected window, |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
59 ;;so q now once again goes back to the previous window configuration. |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
60 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
61 ;;(defvar Buffer-menu-window-config nil |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
62 ;; "Window configuration saved from entry to `buffer-menu'.") |
194 | 63 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
64 ;; Put buffer *Buffer List* into proper mode right away |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
65 ;; so that from now on even list-buffers is enough to get a buffer menu. |
194 | 66 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
67 (defgroup Buffer-menu nil |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
68 "Show a menu of all buffers in a buffer." |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
69 :group 'tools |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
70 :group 'convenience) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
71 |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
72 (defcustom Buffer-menu-use-header-line t |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
73 "*Non-nil means to use an immovable header-line." |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
74 :type 'boolean |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
75 :group 'Buffer-menu) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
76 |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
77 (defface Buffer-menu-buffer-face |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
78 '((t (:weight bold))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
79 "Face used to highlight buffer name." |
62523
a463c8c59947
(Buffer-menu-buffer-face): In group Buffer-menu.
Richard M. Stallman <rms@gnu.org>
parents:
61382
diff
changeset
|
80 :group 'Buffer-menu |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
81 :group 'font-lock-highlighting-faces) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
82 |
48889
ec1a96fb72d6
Change default width of Buffer-menu-buffer+size-width to 24
Robert J. Chassell <bob@rattlesnake.com>
parents:
48864
diff
changeset
|
83 (defcustom Buffer-menu-buffer+size-width 26 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
84 "*How wide to jointly make the buffer name and size columns." |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
85 :type 'number |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
86 :group 'Buffer-menu) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
87 |
48889
ec1a96fb72d6
Change default width of Buffer-menu-buffer+size-width to 24
Robert J. Chassell <bob@rattlesnake.com>
parents:
48864
diff
changeset
|
88 (defcustom Buffer-menu-mode-width 16 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
89 "*How wide to make the mode name column." |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
90 :type 'number |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
91 :group 'Buffer-menu) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
92 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
93 ;; This should get updated & resorted when you click on a column heading |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
94 (defvar Buffer-menu-sort-column nil |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
95 "*2 for sorting by buffer names. 5 for sorting by file names. |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
96 nil for default sorting by visited order.") |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
97 |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
98 (defconst Buffer-menu-buffer-column 4) |
6640
532754d63384
(Buffer-menu-mode): Highlight only the buffer name, not the whole line.
Karl Heuer <kwzh@gnu.org>
parents:
6638
diff
changeset
|
99 |
50033
cd78fe221607
(Buffer-menu-mode-map): Add docstring.
John Paul Wallington <jpw@pobox.com>
parents:
49155
diff
changeset
|
100 (defvar Buffer-menu-mode-map nil |
cd78fe221607
(Buffer-menu-mode-map): Add docstring.
John Paul Wallington <jpw@pobox.com>
parents:
49155
diff
changeset
|
101 "Local keymap for `Buffer-menu-mode' buffers.") |
194 | 102 |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
103 (defvar Buffer-menu-files-only nil |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
104 "Non-nil if the current buffer-menu lists only file buffers. |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
105 This variable determines whether reverting the buffer lists only |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
106 file buffers. It affects both manual reverting and reverting by |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
107 Auto Revert Mode.") |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
108 |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
109 (make-variable-buffer-local 'Buffer-menu-files-only) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
110 |
194 | 111 (if Buffer-menu-mode-map |
112 () | |
113 (setq Buffer-menu-mode-map (make-keymap)) | |
114 (suppress-keymap Buffer-menu-mode-map t) | |
21093
aa96b119d0ef
(Buffer-menu-quit): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
20655
diff
changeset
|
115 (define-key Buffer-menu-mode-map "q" 'quit-window) |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
116 (define-key Buffer-menu-mode-map "v" 'Buffer-menu-select) |
194 | 117 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) |
118 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) | |
119 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) | |
20655
a259327d5333
(Buffer-menu-mode-map): Bind e like f.
Richard M. Stallman <rms@gnu.org>
parents:
18280
diff
changeset
|
120 (define-key Buffer-menu-mode-map "e" '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
|
121 (define-key Buffer-menu-mode-map "\C-m" 'Buffer-menu-this-window) |
194 | 122 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) |
735 | 123 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) |
194 | 124 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) |
125 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) | |
126 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) | |
127 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) | |
128 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) | |
129 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) | |
130 (define-key Buffer-menu-mode-map " " 'next-line) | |
131 (define-key Buffer-menu-mode-map "n" 'next-line) | |
132 (define-key Buffer-menu-mode-map "p" 'previous-line) | |
133 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) | |
134 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) | |
135 (define-key Buffer-menu-mode-map "?" 'describe-mode) | |
136 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) | |
137 (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
|
138 (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
|
139 (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
|
140 (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
|
141 (define-key Buffer-menu-mode-map "g" 'Buffer-menu-revert) |
25166
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
142 (define-key Buffer-menu-mode-map "V" 'Buffer-menu-view) |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
143 (define-key Buffer-menu-mode-map "T" 'Buffer-menu-toggle-files-only) |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
144 (define-key Buffer-menu-mode-map [mouse-2] 'Buffer-menu-mouse-select) |
61382
22d7e92c1591
(Buffer-menu-mode-map): Map follow-link to
Kim F. Storm <storm@cua.dk>
parents:
59092
diff
changeset
|
145 (define-key Buffer-menu-mode-map [follow-link] 'mouse-face) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
146 ) |
194 | 147 |
148 ;; Buffer Menu mode is suitable only for specially formatted data. | |
149 (put 'Buffer-menu-mode 'mode-class 'special) | |
150 | |
151 (defun Buffer-menu-mode () | |
152 "Major mode for editing a list of buffers. | |
153 Each line describes one of the buffers in Emacs. | |
154 Letters do not insert themselves; instead, they are commands. | |
155 \\<Buffer-menu-mode-map> | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
156 \\[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
|
157 \\[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
|
158 \\[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
|
159 so the buffer menu buffer remains visible in its window. |
25166
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
160 \\[Buffer-menu-view] -- select current line's buffer, but in view-mode. |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
161 \\[Buffer-menu-view-other-window] -- select that buffer in |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
162 another window, in view-mode. |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
163 \\[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
|
164 \\[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
|
165 \\[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
|
166 Also show buffers marked with m, in other windows. |
777 | 167 \\[Buffer-menu-1-window] -- select that buffer in full-frame window. |
194 | 168 \\[Buffer-menu-2-window] -- select that buffer in one window, |
169 together with buffer selected before this one in another window. | |
170 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer. | |
171 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. | |
172 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down. | |
173 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down. | |
174 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up. | |
175 \\[Buffer-menu-execute] -- delete or save marked buffers. | |
176 \\[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
|
177 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
|
178 \\[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
|
179 \\[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
|
180 \\[Buffer-menu-revert] -- update the list of buffers. |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
181 \\[Buffer-menu-toggle-files-only] -- toggle whether the menu displays only file buffers. |
18280
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
182 \\[Buffer-menu-bury] -- bury the buffer listed on this line." |
194 | 183 (kill-all-local-variables) |
184 (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
|
185 (setq major-mode 'Buffer-menu-mode) |
61e40a447c92
(Buffer-menu-mode): Add mouse-face properties.
Karl Heuer <kwzh@gnu.org>
parents:
6609
diff
changeset
|
186 (setq mode-name "Buffer Menu") |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
187 (set (make-local-variable 'revert-buffer-function) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
188 'Buffer-menu-revert-function) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
189 (set (make-local-variable 'buffer-stale-function) |
54670
e30c06266ba0
(Buffer-menu-mode): Make the buffer-stale-function return `fast'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
54594
diff
changeset
|
190 #'(lambda (&optional noconfirm) 'fast)) |
194 | 191 (setq truncate-lines t) |
192 (setq buffer-read-only t) | |
62634
2c8a105a05e1
(Buffer-menu-mode): Use `run-mode-hooks'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62523
diff
changeset
|
193 (run-mode-hooks 'buffer-menu-mode-hook)) |
8161
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
194 |
58461 | 195 ;; This function exists so we can make the doc string of Buffer-menu-mode |
196 ;; look nice. | |
16401
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
197 (defun Buffer-menu-revert () |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
198 "Update the list of buffers." |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
199 (interactive) |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
200 (revert-buffer)) |
249f797c3750
(Buffer-menu-revert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 |
8161
6b104526819d
(Buffer-menu-revert-function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7659
diff
changeset
|
202 (defun Buffer-menu-revert-function (ignore1 ignore2) |
59092
49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
Luc Teirlinck <teirllm@auburn.edu>
parents:
58955
diff
changeset
|
203 (or (eq buffer-undo-list t) |
49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
Luc Teirlinck <teirllm@auburn.edu>
parents:
58955
diff
changeset
|
204 (setq buffer-undo-list nil)) |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
205 ;; We can not use save-excursion here. The buffer gets erased. |
62703
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
206 (let ((opoint (point)) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
207 (eobp (eobp)) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
208 (ocol (current-column)) |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
209 (oline (progn (move-to-column 4) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
210 (get-text-property (point) 'buffer))) |
59092
49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
Luc Teirlinck <teirllm@auburn.edu>
parents:
58955
diff
changeset
|
211 (prop (point-min)) |
49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
Luc Teirlinck <teirllm@auburn.edu>
parents:
58955
diff
changeset
|
212 ;; do not make undo records for the reversion. |
49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
Luc Teirlinck <teirllm@auburn.edu>
parents:
58955
diff
changeset
|
213 (buffer-undo-list t)) |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
214 (list-buffers-noselect Buffer-menu-files-only) |
62703
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
215 (if oline |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
216 (while (setq prop (next-single-property-change prop 'buffer)) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
217 (when (eq (get-text-property prop 'buffer) oline) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
218 (goto-char prop) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
219 (move-to-column ocol))) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
220 (goto-char (if eobp (point-max) opoint))))) |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
221 |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
222 (defun Buffer-menu-toggle-files-only (arg) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
223 "Toggle whether the current buffer-menu displays only file buffers. |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
224 With a positive ARG display only file buffers. With zero or |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
225 negative ARG, display other buffers as well." |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
226 (interactive "P") |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
227 (setq Buffer-menu-files-only |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
228 (cond ((not arg) (not Buffer-menu-files-only)) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
229 ((> (prefix-numeric-value arg) 0) t))) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
230 (revert-buffer)) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
231 |
194 | 232 |
233 (defun Buffer-menu-buffer (error-if-non-existent-p) | |
234 "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
|
235 (let* ((where (save-excursion |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
236 (beginning-of-line) |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
237 (+ (point) Buffer-menu-buffer-column))) |
30828
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
238 (name (and (not (eobp)) (get-text-property where 'buffer-name))) |
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
239 (buf (and (not (eobp)) (get-text-property where 'buffer)))) |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
240 (if name |
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
241 (or (get-buffer name) |
30828
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
242 (and buf (buffer-name buf) buf) |
11215
896932ac8ced
(list-buffers-noselect): Put buffer name in a text
Richard M. Stallman <rms@gnu.org>
parents:
10765
diff
changeset
|
243 (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
|
244 (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
|
245 nil)) |
30828
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
246 (or (and buf (buffer-name buf) buf) |
50033
cd78fe221607
(Buffer-menu-mode-map): Add docstring.
John Paul Wallington <jpw@pobox.com>
parents:
49155
diff
changeset
|
247 (if error-if-non-existent-p |
cd78fe221607
(Buffer-menu-mode-map): Add docstring.
John Paul Wallington <jpw@pobox.com>
parents:
49155
diff
changeset
|
248 (error "No buffer on this line") |
30828
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
249 nil))))) |
194 | 250 |
756 | 251 (defun buffer-menu (&optional arg) |
194 | 252 "Make a menu of buffers so you can save, delete or select them. |
253 With argument, show only buffers that are visiting files. | |
254 Type ? after invocation to get help on commands available. | |
40622
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
255 Type q to remove the buffer menu from the display. |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
256 |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
257 The first column shows `>' for a buffer you have |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
258 marked to be displayed, `D' for one you have marked for |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
259 deletion, and `.' for the current buffer. |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
260 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
261 The C column has a `.' for the buffer from which you came. |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
262 The R column has a `%' if the buffer is read-only. |
40622
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
263 The M column has a `*' if it is modified, |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
264 or `S' if you have marked it for saving. |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
265 After this come the buffer name, its size in characters, |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
266 its major mode, and the visited file name (if any)." |
194 | 267 (interactive "P") |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
268 ;;; (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
|
269 (switch-to-buffer (list-buffers-noselect arg)) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
270 (message |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
271 "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
|
272 |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
273 (defun buffer-menu-other-window (&optional arg) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
274 "Display a list of buffers in another window. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
275 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
|
276 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
|
277 Type ? after invocation to get help on commands available. |
40622
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
278 Type q to remove the buffer menu from the display. |
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
279 For more information, see the function `buffer-menu'." |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
280 (interactive "P") |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
281 ;;; (setq Buffer-menu-window-config (current-window-configuration)) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
282 (switch-to-buffer-other-window (list-buffers-noselect arg)) |
194 | 283 (message |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
284 "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
|
285 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
286 (defun Buffer-menu-no-header () |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
287 (beginning-of-line) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
288 (if (or Buffer-menu-use-header-line |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
289 (not (eq (char-after) ?C))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
290 t |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
291 (ding) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
292 (forward-line 1) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
293 nil)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
294 |
194 | 295 (defun Buffer-menu-mark () |
296 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | |
297 (interactive) | |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
298 (when (Buffer-menu-no-header) |
194 | 299 (let ((buffer-read-only nil)) |
300 (delete-char 1) | |
301 (insert ?>) | |
302 (forward-line 1)))) | |
303 | |
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
|
304 (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
|
305 "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
|
306 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
|
307 (interactive "P") |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
308 (when (Buffer-menu-no-header) |
194 | 309 (let* ((buf (Buffer-menu-buffer t)) |
310 (mod (buffer-modified-p buf)) | |
311 (readonly (save-excursion (set-buffer buf) buffer-read-only)) | |
312 (buffer-read-only nil)) | |
313 (delete-char 3) | |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
314 (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
|
315 (forward-line (if backup -1 1))) |
194 | 316 |
317 (defun Buffer-menu-backup-unmark () | |
318 "Move up and cancel all requested operations on buffer on line above." | |
319 (interactive) | |
320 (forward-line -1) | |
321 (Buffer-menu-unmark) | |
322 (forward-line -1)) | |
323 | |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
324 (defun Buffer-menu-delete (&optional arg) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
325 "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
|
326 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
|
327 Negative arg means delete backwards." |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
328 (interactive "p") |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
329 (when (Buffer-menu-no-header) |
194 | 330 (let ((buffer-read-only nil)) |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
331 (if (or (null arg) (= arg 0)) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
332 (setq arg 1)) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
333 (while (> arg 0) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
334 (delete-char 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
335 (insert ?D) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
336 (forward-line 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
337 (setq arg (1- arg))) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
338 (while (and (< arg 0) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
339 (Buffer-menu-no-header)) |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
340 (delete-char 1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
341 (insert ?D) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
342 (forward-line -1) |
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
343 (setq arg (1+ arg)))))) |
194 | 344 |
9063
d6913bc11bb2
(Buffer-menu-delete): Handle prefix arg.
Richard M. Stallman <rms@gnu.org>
parents:
8365
diff
changeset
|
345 (defun Buffer-menu-delete-backwards (&optional arg) |
194 | 346 "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
|
347 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
|
348 (interactive "p") |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
349 (Buffer-menu-delete (- (or arg 1)))) |
194 | 350 |
351 (defun Buffer-menu-save () | |
352 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
353 (interactive) | |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
354 (when (Buffer-menu-no-header) |
194 | 355 (let ((buffer-read-only nil)) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
356 (forward-char 2) |
194 | 357 (delete-char 1) |
358 (insert ?S) | |
359 (forward-line 1)))) | |
360 | |
8196
89db3662bcec
(Buffer-menu-not-modified): Make `Buffer-menu-not-modified' handle an
Richard M. Stallman <rms@gnu.org>
parents:
8161
diff
changeset
|
361 (defun Buffer-menu-not-modified (&optional arg) |
194 | 362 "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
|
363 (interactive "P") |
194 | 364 (save-excursion |
365 (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
|
366 (set-buffer-modified-p arg)) |
194 | 367 (save-excursion |
368 (beginning-of-line) | |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
369 (forward-char 2) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
370 (if (= (char-after) (if arg ? ?*)) |
194 | 371 (let ((buffer-read-only nil)) |
372 (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
|
373 (insert (if arg ?* ? )))))) |
194 | 374 |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
375 (defun Buffer-menu-beginning () |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
376 (goto-char (point-min)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
377 (unless Buffer-menu-use-header-line |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
378 (forward-line))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
379 |
194 | 380 (defun Buffer-menu-execute () |
381 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." | |
382 (interactive) | |
383 (save-excursion | |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
384 (Buffer-menu-beginning) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
385 (while (re-search-forward "^..S" nil t) |
194 | 386 (let ((modp nil)) |
387 (save-excursion | |
388 (set-buffer (Buffer-menu-buffer t)) | |
389 (save-buffer) | |
390 (setq modp (buffer-modified-p))) | |
391 (let ((buffer-read-only nil)) | |
392 (delete-char -1) | |
393 (insert (if modp ?* ? )))))) | |
394 (save-excursion | |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
395 (Buffer-menu-beginning) |
194 | 396 (let ((buff-menu-buffer (current-buffer)) |
397 (buffer-read-only nil)) | |
49050
8b38bac9826a
(Buffer-menu-execute): Fix for effect of header
Dave Love <fx@gnu.org>
parents:
49046
diff
changeset
|
398 (while (re-search-forward "^D" nil t) |
194 | 399 (forward-char -1) |
400 (let ((buf (Buffer-menu-buffer nil))) | |
401 (or (eq buf nil) | |
402 (eq buf buff-menu-buffer) | |
30828
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
403 (save-excursion (kill-buffer buf))) |
26dae0a7f527
(list-buffers-noselect): Set `buffer' as well as
Gerd Moellmann <gerd@gnu.org>
parents:
30824
diff
changeset
|
404 (if (and buf (buffer-name buf)) |
194 | 405 (progn (delete-char 1) |
406 (insert ? )) | |
407 (delete-region (point) (progn (forward-line 1) (point))) | |
49050
8b38bac9826a
(Buffer-menu-execute): Fix for effect of header
Dave Love <fx@gnu.org>
parents:
49046
diff
changeset
|
408 (unless (bobp) |
8b38bac9826a
(Buffer-menu-execute): Fix for effect of header
Dave Love <fx@gnu.org>
parents:
49046
diff
changeset
|
409 (forward-char -1)))))))) |
194 | 410 |
411 (defun Buffer-menu-select () | |
412 "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
|
413 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
|
414 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
|
415 in the selected frame." |
194 | 416 (interactive) |
417 (let ((buff (Buffer-menu-buffer t)) | |
30851
f9233f642b88
* buff-menu.el (list-buffers-noselect): Use `dolist' instead of
Sam Steingold <sds@gnu.org>
parents:
30828
diff
changeset
|
418 (menu (current-buffer)) |
194 | 419 (others ()) |
420 tem) | |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
421 (Buffer-menu-beginning) |
49155
e8a430c172dc
(Buffer-menu-select): Fix for effect of header line.
Andreas Schwab <schwab@suse.de>
parents:
49050
diff
changeset
|
422 (while (re-search-forward "^>" nil t) |
194 | 423 (setq tem (Buffer-menu-buffer t)) |
424 (let ((buffer-read-only nil)) | |
425 (delete-char -1) | |
426 (insert ?\ )) | |
427 (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) | |
428 (setq others (nreverse others) | |
777 | 429 tem (/ (1- (frame-height)) (1+ (length others)))) |
194 | 430 (delete-other-windows) |
431 (switch-to-buffer buff) | |
432 (or (eq menu buff) | |
433 (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
|
434 (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
|
435 (progn |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
436 ;;; ;; 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
|
437 ;;; ;; selected buffers. |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
438 ;;; (if Buffer-menu-window-config |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
439 ;;; (progn |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
440 ;;; (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
|
441 ;;; (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
|
442 (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
|
443 (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
|
444 (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
|
445 (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
|
446 (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
|
447 (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
|
448 (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
|
449 ))) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
450 |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
451 |
194 | 452 |
453 (defun Buffer-menu-visit-tags-table () | |
454 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | |
455 (interactive) | |
456 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | |
457 (if file | |
458 (visit-tags-table file) | |
459 (error "Specified buffer has no file")))) | |
460 | |
461 (defun Buffer-menu-1-window () | |
777 | 462 "Select this line's buffer, alone, in full frame." |
194 | 463 (interactive) |
464 (switch-to-buffer (Buffer-menu-buffer t)) | |
465 (bury-buffer (other-buffer)) | |
466 (delete-other-windows)) | |
467 | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
468 (defun Buffer-menu-mouse-select (event) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
469 "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
|
470 (interactive "e") |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
471 (let (buffer) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
472 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
473 (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
|
474 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
475 (goto-char (posn-point (event-end event))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
476 (setq buffer (Buffer-menu-buffer t)))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
477 (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
|
478 (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
|
479 (eq (selected-window) (frame-root-window))) |
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
480 (switch-to-buffer-other-frame buffer) |
ed3bbbdd9ef5
(Buffer-menu-mouse-select): Handle dedicated window.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
481 (switch-to-buffer buffer)))) |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
482 |
194 | 483 (defun Buffer-menu-this-window () |
484 "Select this line's buffer in this window." | |
485 (interactive) | |
486 (switch-to-buffer (Buffer-menu-buffer t))) | |
487 | |
488 (defun Buffer-menu-other-window () | |
489 "Select this line's buffer in other window, leaving buffer menu visible." | |
490 (interactive) | |
491 (switch-to-buffer-other-window (Buffer-menu-buffer t))) | |
492 | |
735 | 493 (defun Buffer-menu-switch-other-window () |
494 "Make the other window select this line's buffer. | |
495 The current window remains selected." | |
496 (interactive) | |
58955
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
497 (let ((pop-up-windows t) |
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
498 same-window-buffer-names |
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
499 same-window-regexps) |
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
500 (display-buffer (Buffer-menu-buffer t)))) |
735 | 501 |
194 | 502 (defun Buffer-menu-2-window () |
503 "Select this line's buffer, with previous buffer in second window." | |
504 (interactive) | |
505 (let ((buff (Buffer-menu-buffer t)) | |
506 (menu (current-buffer)) | |
58955
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
507 (pop-up-windows t) |
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
508 same-window-buffer-names |
58f1100f0a9e
(Buffer-menu-switch-other-window): Bind pop-up-windows to t.
Juri Linkov <juri@jurta.org>
parents:
58954
diff
changeset
|
509 same-window-regexps) |
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
|
510 (delete-other-windows) |
194 | 511 (switch-to-buffer (other-buffer)) |
512 (pop-to-buffer buff) | |
513 (bury-buffer menu))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
514 |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
515 (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
|
516 "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
|
517 (interactive) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
518 (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
|
519 (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
|
520 (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
|
521 (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
|
522 (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
|
523 (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
|
524 (beginning-of-line) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
525 (forward-char 1) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
526 (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
|
527 (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
|
528 (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
|
529 (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
|
530 |
18278
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
531 (defun Buffer-menu-bury () |
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
532 "Bury the buffer listed on this line." |
4f78346eb734
(Buffer-menu-bury): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16401
diff
changeset
|
533 (interactive) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
534 (when (Buffer-menu-no-header) |
18280
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
535 (save-excursion |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
536 (beginning-of-line) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
537 (bury-buffer (Buffer-menu-buffer t)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
538 (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
|
539 (buffer-read-only nil)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
540 (delete-region (point) (progn (forward-line -1) (point))) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
541 (goto-char (point-max)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
542 (insert line)) |
f693db11df45
(Buffer-menu-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18278
diff
changeset
|
543 (message "Buried buffer moved to the end")))) |
25166
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
544 |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
545 |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
546 (defun Buffer-menu-view () |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
547 "View this line's buffer in View mode." |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
548 (interactive) |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
549 (view-buffer (Buffer-menu-buffer t))) |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
550 |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
551 |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
552 (defun Buffer-menu-view-other-window () |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
553 "View this line's buffer in View mode in another window." |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
554 (interactive) |
e8ec0085ff7b
(Buffer-menu-mode-map): Add V for Buffer-menu-View.
Richard M. Stallman <rms@gnu.org>
parents:
21093
diff
changeset
|
555 (view-buffer-other-window (Buffer-menu-buffer t))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
556 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
557 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
558 (define-key ctl-x-map "\C-b" 'list-buffers) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
559 |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
560 (defun list-buffers (&optional files-only) |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
561 "Display a list of names of existing buffers. |
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
562 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
|
563 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
|
564 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
|
565 |
40622
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
566 For more information, see the function `buffer-menu'." |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
567 (interactive "P") |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
568 (display-buffer (list-buffers-noselect files-only))) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
569 |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
570 (defun Buffer-menu-buffer+size (name size &optional name-props size-props) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
571 (if (> (+ (length name) (length size) 2) Buffer-menu-buffer+size-width) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
572 (setq name |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
573 (if (string-match "<[0-9]+>$" name) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
574 (concat (substring name 0 |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
575 (- Buffer-menu-buffer+size-width |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
576 (max (length size) 3) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
577 (match-end 0) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
578 (- (match-beginning 0)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
579 2)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
580 ":" ; narrow ellipsis |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
581 (match-string 0 name)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
582 (concat (substring name 0 |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
583 (- Buffer-menu-buffer+size-width |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
584 (max (length size) 3) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
585 2)) |
49046
d6e1c5f7f468
(Buffer-menu-buffer+size): Don't clobber buffer name.
Andreas Schwab <schwab@suse.de>
parents:
48889
diff
changeset
|
586 ":"))) ; narrow ellipsis |
d6e1c5f7f468
(Buffer-menu-buffer+size): Don't clobber buffer name.
Andreas Schwab <schwab@suse.de>
parents:
48889
diff
changeset
|
587 ;; Don't put properties on (buffer-name). |
d6e1c5f7f468
(Buffer-menu-buffer+size): Don't clobber buffer name.
Andreas Schwab <schwab@suse.de>
parents:
48889
diff
changeset
|
588 (setq name (copy-sequence name))) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
589 (add-text-properties 0 (length name) name-props name) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
590 (add-text-properties 0 (length size) size-props size) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
591 (concat name |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
592 (make-string (- Buffer-menu-buffer+size-width |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
593 (length name) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
594 (length size)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
595 ? ) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
596 size)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
597 |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
598 (defun Buffer-menu-sort (column) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
599 "Sort the buffer menu by COLUMN." |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
600 (interactive "P") |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
601 (when column |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
602 (setq column (prefix-numeric-value column)) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
603 (if (< column 2) (setq column 2)) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
604 (if (> column 5) (setq column 5))) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
605 (setq Buffer-menu-sort-column column) |
57555
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
606 (let (buffer-read-only l buf m1 m2) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
607 (save-excursion |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
608 (Buffer-menu-beginning) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
609 (while (not (eobp)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
610 (when (buffer-live-p (setq buf (get-text-property (+ (point) 4) 'buffer))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
611 (setq m1 (char-after) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
612 m1 (if (memq m1 '(?> ?D)) m1) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
613 m2 (char-after (+ (point) 2)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
614 m2 (if (eq m2 ?S) m2)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
615 (if (or m1 m2) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
616 (push (list buf m1 m2) l))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
617 (forward-line))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
618 (Buffer-menu-revert) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
619 (setq buffer-read-only) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
620 (save-excursion |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
621 (Buffer-menu-beginning) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
622 (while (not (eobp)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
623 (when (setq buf (assq (get-text-property (+ (point) 4) 'buffer) l)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
624 (setq m1 (cadr buf) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
625 m2 (cadr (cdr buf))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
626 (when m1 |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
627 (delete-char 1) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
628 (insert m1) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
629 (backward-char 1)) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
630 (when m2 |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
631 (forward-char 2) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
632 (delete-char 1) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
633 (insert m2))) |
716fe8f547c3
(Buffer-menu-revert-function): Emulate save-excursion.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57030
diff
changeset
|
634 (forward-line))))) |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
635 |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
636 (defun Buffer-menu-make-sort-button (name column) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
637 (if (equal column Buffer-menu-sort-column) (setq column nil)) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
638 (propertize name |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
639 'help-echo (if column |
62703
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
640 (if Buffer-menu-use-header-line |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
641 (concat "mouse-2: sort by " (downcase name)) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
642 (concat "mouse-2, RET: sort by " |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
643 (downcase name))) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
644 (if Buffer-menu-use-header-line |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
645 "mouse-2: sort by visited order" |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
646 "mouse-2, RET: sort by visited order")) |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
647 'mouse-face 'highlight |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
648 'keymap (let ((map (make-sparse-keymap))) |
62703
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
649 (if Buffer-menu-use-header-line |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
650 (define-key map [header-line mouse-2] |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
651 `(lambda (e) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
652 (interactive "e") |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
653 (save-window-excursion |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
654 (if e (mouse-select-window e)) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
655 (Buffer-menu-sort ,column)))) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
656 (define-key map [mouse-2] |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
657 `(lambda (e) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
658 (interactive "e") |
57920
56342493afe3
(Buffer-menu-make-sort-button): Preserve point even when clicking from another window.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57580
diff
changeset
|
659 (if e (mouse-select-window e)) |
62703
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
660 (Buffer-menu-sort ,column))) |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
661 (define-key map "\C-m" |
a078b317d07c
(Buffer-menu-revert-function): Improve handling of point after reverting.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62634
diff
changeset
|
662 `(lambda () (interactive) |
57920
56342493afe3
(Buffer-menu-make-sort-button): Preserve point even when clicking from another window.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
57580
diff
changeset
|
663 (Buffer-menu-sort ,column)))) |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
664 map))) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
665 |
58276
935277968aef
(list-buffers-noselect): New arg BUFFER-LIST.
Richard M. Stallman <rms@gnu.org>
parents:
57920
diff
changeset
|
666 (defun list-buffers-noselect (&optional files-only buffer-list) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
667 "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
|
668 The buffer is named `*Buffer List*'. |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
669 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
|
670 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
|
671 |
58276
935277968aef
(list-buffers-noselect): New arg BUFFER-LIST.
Richard M. Stallman <rms@gnu.org>
parents:
57920
diff
changeset
|
672 If BUFFER-LIST is non-nil, it should be a list of buffers; |
935277968aef
(list-buffers-noselect): New arg BUFFER-LIST.
Richard M. Stallman <rms@gnu.org>
parents:
57920
diff
changeset
|
673 it means list those buffers and no others. |
935277968aef
(list-buffers-noselect): New arg BUFFER-LIST.
Richard M. Stallman <rms@gnu.org>
parents:
57920
diff
changeset
|
674 |
40622
d2bfc00496d7
(buffer-menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
40489
diff
changeset
|
675 For more information, see the function `buffer-menu'." |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
676 (let* ((old-buffer (current-buffer)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
677 (standard-output standard-output) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
678 (mode-end (make-string (- Buffer-menu-mode-width 2) ? )) |
58425
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
679 (header (concat "CRM " |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
680 (Buffer-menu-buffer+size |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
681 (Buffer-menu-make-sort-button "Buffer" 2) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
682 (Buffer-menu-make-sort-button "Size" 3)) |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
683 " " |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
684 (Buffer-menu-make-sort-button "Mode" 4) mode-end |
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
685 (Buffer-menu-make-sort-button "File" 5) "\n")) |
58299
40fc4ca7acc0
(list-buffers-noselect): Massage to fit in 80 columns.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58276
diff
changeset
|
686 list desired-point) |
50172
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
687 (when Buffer-menu-use-header-line |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
688 (let ((pos 0)) |
50172
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
689 ;; Turn spaces in the header into stretch specs so they work |
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
690 ;; regardless of the header-line face. |
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
691 (while (string-match "[ \t]+" header pos) |
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
692 (setq pos (match-end 0)) |
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
693 (put-text-property (match-beginning 0) pos 'display |
58425
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
694 ;; Assume fixed-size chars in the buffer. |
58352
e14d75675a15
(list-buffers-noselect): Eliminate space at the start of HEADER.
Richard M. Stallman <rms@gnu.org>
parents:
58299
diff
changeset
|
695 (list 'space :align-to pos) |
58425
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
696 header))) |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
697 ;; Try to better align the one-char headers. |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
698 (put-text-property 0 3 'face 'fixed-pitch header) |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
699 ;; Add a "dummy" leading space to align the beginning of the header |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
700 ;; line with the beginning of the text (rather than with the left |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
701 ;; scrollbar or the left fringe). –-Stef |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
702 (setq header (concat (propertize " " 'display '(space :align-to 0)) |
58954
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
703 header))) |
54580
f9e5bd96c71c
(Buffer-menu-sort, Buffer-menu-make-sort-button): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
704 (with-current-buffer (get-buffer-create "*Buffer List*") |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
705 (setq buffer-read-only nil) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
706 (erase-buffer) |
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
707 (setq standard-output (current-buffer)) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
708 (unless Buffer-menu-use-header-line |
58425
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
709 (let ((underline (if (char-displayable-p ?—) ?— ?-))) |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
710 (insert header |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
711 (apply 'string |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
712 (mapcar (lambda (c) |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
713 (if (memq c '(?\n ?\ )) c underline)) |
f0b9b97606f9
(list-buffers-noselect): Use fixed-pitch only in the header-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58352
diff
changeset
|
714 header))))) |
58954
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
715 ;; Collect info for every buffer we're interested in. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
716 (dolist (buffer (or buffer-list (buffer-list))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
717 (with-current-buffer buffer |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
718 (let ((name (buffer-name)) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
719 (file buffer-file-name)) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
720 (unless (and (not buffer-list) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
721 (or |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
722 ;; Don't mention internal buffers. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
723 (and (string= (substring name 0 1) " ") (null file)) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
724 ;; Maybe don't mention buffers without files. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
725 (and files-only (not file)) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
726 (string= name "*Buffer List*"))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
727 ;; Otherwise output info. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
728 (let ((mode (concat (format-mode-line mode-name nil nil buffer) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
729 (if mode-line-process |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
730 (format-mode-line mode-line-process |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
731 nil nil buffer)))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
732 (bits (string |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
733 (if (eq buffer old-buffer) ?. ?\ ) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
734 ;; Handle readonly status. The output buffer |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
735 ;; is special cased to appear readonly; it is |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
736 ;; actually made so at a later date. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
737 (if (or (eq buffer standard-output) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
738 buffer-read-only) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
739 ?% ?\ ) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
740 ;; Identify modified buffers. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
741 (if (buffer-modified-p) ?* ?\ ) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
742 ;; Space separator. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
743 ?\ ))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
744 (unless file |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
745 ;; No visited file. Check local value of |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
746 ;; list-buffers-directory. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
747 (when (and (boundp 'list-buffers-directory) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
748 list-buffers-directory) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
749 (setq file list-buffers-directory))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
750 (push (list buffer bits name (buffer-size) mode file) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
751 list)))))) |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
752 ;; Preserve the original buffer-list ordering, just in case. |
bb8424d9ff97
(list-buffers-noselect): Collect internal info
Juri Linkov <juri@jurta.org>
parents:
58461
diff
changeset
|
753 (setq list (nreverse list)) |
58299
40fc4ca7acc0
(list-buffers-noselect): Massage to fit in 80 columns.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58276
diff
changeset
|
754 ;; Place the buffers's info in the output buffer, sorted if necessary. |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
755 (dolist (buffer |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
756 (if Buffer-menu-sort-column |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
757 (sort list |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
758 (if (eq Buffer-menu-sort-column 3) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
759 (lambda (a b) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
760 (< (nth Buffer-menu-sort-column a) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
761 (nth Buffer-menu-sort-column b))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
762 (lambda (a b) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
763 (string< (nth Buffer-menu-sort-column a) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
764 (nth Buffer-menu-sort-column b))))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
765 list)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
766 (if (eq (car buffer) old-buffer) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
767 (setq desired-point (point))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
768 (insert (cadr buffer) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
769 ;; Put the buffer name into a text property |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
770 ;; so we don't have to extract it from the text. |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
771 ;; This way we avoid problems with unusual buffer names. |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
772 (Buffer-menu-buffer+size (nth 2 buffer) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
773 (int-to-string (nth 3 buffer)) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
774 `(buffer-name ,(nth 2 buffer) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
775 buffer ,(car buffer) |
62523
a463c8c59947
(Buffer-menu-buffer-face): In group Buffer-menu.
Richard M. Stallman <rms@gnu.org>
parents:
61382
diff
changeset
|
776 font-lock-face Buffer-menu-buffer-face |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
777 mouse-face highlight |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
778 help-echo "mouse-2: select this buffer")) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
779 " " |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
780 (if (> (length (nth 4 buffer)) Buffer-menu-mode-width) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
781 (substring (nth 4 buffer) 0 Buffer-menu-mode-width) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
782 (nth 4 buffer))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
783 (when (nth 5 buffer) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
784 (indent-to (+ Buffer-menu-buffer-column Buffer-menu-buffer+size-width |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
785 Buffer-menu-mode-width 4) 1) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
786 (princ (abbreviate-file-name (nth 5 buffer)))) |
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
787 (princ "\n")) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
788 (Buffer-menu-mode) |
48864
02944b0aaecd
(Buffer-menu, Buffer-menu-use-header-line, Buffer-menu-buffer-face,
Juanma Barranquero <lekktu@gmail.com>
parents:
40622
diff
changeset
|
789 (when Buffer-menu-use-header-line |
50172
48610ee0507d
(list-buffers-noselect): Use the display property
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50033
diff
changeset
|
790 (setq header-line-format header)) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
791 ;; 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
|
792 ;; current buffer is not displayed for some reason. |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
793 (and desired-point |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
794 (goto-char desired-point)) |
54594
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
795 (setq Buffer-menu-files-only files-only) |
c07fb48cb0e2
(Buffer-menu-revert-function): Make it suitable for
Luc Teirlinck <teirllm@auburn.edu>
parents:
54580
diff
changeset
|
796 (set-buffer-modified-p nil) |
10592
bbb68f0d31c6
(list-buffers-noselect): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10421
diff
changeset
|
797 (current-buffer)))) |
10419
cb6f68d16210
(list-buffers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10269
diff
changeset
|
798 |
58299
40fc4ca7acc0
(list-buffers-noselect): Massage to fit in 80 columns.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58276
diff
changeset
|
799 ;; arch-tag: e7dfcfc9-6cb2-46e4-bf55-8ef1936d83c6 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
800 ;;; buff-menu.el ends here |