\f
(defvar tab-line-tab-map
(let ((map (make-sparse-keymap)))
- (define-key map [tab-line mouse-1] 'tab-line-select-tab)
+ (define-key map [tab-line down-mouse-1] 'tab-line-select-tab)
(define-key map [tab-line mouse-2] 'tab-line-close-tab)
+ (define-key map [tab-line down-mouse-3] 'tab-line-tab-context-menu)
(define-key map "\C-m" 'tab-line-select-tab)
map)
"Local keymap for `tab-line-mode' window tabs.")
(defvar tab-line-add-map
(let ((map (make-sparse-keymap)))
- (define-key map [tab-line mouse-1] 'tab-line-new-tab)
- (define-key map [tab-line mouse-2] 'tab-line-new-tab)
+ (define-key map [tab-line down-mouse-1] 'tab-line-new-tab)
+ (define-key map [tab-line down-mouse-2] 'tab-line-new-tab)
(define-key map "\C-m" 'tab-line-new-tab)
map)
"Local keymap to add `tab-line-mode' window tabs.")
(defvar tab-line-left-map
(let ((map (make-sparse-keymap)))
- (define-key map [tab-line mouse-1] 'tab-line-hscroll-left)
- (define-key map [tab-line mouse-2] 'tab-line-hscroll-left)
+ (define-key map [tab-line down-mouse-1] 'tab-line-hscroll-left)
+ (define-key map [tab-line down-mouse-2] 'tab-line-hscroll-left)
(define-key map "\C-m" 'tab-line-new-tab)
map)
"Local keymap to scroll `tab-line-mode' window tabs to the left.")
(defvar tab-line-right-map
(let ((map (make-sparse-keymap)))
- (define-key map [tab-line mouse-1] 'tab-line-hscroll-right)
- (define-key map [tab-line mouse-2] 'tab-line-hscroll-right)
+ (define-key map [tab-line down-mouse-1] 'tab-line-hscroll-right)
+ (define-key map [tab-line down-mouse-2] 'tab-line-hscroll-right)
(define-key map "\C-m" 'tab-line-new-tab)
map)
"Local keymap to scroll `tab-line-mode' window tabs to the right.")
(when window
(force-mode-line-update t))))
-(defun tab-line-hscroll-right (&optional arg mouse-event)
+(defun tab-line-hscroll-right (&optional arg event)
(interactive (list current-prefix-arg last-nonmenu-event))
- (let ((window (and (listp mouse-event) (posn-window (event-start mouse-event)))))
+ (let ((window (and (listp event) (posn-window (event-start event)))))
(tab-line-hscroll arg window)
(force-mode-line-update window)))
-(defun tab-line-hscroll-left (&optional arg mouse-event)
+(defun tab-line-hscroll-left (&optional arg event)
(interactive (list current-prefix-arg last-nonmenu-event))
- (let ((window (and (listp mouse-event) (posn-window (event-start mouse-event)))))
+ (let ((window (and (listp event) (posn-window (event-start event)))))
(tab-line-hscroll (- (or arg 1)) window)
(force-mode-line-update window)))
\f
-(defun tab-line-new-tab (&optional mouse-event)
+(defun tab-line-new-tab (&optional event)
"Add a new tab to the tab line.
Usually is invoked by clicking on the plus-shaped button.
But any switching to other buffer also adds a new tab
(if (functionp tab-line-new-tab-choice)
(funcall tab-line-new-tab-choice)
(let ((tab-line-tabs-buffer-groups mouse-buffer-menu-mode-groups))
- (if (and (listp mouse-event)
+ (if (and (listp event)
(display-popup-menus-p)
(not tty-menu-open-use-tmm))
- (mouse-buffer-menu mouse-event) ; like (buffer-menu-open)
+ (mouse-buffer-menu event) ; like (buffer-menu-open)
;; tty menu doesn't support mouse clicks, so use tmm
(tmm-prompt (mouse-buffer-menu-keymap))))))
-(defun tab-line-select-tab (&optional e)
+(defun tab-line-select-tab (&optional event)
"Switch to the selected tab.
This command maintains the original order of prev/next buffers.
So for example, switching to a previous tab is equivalent to
using the `previous-buffer' command."
(interactive "e")
- (let* ((posnp (event-start e))
+ (let* ((posnp (event-start event))
(tab (get-pos-property 1 'tab (car (posn-string posnp))))
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
(if buffer
:group 'tab-line
:version "28.1")
-(defun tab-line-switch-to-prev-tab (&optional mouse-event)
+(defun tab-line-switch-to-prev-tab (&optional event)
"Switch to the previous tab.
Its effect is the same as using the `previous-buffer' command
(\\[previous-buffer])."
(interactive (list last-nonmenu-event))
- (let ((window (and (listp mouse-event) (posn-window (event-start mouse-event)))))
+ (let ((window (and (listp event) (posn-window (event-start event)))))
(if (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
(switch-to-prev-buffer window)
(with-selected-window (or window (selected-window))
(when (bufferp buffer)
(switch-to-buffer buffer)))))))
-(defun tab-line-switch-to-next-tab (&optional mouse-event)
+(defun tab-line-switch-to-next-tab (&optional event)
"Switch to the next tab.
Its effect is the same as using the `next-buffer' command
(\\[next-buffer])."
(interactive (list last-nonmenu-event))
- (let ((window (and (listp mouse-event) (posn-window (event-start mouse-event)))))
+ (let ((window (and (listp event) (posn-window (event-start event)))))
(if (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
(switch-to-next-buffer window)
(with-selected-window (or window (selected-window))
:group 'tab-line
:version "27.1")
-(defun tab-line-close-tab (&optional mouse-event)
+(defun tab-line-close-tab (&optional event)
"Close the selected tab.
Usually is invoked by clicking on the close button on the right side
of the tab. This command buries the buffer, so it goes out of sight
from the tab line."
(interactive (list last-nonmenu-event))
- (let* ((posnp (and (listp mouse-event) (event-start mouse-event)))
+ (let* ((posnp (and (listp event) (event-start event)))
(window (and posnp (posn-window posnp)))
(tab (get-pos-property 1 'tab (car (posn-string posnp))))
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
(funcall tab-line-close-tab-function tab)))
(force-mode-line-update))))
+(defun tab-line-tab-context-menu (&optional event)
+ "Pop up context menu for the tab."
+ (interactive "e")
+ (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))))
+ (define-key-after menu [close]
+ '(menu-item "Close" tab-line-close-tab :help "Close the tab"))
+ (popup-menu menu event)))
+
+(defun tab-line-context-menu (&optional event)
+ "Pop up context menu for the tab line."
+ (interactive "e")
+ (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))))
+ (define-key-after menu [close]
+ '(menu-item "New tab" tab-line-new-tab :help "Create a new tab"))
+ (popup-menu menu event)))
+
\f
;;;###autoload
(define-minor-mode tab-line-mode
:version "27.1")
\f
+(global-set-key [tab-line down-mouse-3] 'tab-line-context-menu)
+
(global-set-key [tab-line mouse-4] 'tab-line-hscroll-left)
(global-set-key [tab-line mouse-5] 'tab-line-hscroll-right)
(global-set-key [tab-line wheel-up] 'tab-line-hscroll-left)