Mercurial > emacs
comparison lisp/buff-menu.el @ 10592:bbb68f0d31c6
(list-buffers-noselect): New subroutine.
(list-buffers): Use that.
(buffer-menu): Switch to the buffer in the same window.
(buffer-menu-other-window): New command.
(Buffer-menu-select): Just change the current window.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 30 Jan 1995 01:11:10 +0000 |
parents | 4252d6935d43 |
children | 7ae93c2ee7a2 |
comparison
equal
deleted
inserted
replaced
10591:5a049637599a | 10592:bbb68f0d31c6 |
---|---|
39 ;; | 39 ;; |
40 ;; Based on FSF code dating back to 1985. | 40 ;; Based on FSF code dating back to 1985. |
41 | 41 |
42 ;;; Code: | 42 ;;; Code: |
43 | 43 |
44 ;;;Not needed, now that q is now just quit and Buffer-menu-select is v. | 44 ;;;Trying to preserve the old window configuration works well in |
45 ;;;simple scenarios, when you enter the buffer menu, use it, and exit it. | |
46 ;;;But it does strange things when you switch back to the buffer list buffer | |
47 ;;;with C-x b, later on, when the window configuration is different. | |
48 ;;;The choice seems to be, either restore the window configuration | |
49 ;;;in all cases, or in no cases. | |
50 ;;;I decided it was better not to restore the window config at all. -- rms. | |
51 | |
52 ;;;But since then, I changed buffer-menu to use the selected window, | |
53 ;;;so q now once again goes back to the previous window configuration. | |
54 | |
45 ;;;(defvar Buffer-menu-window-config nil | 55 ;;;(defvar Buffer-menu-window-config nil |
46 ;;; "Window configuration saved from entry to `buffer-menu'.") | 56 ;;; "Window configuration saved from entry to `buffer-menu'.") |
47 | 57 |
48 ; Put buffer *Buffer List* into proper mode right away | 58 ; Put buffer *Buffer List* into proper mode right away |
49 ; so that from now on even list-buffers is enough to get a buffer menu. | 59 ; so that from now on even list-buffers is enough to get a buffer menu. |
159 | 169 |
160 (defun buffer-menu (&optional arg) | 170 (defun buffer-menu (&optional arg) |
161 "Make a menu of buffers so you can save, delete or select them. | 171 "Make a menu of buffers so you can save, delete or select them. |
162 With argument, show only buffers that are visiting files. | 172 With argument, show only buffers that are visiting files. |
163 Type ? after invocation to get help on commands available. | 173 Type ? after invocation to get help on commands available. |
164 Type q immediately to make the buffer menu go away and to restore | 174 Type q immediately to make the buffer menu go away." |
165 previous window configuration." | |
166 (interactive "P") | 175 (interactive "P") |
167 ;;; (setq Buffer-menu-window-config (current-window-configuration)) | 176 ;;; (setq Buffer-menu-window-config (current-window-configuration)) |
168 (list-buffers arg) | 177 (switch-to-buffer (list-buffers-noselect arg)) |
169 (let ((newpoint (save-excursion (set-buffer "*Buffer List*") | |
170 (point)))) | |
171 (pop-to-buffer "*Buffer List*") | |
172 (goto-char newpoint)) | |
173 (message | 178 (message |
174 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) | 179 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) |
175 | 180 |
181 (defun buffer-menu-other-window (&optional arg) | |
182 "Display a list of buffers in another window. | |
183 With the buffer list buffer, you can save, delete or select the buffers. | |
184 With argument, show only buffers that are visiting files. | |
185 Type ? after invocation to get help on commands available. | |
186 Type q immediately to make the buffer menu go away." | |
187 (interactive "P") | |
188 ;;; (setq Buffer-menu-window-config (current-window-configuration)) | |
189 (switch-to-buffer-other-window (list-buffers-noselect arg)) | |
190 (message | |
191 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) | |
192 | |
176 (defun Buffer-menu-quit () | 193 (defun Buffer-menu-quit () |
177 "Quit the buffer menu." | 194 "Quit the buffer menu." |
178 (interactive) | 195 (interactive) |
179 (let ((buffer (current-buffer))) | 196 (let ((buffer (current-buffer))) |
180 ;; Restore previous window configuration before displaying | 197 ;; Switch away from the buffer menu and bury it. |
181 ;; selected buffers. | |
182 (switch-to-buffer (other-buffer)) | 198 (switch-to-buffer (other-buffer)) |
183 (bury-buffer buffer))) | 199 (bury-buffer buffer))) |
184 | 200 |
185 (defun Buffer-menu-mark () | 201 (defun Buffer-menu-mark () |
186 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | 202 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." |
303 (delete-region (point) (progn (forward-line 1) (point))) | 319 (delete-region (point) (progn (forward-line 1) (point))) |
304 (forward-char -1)))))) | 320 (forward-char -1)))))) |
305 | 321 |
306 (defun Buffer-menu-select () | 322 (defun Buffer-menu-select () |
307 "Select this line's buffer; also display buffers marked with `>'. | 323 "Select this line's buffer; also display buffers marked with `>'. |
308 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command." | 324 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command. |
325 This command deletes and replaces all the previously existing windows | |
326 in the selected frame." | |
309 (interactive) | 327 (interactive) |
310 (let ((buff (Buffer-menu-buffer t)) | 328 (let ((buff (Buffer-menu-buffer t)) |
311 (menu (current-buffer)) | 329 (menu (current-buffer)) |
312 (others ()) | 330 (others ()) |
313 tem) | 331 tem) |
339 (switch-to-buffer (car others)) | 357 (switch-to-buffer (car others)) |
340 (setq others (cdr others))) | 358 (setq others (cdr others))) |
341 (other-window 1) ;back to the beginning! | 359 (other-window 1) ;back to the beginning! |
342 ))) | 360 ))) |
343 | 361 |
362 | |
344 | 363 |
345 (defun Buffer-menu-visit-tags-table () | 364 (defun Buffer-menu-visit-tags-table () |
346 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | 365 "Visit the tags table in the buffer on this line. See `visit-tags-table'." |
347 (interactive) | 366 (interactive) |
348 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | 367 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) |
426 Non-null optional arg FILES-ONLY means mention only file buffers. | 445 Non-null optional arg FILES-ONLY means mention only file buffers. |
427 | 446 |
428 The M column contains a * for buffers that are modified. | 447 The M column contains a * for buffers that are modified. |
429 The R column contains a % for buffers that are read-only." | 448 The R column contains a % for buffers that are read-only." |
430 (interactive "P") | 449 (interactive "P") |
450 (display-buffer (list-buffers-noselect files-only))) | |
451 | |
452 (defun list-buffers-noselect (&optional files-only) | |
453 "Create and return a buffer with a list of names of existing buffers. | |
454 The buffer is named `*Buffer List*'. | |
455 Note that buffers with names starting with spaces are omitted. | |
456 Non-null optional arg FILES-ONLY means mention only file buffers. | |
457 | |
458 The M column contains a * for buffers that are modified. | |
459 The R column contains a % for buffers that are read-only." | |
431 (let ((old-buffer (current-buffer)) | 460 (let ((old-buffer (current-buffer)) |
432 (blist-buffer (get-buffer-create "*Buffer List*")) | 461 (standard-output standard-output) |
433 (desired-point nil)) | 462 desired-point) |
434 (with-output-to-temp-buffer "*Buffer List*" | 463 (save-excursion |
435 (set-buffer standard-output) | 464 (set-buffer (get-buffer-create "*Buffer List*")) |
465 (setq buffer-read-only nil) | |
466 (erase-buffer) | |
467 (setq standard-output (current-buffer)) | |
436 (princ "\ | 468 (princ "\ |
437 MR Buffer Size Mode File | 469 MR Buffer Size Mode File |
438 -- ------ ---- ---- ---- | 470 -- ------ ---- ---- ---- |
439 ") | 471 ") |
440 (let ((bl (buffer-list))) | 472 (let ((bl (buffer-list))) |
494 list-buffers-directory) | 526 list-buffers-directory) |
495 (setq file list-buffers-directory)))) | 527 (setq file list-buffers-directory)))) |
496 (if file | 528 (if file |
497 (princ file)) | 529 (princ file)) |
498 (princ "\n")))) | 530 (princ "\n")))) |
499 (setq bl (cdr bl))))) | 531 (setq bl (cdr bl)))) |
500 ;; DESIRED-POINT doesn't have to be set; it is not when the | |
501 ;; current buffer is not displayed for some reason. | |
502 (save-excursion | |
503 (set-buffer blist-buffer) | |
504 (Buffer-menu-mode) | 532 (Buffer-menu-mode) |
533 ;; DESIRED-POINT doesn't have to be set; it is not when the | |
534 ;; current buffer is not displayed for some reason. | |
505 (and desired-point | 535 (and desired-point |
506 (goto-char desired-point))))) | 536 (goto-char desired-point)) |
537 (current-buffer)))) | |
507 | 538 |
508 ;;; buff-menu.el ends here | 539 ;;; buff-menu.el ends here |