Function: tab-bar--event-to-item

tab-bar--event-to-item is a byte-compiled function defined in tab-bar.el.gz.

Signature

(tab-bar--event-to-item POSN)

Documentation

Extract extra info from the mouse event at position POSN.

It returns a list of the form (KEY KEY-BINDING CLOSE-P), where:
 KEY is a symbol representing a tab, such as 'tab-1 or 'current-tab;
 KEY-BINDING is the binding of KEY;
 CLOSE-P is non-nil if the mouse event was a click on the close button "x",
   nil otherwise.

Source Code

;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar--event-to-item (posn)
  "Extract extra info from the mouse event at position POSN.
It returns a list of the form (KEY KEY-BINDING CLOSE-P), where:
 KEY is a symbol representing a tab, such as \\='tab-1 or \\='current-tab;
 KEY-BINDING is the binding of KEY;
 CLOSE-P is non-nil if the mouse event was a click on the close button \"x\",
   nil otherwise."
  (setq tab-bar--dragging-in-progress nil)
  (if (posn-window posn)
      (let* ((caption (car (posn-string posn)))
             (menu-item (when caption
                          (get-text-property 0 'menu-item caption))))
        (when (equal menu-item '(global ignore nil))
          (setf (nth 1 menu-item)
                (key-binding (vector 'tab-bar last-nonmenu-event) t)))
        menu-item)
    ;; Text-mode emulation of switching tabs on the tab bar.
    ;; This code is used when you click the mouse in the tab bar
    ;; on a console which has no window system but does have a mouse.
    (let* ((x-position (car (posn-x-y posn)))
           (keymap (lookup-key (cons 'keymap (nreverse (current-active-maps)))
                               [tab-bar]))
           (column 0))
      (when x-position
        (catch 'done
          (map-keymap
           (lambda (key binding)
             (when (eq (car-safe binding) 'menu-item)
               (when (> (+ column (length (nth 1 binding))) x-position)
                 (throw 'done (list key (nth 2 binding)
                                    (get-text-property
                                     (- x-position column)
                                     'close-tab (nth 1 binding)))))
               (setq column (+ column (length (nth 1 binding))))))
           keymap))))))