*** The tab bar now supports more mouse commands.
Clicking 'mouse-2' closes the tab, 'mouse-3' displays the context menu
-with items that operate on the clicked tab.
+with items that operate on the clicked tab. Dragging the tab with
+'mouse-1' moves it to another position on the tab bar.
*** The key prefix 'C-x t t' displays next command buffer in a new tab.
It's bound to the command 'other-tab-prefix' that requests the buffer
(popup-menu menu event)))
+(defun tab-bar-mouse-move-tab (event)
+ (interactive "e")
+ (let* ((caption (car (posn-string (event-start event))))
+ (item (and caption (get-text-property 0 'menu-item caption)))
+ (from (tab--key-to-number (nth 0 item)))
+ (caption (car (posn-string (event-end event))))
+ (item (and caption (get-text-property 0 'menu-item caption)))
+ (to (tab--key-to-number (nth 0 item))))
+ (tab-bar-move-tab-to to from)))
+
(defun toggle-tab-bar-mode-from-frame (&optional arg)
"Toggle tab bar on or off, based on the status of the current frame.
Used in the Show/Hide menu, to have the toggle reflect the current frame.
(defvar tab-bar-map
(let ((map (make-sparse-keymap)))
(define-key map [down-mouse-1] 'tab-bar-mouse-select-tab)
+ (define-key map [drag-mouse-1] 'tab-bar-mouse-move-tab)
(define-key map [mouse-1] 'ignore)
(define-key map [down-mouse-2] 'tab-bar-mouse-close-tab)
(define-key map [mouse-2] 'ignore)
(let ((key (event-basic-type last-command-event)))
(setq arg (if (and (characterp key) (>= key ?1) (<= key ?9))
(- key ?0)
- 1))))
+ 0))))
(let* ((tabs (funcall tab-bar-tabs-function))
(from-index (tab-bar--current-tab-index tabs))
- (to-index (if (< arg 0) (+ (length tabs) (1+ arg)) arg))
+ (to-index (cond ((< arg 0) (+ (length tabs) (1+ arg)))
+ ((zerop arg) (1+ from-index))
+ (t arg)))
(to-index (1- (max 1 (min to-index (length tabs))))))
(unless (eq from-index to-index)
frame_to_window_pixel_xy (w, &x, &y);
ts = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p);
- if (ts == -1
- /* If the button is released on a tab other than the one where
- it was pressed, don't generate the tab-bar button click event. */
- || (ts != 0 && !down_p))
+ if (ts == -1)
return Qnil;
/* If item is disabled, do nothing. */