;; this depends on the format of list-buffers (from src/buffer.c) and
;; on stuff in lisp/buff-menu.el
-(defvar electric-buffer-menu-mode-map nil)
+(defvar electric-buffer-menu-mode-map
+ (let ((map (make-keymap)))
+ (fillarray (car (cdr map)) 'Electric-buffer-menu-undefined)
+ (define-key map "\e" nil)
+ (define-key map "\C-z" 'suspend-frame)
+ (define-key map "v" 'Electric-buffer-menu-mode-view-buffer)
+ (define-key map (char-to-string help-char) 'Helper-help)
+ (define-key map "?" 'Helper-describe-bindings)
+ (define-key map "\C-c" nil)
+ (define-key map "\C-c\C-c" 'Electric-buffer-menu-quit)
+ (define-key map "\C-]" 'Electric-buffer-menu-quit)
+ (define-key map "q" 'Electric-buffer-menu-quit)
+ (define-key map " " 'Electric-buffer-menu-select)
+ (define-key map "\C-m" 'Electric-buffer-menu-select)
+ (define-key map "\C-l" 'recenter)
+ (define-key map "s" 'Buffer-menu-save)
+ (define-key map "d" 'Buffer-menu-delete)
+ (define-key map "k" 'Buffer-menu-delete)
+ (define-key map "\C-d" 'Buffer-menu-delete-backwards)
+ ;; (define-key map "\C-k" 'Buffer-menu-delete)
+ (define-key map "\177" 'Buffer-menu-backup-unmark)
+ (define-key map "~" 'Buffer-menu-not-modified)
+ (define-key map "u" 'Buffer-menu-unmark)
+ (let ((i ?0))
+ (while (<= i ?9)
+ (define-key map (char-to-string i) 'digit-argument)
+ (define-key map (concat "\e" (char-to-string i)) 'digit-argument)
+ (setq i (1+ i))))
+ (define-key map "-" 'negative-argument)
+ (define-key map "\e-" 'negative-argument)
+ (define-key map "m" 'Buffer-menu-mark)
+ (define-key map "\C-u" 'universal-argument)
+ (define-key map "\C-p" 'previous-line)
+ (define-key map "\C-n" 'next-line)
+ (define-key map "p" 'previous-line)
+ (define-key map "n" 'next-line)
+ (define-key map "\C-v" 'scroll-up)
+ (define-key map "\ev" 'scroll-down)
+ (define-key map ">" 'scroll-right)
+ (define-key map "<" 'scroll-left)
+ (define-key map "\e\C-v" 'scroll-other-window)
+ (define-key map "\e>" 'end-of-buffer)
+ (define-key map "\e<" 'beginning-of-buffer)
+ (define-key map "\e\e" nil)
+ (define-key map "\e\e\e" 'Electric-buffer-menu-quit)
+ ;; This binding prevents the "escape => ESC" function-key-map mapping from
+ ;; kicking in!
+ ;; (define-key map [escape escape escape] 'Electric-buffer-menu-quit)
+ (define-key map [mouse-2] 'Electric-buffer-menu-mouse-select)
+ map))
(defvar electric-buffer-menu-mode-hook nil
"Normal hook run by `electric-buffer-list'.")
;; generally the same as Buffer-menu-mode-map
;; (except we don't indirect to global-map)
(put 'Electric-buffer-menu-undefined 'suppress-keymap t)
-(if electric-buffer-menu-mode-map
- nil
- (let ((map (make-keymap)))
- (fillarray (car (cdr map)) 'Electric-buffer-menu-undefined)
- (define-key map "\e" nil)
- (define-key map "\C-z" 'suspend-frame)
- (define-key map "v" 'Electric-buffer-menu-mode-view-buffer)
- (define-key map (char-to-string help-char) 'Helper-help)
- (define-key map "?" 'Helper-describe-bindings)
- (define-key map "\C-c" nil)
- (define-key map "\C-c\C-c" 'Electric-buffer-menu-quit)
- (define-key map "\C-]" 'Electric-buffer-menu-quit)
- (define-key map "q" 'Electric-buffer-menu-quit)
- (define-key map " " 'Electric-buffer-menu-select)
- (define-key map "\C-m" 'Electric-buffer-menu-select)
- (define-key map "\C-l" 'recenter)
- (define-key map "s" 'Buffer-menu-save)
- (define-key map "d" 'Buffer-menu-delete)
- (define-key map "k" 'Buffer-menu-delete)
- (define-key map "\C-d" 'Buffer-menu-delete-backwards)
- ;(define-key map "\C-k" 'Buffer-menu-delete)
- (define-key map "\177" 'Buffer-menu-backup-unmark)
- (define-key map "~" 'Buffer-menu-not-modified)
- (define-key map "u" 'Buffer-menu-unmark)
- (let ((i ?0))
- (while (<= i ?9)
- (define-key map (char-to-string i) 'digit-argument)
- (define-key map (concat "\e" (char-to-string i)) 'digit-argument)
- (setq i (1+ i))))
- (define-key map "-" 'negative-argument)
- (define-key map "\e-" 'negative-argument)
- (define-key map "m" 'Buffer-menu-mark)
- (define-key map "\C-u" 'universal-argument)
- (define-key map "\C-p" 'previous-line)
- (define-key map "\C-n" 'next-line)
- (define-key map "p" 'previous-line)
- (define-key map "n" 'next-line)
- (define-key map "\C-v" 'scroll-up)
- (define-key map "\ev" 'scroll-down)
- (define-key map ">" 'scroll-right)
- (define-key map "<" 'scroll-left)
- (define-key map "\e\C-v" 'scroll-other-window)
- (define-key map "\e>" 'end-of-buffer)
- (define-key map "\e<" 'beginning-of-buffer)
- (define-key map "\e\e" nil)
- (define-key map "\e\e\e" 'Electric-buffer-menu-quit)
- (define-key map [escape escape escape] 'Electric-buffer-menu-quit)
- (define-key map [mouse-2] 'Electric-buffer-menu-mouse-select)
- (setq electric-buffer-menu-mode-map map)))
+
(defun Electric-buffer-menu-exit ()
(interactive)