[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 912966a: * lisp/tab-bar.el (tab-bar-swap-tabs, tab-
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] master 912966a: * lisp/tab-bar.el (tab-bar-swap-tabs, tab-bar-move-tab): New commands. |
Date: |
Sun, 20 Oct 2019 13:36:35 -0400 (EDT) |
branch: master
commit 912966a5aaca489c4f130e38342c07a675c45085
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>
* lisp/tab-bar.el (tab-bar-swap-tabs, tab-bar-move-tab): New commands.
(tab-swap, tab-move): New aliases to new commands.
---
lisp/tab-bar.el | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 117b8ea..1c182a9 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -544,6 +544,26 @@ to the numeric argument. ARG counts from 1."
(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab)
+(defun tab-bar-swap-tabs (to-index &optional from-index)
+ "Exchange positions of two tabs referred by FROM-INDEX and TO-INDEX.
+FROM-INDEX defaults to the current tab index.
+FROM-INDEX and TO-INDEX count from 1."
+ (interactive "P")
+ (let* ((tabs (funcall tab-bar-tabs-function))
+ (from-index (or from-index (1+ (tab-bar--current-tab-index tabs)))))
+ (rotatef (nth (1- from-index) tabs)
+ (nth (1- to-index) tabs))))
+
+(defun tab-bar-move-tab (&optional arg)
+ "Move the current tab ARG positions to the right.
+If a negative ARG, move the current tab ARG positions to the left."
+ (interactive "p")
+ (let* ((tabs (funcall tab-bar-tabs-function))
+ (from-index (or (tab-bar--current-tab-index tabs) 0))
+ (to-index (mod (+ from-index arg) (length tabs))))
+ (tab-bar-swap-tabs (1+ to-index) (1+ from-index))))
+
+
(defcustom tab-bar-new-tab-to 'right
"Defines where to create a new tab.
If `leftmost', create as the first tab.
@@ -717,14 +737,16 @@ function `tab-bar-tab-name-function'."
;;; Short aliases
-(defalias 'tab-new 'tab-bar-new-tab)
-(defalias 'tab-close 'tab-bar-close-tab)
+(defalias 'tab-new 'tab-bar-new-tab)
+(defalias 'tab-close 'tab-bar-close-tab)
(defalias 'tab-close-other 'tab-bar-close-other-tabs)
-(defalias 'tab-select 'tab-bar-select-tab)
-(defalias 'tab-next 'tab-bar-switch-to-next-tab)
-(defalias 'tab-previous 'tab-bar-switch-to-prev-tab)
-(defalias 'tab-rename 'tab-bar-rename-tab)
-(defalias 'tab-list 'tab-bar-list)
+(defalias 'tab-select 'tab-bar-select-tab)
+(defalias 'tab-next 'tab-bar-switch-to-next-tab)
+(defalias 'tab-previous 'tab-bar-switch-to-prev-tab)
+(defalias 'tab-swap 'tab-bar-swap-tabs)
+(defalias 'tab-move 'tab-bar-move-tab)
+(defalias 'tab-rename 'tab-bar-rename-tab)
+(defalias 'tab-list 'tab-bar-list)
;;; Non-graphical access to frame-local tabs (named window configurations)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 912966a: * lisp/tab-bar.el (tab-bar-swap-tabs, tab-bar-move-tab): New commands.,
Juri Linkov <=