Mercurial > emacs
view lisp/buff-menu.el @ 1721:6ba3bca4c3de
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
* xterm.h (struct x_display): Delete v_scrollbar, v_thumbup,
v_thumbdown, v_slider, h_scrollbar, h_thumbup,
h_thumbdown, h_slider, v_scrollbar_width, h_scrollbar_height
fields.
* keyboard.c (Qvscrollbar_part, Qvslider_part, Qvthumbup_part,
Qvthumbdown_part, Qhscrollbar_part, Qhslider_part, Qhthumbup_part,
Qhthumbdown_part, Qscrollbar_click): Deleted; part of an obsolete
interface.
(head_table): Removed from here as well.
(syms_of_keyboard): And here.
* keyboard.h: And here.
(POSN_SCROLLBAR_BUTTON): Removed.
* xscrollbar.h: File removed - no longer necessary.
* xfns.c: Don't #include it any more.
(Qhorizontal_scroll_bar, Qvertical_scroll_bar): Deleted.
(syms_of_xfns): Don't initialize or staticpro them.
(gray_bits): Salvaged from xscrollbar.h.
(x_window_to_scrollbar): Deleted.
(x_set_horizontal_scrollbar): Deleted.
(enum x_frame_parm, x_frame_parms): Remove references to
x_set_horizontal_scrollbar.
(x_set_foreground_color, x_set_background_color,
x_set_border_pixel): Remove special code to support scrollbars.
(Fx_create_frame): Remove old scrollbar setup code.
(install_vertical_scrollbar, install_horizontal_scrollbar,
adjust_scrollbars, x_resize_scrollbars): Deleted.
* xterm.c (construct_mouse_click): This doesn't need to take care of
scrollbar clicks anymore.
(XTread_socket): Remove old code to support scrollbars. Call new
functions instead for events which occur in scrollbar windows.
(XTupdate_end): Remove call to adjust_scrollbars; the main
redisplay code takes care of that now.
(enum window_type): Deleted.
* ymakefile: Note that xfns.o no longer depends on xscrollbar.h.
* xterm.h (PIXEL_WIDTH, PIXEL_HEIGHT): Change name of parameter
from `s' to `f'; it's a frame pointer.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 24 Dec 1992 06:23:08 +0000 |
parents | 213978acbc1e |
children | 10e417efb12a |
line wrap: on
line source
;;; buff-menu.el --- buffer menu main function and support functions. ;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. ;; Maintainer: FSF ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Code: ; Put buffer *Buffer List* into proper mode right away ; so that from now on even list-buffers is enough to get a buffer menu. (defvar Buffer-menu-mode-map nil "") (if Buffer-menu-mode-map () (setq Buffer-menu-mode-map (make-keymap)) (suppress-keymap Buffer-menu-mode-map t) (define-key Buffer-menu-mode-map "q" 'Buffer-menu-select) (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) (define-key Buffer-menu-mode-map " " 'next-line) (define-key Buffer-menu-mode-map "n" 'next-line) (define-key Buffer-menu-mode-map "p" 'previous-line) (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) (define-key Buffer-menu-mode-map "?" 'describe-mode) (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark) (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table)) ;; Buffer Menu mode is suitable only for specially formatted data. (put 'Buffer-menu-mode 'mode-class 'special) (defun Buffer-menu-mode () "Major mode for editing a list of buffers. Each line describes one of the buffers in Emacs. Letters do not insert themselves; instead, they are commands. \\<Buffer-menu-mode-map> \\[Buffer-menu-mark] -- mark buffer to be displayed. \\[Buffer-menu-select] -- select buffer of line point is on. Also show buffers marked with m in other windows. \\[Buffer-menu-1-window] -- select that buffer in full-frame window. \\[Buffer-menu-2-window] -- select that buffer in one window, together with buffer selected before this one in another window. \\[Buffer-menu-this-window] -- select that buffer in place of the buffer menu buffer. \\[Buffer-menu-other-window] -- select that buffer in another window, so the buffer menu buffer remains visible in its window. \\[Buffer-menu-switch-other-window] -- switch the other window to this buffer. \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer. \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. \\[Buffer-menu-save] -- mark that buffer to be saved, and move down. \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down. \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up. \\[Buffer-menu-execute] -- delete or save marked buffers. \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. \\[Buffer-menu-backup-unmark] -- back up a line and remove marks." (kill-all-local-variables) (use-local-map Buffer-menu-mode-map) (setq truncate-lines t) (setq buffer-read-only t) (setq major-mode 'Buffer-menu-mode) (setq mode-name "Buffer Menu") (run-hooks 'buffer-menu-mode-hook)) (defvar Buffer-menu-buffer-column 4) (defun Buffer-menu-buffer (error-if-non-existent-p) "Return buffer described by this line of buffer menu." (save-excursion (beginning-of-line) (forward-char Buffer-menu-buffer-column) (let ((start (point)) string) ;; End of buffer name marked by tab or two spaces. (re-search-forward "\t\\| ") (skip-chars-backward " \t") (setq string (buffer-substring start (point))) (or (get-buffer string) (if error-if-non-existent-p (error "No buffer named \"%s\"" string) nil))))) (defun buffer-menu (&optional arg) "Make a menu of buffers so you can save, delete or select them. With argument, show only buffers that are visiting files. Type ? after invocation to get help on commands available. Type q immediately to make the buffer menu go away." (interactive "P") (list-buffers arg) (pop-to-buffer "*Buffer List*") (forward-line 2) (message "Commands: d, s, x; 1, 2, m, u, q; delete; ~; ? for help.")) (defun Buffer-menu-mark () "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." (interactive) (beginning-of-line) (if (looking-at " [-M]") (ding) (let ((buffer-read-only nil)) (delete-char 1) (insert ?>) (forward-line 1)))) (defun Buffer-menu-unmark () "Cancel all requested operations on buffer on this line." (interactive) (beginning-of-line) (if (looking-at " [-M]") (ding) (let* ((buf (Buffer-menu-buffer t)) (mod (buffer-modified-p buf)) (readonly (save-excursion (set-buffer buf) buffer-read-only)) (buffer-read-only nil)) (delete-char 3) (insert (if readonly (if mod " *%" " %") (if mod " * " " "))))) (forward-line 1)) (defun Buffer-menu-backup-unmark () "Move up and cancel all requested operations on buffer on line above." (interactive) (forward-line -1) (Buffer-menu-unmark) (forward-line -1)) (defun Buffer-menu-delete () "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." (interactive) (beginning-of-line) (if (looking-at " [-M]") ;header lines (ding) (let ((buffer-read-only nil)) (delete-char 1) (insert ?D) (forward-line 1)))) (defun Buffer-menu-delete-backwards () "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command and then move up one line" (interactive) (Buffer-menu-delete) (forward-line -2) (if (looking-at " [-M]") (forward-line 1))) (defun Buffer-menu-save () "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." (interactive) (beginning-of-line) (forward-char 1) (if (looking-at " [-M]") ;header lines (ding) (let ((buffer-read-only nil)) (delete-char 1) (insert ?S) (forward-line 1)))) (defun Buffer-menu-not-modified () "Mark buffer on this line as unmodified (no changes to save)." (interactive) (save-excursion (set-buffer (Buffer-menu-buffer t)) (set-buffer-modified-p nil)) (save-excursion (beginning-of-line) (forward-char 1) (if (looking-at "\\*") (let ((buffer-read-only nil)) (delete-char 1) (insert ? ))))) (defun Buffer-menu-execute () "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." (interactive) (save-excursion (goto-char (point-min)) (forward-line 1) (while (re-search-forward "^.S" nil t) (let ((modp nil)) (save-excursion (set-buffer (Buffer-menu-buffer t)) (save-buffer) (setq modp (buffer-modified-p))) (let ((buffer-read-only nil)) (delete-char -1) (insert (if modp ?* ? )))))) (save-excursion (goto-char (point-min)) (forward-line 1) (let ((buff-menu-buffer (current-buffer)) (buffer-read-only nil)) (while (search-forward "\nD" nil t) (forward-char -1) (let ((buf (Buffer-menu-buffer nil))) (or (eq buf nil) (eq buf buff-menu-buffer) (save-excursion (kill-buffer buf)))) (if (Buffer-menu-buffer nil) (progn (delete-char 1) (insert ? )) (delete-region (point) (progn (forward-line 1) (point))) (forward-char -1)))))) (defun Buffer-menu-select () "Select this line's buffer; also display buffers marked with `>'. You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command." (interactive) (let ((buff (Buffer-menu-buffer t)) (menu (current-buffer)) (others ()) tem) (goto-char (point-min)) (while (search-forward "\n>" nil t) (setq tem (Buffer-menu-buffer t)) (let ((buffer-read-only nil)) (delete-char -1) (insert ?\ )) (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) (setq others (nreverse others) tem (/ (1- (frame-height)) (1+ (length others)))) (delete-other-windows) (switch-to-buffer buff) (or (eq menu buff) (bury-buffer menu)) (while others (split-window nil tem) (other-window 1) (switch-to-buffer (car others)) (setq others (cdr others))) (other-window 1))) ;back to the beginning! (defun Buffer-menu-visit-tags-table () "Visit the tags table in the buffer on this line. See `visit-tags-table'." (interactive) (let ((file (buffer-file-name (Buffer-menu-buffer t)))) (if file (visit-tags-table file) (error "Specified buffer has no file")))) (defun Buffer-menu-1-window () "Select this line's buffer, alone, in full frame." (interactive) (switch-to-buffer (Buffer-menu-buffer t)) (bury-buffer (other-buffer)) (delete-other-windows)) (defun Buffer-menu-this-window () "Select this line's buffer in this window." (interactive) (switch-to-buffer (Buffer-menu-buffer t))) (defun Buffer-menu-other-window () "Select this line's buffer in other window, leaving buffer menu visible." (interactive) (switch-to-buffer-other-window (Buffer-menu-buffer t))) (defun Buffer-menu-switch-other-window () "Make the other window select this line's buffer. The current window remains selected." (interactive) (display-buffer (Buffer-menu-buffer t))) (defun Buffer-menu-2-window () "Select this line's buffer, with previous buffer in second window." (interactive) (let ((buff (Buffer-menu-buffer t)) (menu (current-buffer)) (pop-up-windows t)) (switch-to-buffer (other-buffer)) (pop-to-buffer buff) (bury-buffer menu))) ;;; buff-menu.el ends here