aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-10-21 01:37:39 +0300
committerJuri Linkov2019-10-21 01:37:39 +0300
commit30deac84c4168a6315a08a0dd85f6dde9b9df439 (patch)
treec003db9aaee2310e3b74301149f5c0a5b8551fd3
parent0e6f4628d8fff53505e4399e71da9f531a64fff7 (diff)
downloademacs-30deac84c4168a6315a08a0dd85f6dde9b9df439.tar.gz
emacs-30deac84c4168a6315a08a0dd85f6dde9b9df439.zip
* lisp/tab-line.el: Bind mouse commands to [tab-line].
* lisp/tab-line.el: Bind mouse-4/mouse-5, wheel-up/wheel-down globally to [tab-line]. (tab-line-tab-map): Remove local bindings of mouse-4/mouse-5. (tab-line-new-tab, tab-line-switch-to-prev-tab) (tab-line-switch-to-next-tab, tab-line-close-tab): Turn commands into mouse-free (can be used without mouse).
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/tab-line.el43
2 files changed, 26 insertions, 19 deletions
diff --git a/etc/NEWS b/etc/NEWS
index d9a9fd82a61..d0e369e0f72 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2184,7 +2184,7 @@ the previous window-local tab is the same as typing 'C-x <LEFT>'
2184('next-buffer'). Both commands support a numeric prefix argument as 2184('next-buffer'). Both commands support a numeric prefix argument as
2185a repeat count. Clicking on the plus icon adds a new buffer to the 2185a repeat count. Clicking on the plus icon adds a new buffer to the
2186window-local tab line of buffers. Using the mouse wheel on the tab 2186window-local tab line of buffers. Using the mouse wheel on the tab
2187line scrolls tabs that display the window buffers. 2187line scrolls tabs.
2188 2188
2189** fileloop.el lets one setup multifile operations like search&replace. 2189** fileloop.el lets one setup multifile operations like search&replace.
2190 2190
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 5f2dd3e6dd0..58f648c2827 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -94,8 +94,6 @@
94 (let ((map (make-sparse-keymap))) 94 (let ((map (make-sparse-keymap)))
95 (define-key map [tab-line mouse-1] 'tab-line-select-tab) 95 (define-key map [tab-line mouse-1] 'tab-line-select-tab)
96 (define-key map [tab-line mouse-2] 'tab-line-close-tab) 96 (define-key map [tab-line mouse-2] 'tab-line-close-tab)
97 (define-key map [tab-line mouse-4] 'tab-line-switch-to-prev-tab)
98 (define-key map [tab-line mouse-5] 'tab-line-switch-to-next-tab)
99 (define-key map "\C-m" 'tab-line-select-tab) 97 (define-key map "\C-m" 'tab-line-select-tab)
100 map) 98 map)
101 "Local keymap for `tab-line-mode' window tabs.") 99 "Local keymap for `tab-line-mode' window tabs.")
@@ -262,16 +260,16 @@ variable `tab-line-tabs-function'."
262 tab-line-new-button)))))) 260 tab-line-new-button))))))
263 261
264 262
265(defun tab-line-new-tab (&optional e) 263(defun tab-line-new-tab (&optional mouse-event)
266 "Add a new tab to the tab line. 264 "Add a new tab to the tab line.
267Usually is invoked by clicking on the plus-shaped button. 265Usually is invoked by clicking on the plus-shaped button.
268But any switching to other buffer also adds a new tab 266But any switching to other buffer also adds a new tab
269corresponding to the switched buffer." 267corresponding to the switched buffer."
270 (interactive "e") 268 (interactive (list last-nonmenu-event))
271 (if (functionp tab-line-new-tab-choice) 269 (if (functionp tab-line-new-tab-choice)
272 (funcall tab-line-new-tab-choice) 270 (funcall tab-line-new-tab-choice)
273 (if window-system ; (display-popup-menus-p) 271 (if (and (listp mouse-event) window-system) ; (display-popup-menus-p)
274 (mouse-buffer-menu e) ; like (buffer-menu-open) 272 (mouse-buffer-menu mouse-event) ; like (buffer-menu-open)
275 ;; tty menu doesn't support mouse clicks, so use tmm 273 ;; tty menu doesn't support mouse clicks, so use tmm
276 (tmm-prompt (mouse-buffer-menu-keymap))))) 274 (tmm-prompt (mouse-buffer-menu-keymap)))))
277 275
@@ -302,19 +300,21 @@ using the `previous-buffer' command."
302 (with-selected-window window 300 (with-selected-window window
303 (switch-to-buffer buffer)))))) 301 (switch-to-buffer buffer))))))
304 302
305(defun tab-line-switch-to-prev-tab (&optional e) 303(defun tab-line-switch-to-prev-tab (&optional mouse-event)
306 "Switch to the previous tab. 304 "Switch to the previous tab.
307Its effect is the same as using the `previous-buffer' command 305Its effect is the same as using the `previous-buffer' command
308(\\[previous-buffer])." 306(\\[previous-buffer])."
309 (interactive "e") 307 (interactive (list last-nonmenu-event))
310 (switch-to-prev-buffer (posn-window (event-start e)))) 308 (switch-to-prev-buffer
309 (and (listp mouse-event) (posn-window (event-start mouse-event)))))
311 310
312(defun tab-line-switch-to-next-tab (&optional e) 311(defun tab-line-switch-to-next-tab (&optional mouse-event)
313 "Switch to the next tab. 312 "Switch to the next tab.
314Its effect is the same as using the `next-buffer' command 313Its effect is the same as using the `next-buffer' command
315(\\[next-buffer])." 314(\\[next-buffer])."
316 (interactive "e") 315 (interactive (list last-nonmenu-event))
317 (switch-to-next-buffer (posn-window (event-start e)))) 316 (switch-to-next-buffer
317 (and (listp mouse-event) (posn-window (event-start mouse-event)))))
318 318
319(defcustom tab-line-close-tab-action 'bury-buffer 319(defcustom tab-line-close-tab-action 'bury-buffer
320 "Defines what to do on closing the tab. 320 "Defines what to do on closing the tab.
@@ -326,16 +326,17 @@ If `kill-buffer', kills the tab's buffer."
326 :group 'tab-line 326 :group 'tab-line
327 :version "27.1") 327 :version "27.1")
328 328
329(defun tab-line-close-tab (&optional e) 329(defun tab-line-close-tab (&optional mouse-event)
330 "Close the selected tab. 330 "Close the selected tab.
331Usually is invoked by clicking on the close button on the right side 331Usually is invoked by clicking on the close button on the right side
332of the tab. This command buries the buffer, so it goes out of sight 332of the tab. This command buries the buffer, so it goes out of sight
333from the tab line." 333from the tab line."
334 (interactive "e") 334 (interactive (list last-nonmenu-event))
335 (let* ((posnp (event-start e)) 335 (let* ((posnp (and (listp mouse-event) (event-start mouse-event)))
336 (window (posn-window posnp)) 336 (window (and posnp (posn-window posnp)))
337 (buffer (get-pos-property 1 'tab (car (posn-string posnp))))) 337 (buffer (or (get-pos-property 1 'tab (car (posn-string posnp)))
338 (with-selected-window window 338 (current-buffer))))
339 (with-selected-window (or window (selected-window))
339 (cond 340 (cond
340 ((eq tab-line-close-tab-action 'kill-buffer) 341 ((eq tab-line-close-tab-action 'kill-buffer)
341 (kill-buffer buffer)) 342 (kill-buffer buffer))
@@ -358,5 +359,11 @@ from the tab line."
358 '(:eval (tab-line-format))))) 359 '(:eval (tab-line-format)))))
359 360
360 361
362(global-set-key [tab-line mouse-4] 'tab-line-switch-to-prev-tab)
363(global-set-key [tab-line mouse-5] 'tab-line-switch-to-next-tab)
364(global-set-key [tab-line wheel-up] 'tab-line-switch-to-prev-tab)
365(global-set-key [tab-line wheel-down] 'tab-line-switch-to-next-tab)
366
367
361(provide 'tab-line) 368(provide 'tab-line)
362;;; tab-line.el ends here 369;;; tab-line.el ends here