Function: mouse-select-buffer
mouse-select-buffer is a byte-compiled function defined in msb.el.gz.
Signature
(mouse-select-buffer EVENT)
Documentation
Pop up several menus of buffers, for selection with the mouse.
Returns the selected buffer or nil if no buffer is selected.
The way the buffers are split is conveniently handled with the
variable msb-menu-cond.
Source Code
;; Defined in /usr/src/emacs/lisp/msb.el.gz
(defun mouse-select-buffer (event)
"Pop up several menus of buffers, for selection with the mouse.
Returns the selected buffer or nil if no buffer is selected.
The way the buffers are split is conveniently handled with the
variable `msb-menu-cond'."
;; Popup the menu and return the selected buffer.
(when (or msb--error
(not msb--last-buffer-menu)
(not (fboundp 'frame-or-buffer-changed-p))
(frame-or-buffer-changed-p))
(setq msb--error nil)
(setq msb--last-buffer-menu (msb--create-buffer-menu)))
(let ((position event)
choice)
(when (and (fboundp 'posn-x-y)
(fboundp 'posn-window))
(let ((posX (car (posn-x-y (event-start event))))
(posY (cdr (posn-x-y (event-start event))))
(posWind (posn-window (event-start event))))
;; adjust position
(setq posX (- posX (funcall msb-horizontal-shift-function))
position (list (list posX posY) posWind))))
;; Popup the menu
(setq choice (x-popup-menu position msb--last-buffer-menu))
(cond
((eq (car choice) 'toggle)
;; Bring up the menu again with type toggled.
(msb--toggle-menu-type)
(mouse-select-buffer event))
((and (numberp (car choice))
(null (cdr choice)))
(let ((msb--last-buffer-menu (nthcdr 2 (assq (car choice)
msb--last-buffer-menu))))
(mouse-select-buffer event)))
((while (numberp (car choice))
(setq choice (cdr choice))))
((and (stringp (car choice))
(null (cdr choice)))
(car choice))
((null choice)
choice)
(t
(error "Unknown form for buffer: %s" choice)))))