Created
April 7, 2012 09:03
-
-
Save Johniel/2326697 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; move tab position | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defun tabbar-insert (tabs ctab nth) | |
(append (nthcar nth tabs) | |
(list ctab) | |
(nthcdr nth tabs))) | |
(defun tabbar-find-remove (ctabs ctab) | |
(let ((index 0) | |
(head '()) | |
(rest ctabs)) | |
(while (not (eq ctab (car rest))) | |
(incf index) | |
(setq head (append head (list (car rest)))) | |
(setq rest (cdr rest))) | |
(list index (append head (cdr rest))))) | |
(defun tabbar-move-tab (&optional with-right?) | |
(let* ((ctabset (tabbar-current-tabset 't)) | |
(ctabs (tabbar-tabs ctabset)) | |
(ctab (tabbar-selected-tab ctabset))) | |
(if (and ctabset ctabs ctab) | |
(progn | |
(let* ((index-tabs (tabbar-find-remove ctabs ctab)) | |
(index (first index-tabs)) | |
(l (length ctabs))) | |
(setq index (if with-right? | |
(% (+ index 1) l) | |
(% (+ (- index 1) l) l))) | |
(set ctabset (tabbar-insert (second index-tabs) ctab index)) | |
(put ctabset 'template nil) | |
(tabbar-display-update)))))) | |
(defun tabbar-move-right () | |
(interactive) | |
(tabbar-move-tab t)) | |
(defun tabbar-move-left () | |
(interactive) | |
(tabbar-move-tab)) | |
(global-set-key [\C-home] 'tabbar-move-left) | |
(global-set-key [\C-end] 'tabbar-move-right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment