forked from krisajenkins/evil-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
evil-tabs.el
94 lines (77 loc) · 2.71 KB
/
evil-tabs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;;; evil-tabs.el --- Integrating Vim-style tabs for Evil mode users.
;; Copyright 2013 Kris Jenkins
;;
;; Author: Kris Jenkins <[email protected]>
;; Maintainer: Kris Jenkins <[email protected]>
;; Keywords: evil tab tabs vim
;; URL: https://github.com/krisajenkins/evil-tabs
;; Created: 30th September 2013
;; Version: 0.1.0
;; Package-Requires: ((evil "0.0.0") (elscreen "0.0.0"))
;;; Commentary:
;;
;; Integrating Vim-style tabs for Evil mode users.
;;; Code:
(require 'evil)
(require 'elscreen)
(defvar evil-tabs-mode-map (make-sparse-keymap)
"Evil-tabs-mode's keymap.")
(evil-define-command evil-tabs-tabedit (file)
(interactive "<f>")
(elscreen-find-file file))
(evil-define-command evil-tab-sensitive-quit (&optional bang)
:repeat nil
(interactive "<!>")
(if (> (length (elscreen-get-screen-list)) 1)
(elscreen-kill)
(evil-quit bang)))
(evil-define-command evil-tabs-current-buffer-to-tab ()
(let ((nwindows (length (window-list)))
(cb (current-buffer)))
(when (> nwindows 1)
(delete-window)
(elscreen-create)
(switch-to-buffer cb))))
(evil-define-motion evil-tabs-goto-tab (&optional count)
(if count
(elscreen-goto (- count 1))
(elscreen-next)))
(evil-ex-define-cmd "tabe[dit]" 'evil-tabs-tabedit)
(evil-ex-define-cmd "tabclone" 'elscreen-clone)
(evil-ex-define-cmd "tabc[lose]" 'elscreen-kill)
(evil-ex-define-cmd "tabd[isplay]" 'elscreen-toggle-display-tab)
(evil-ex-define-cmd "tabg[oto]" 'elscreen-goto)
(evil-ex-define-cmd "tabo[nly]" 'elscreen-kill-others)
(evil-ex-define-cmd "tabnew" 'elscreen-create)
(evil-ex-define-cmd "tabn[ext]" 'elscreen-next)
(evil-ex-define-cmd "tabp[rev]" 'elscreen-previous)
(evil-ex-define-cmd "tabr[ename]" 'elscreen-screen-nickname)
(evil-ex-define-cmd "tabs[elect]" 'elscreen-select-and-goto)
(evil-ex-define-cmd "tabw[ith]" 'elscreen-find-and-goto-by-buffer)
(evil-ex-define-cmd "q[uit]" 'evil-tab-sensitive-quit)
(evil-define-key 'normal evil-tabs-mode-map
"gt" 'elscreen-next
"gT" 'elscreen-previous
"gt" 'evil-tabs-goto-tab
"T" 'evil-tabs-current-buffer-to-tab)
;;;###autoload
(define-minor-mode evil-tabs-mode
"Integrating Vim-style tabs for Evil mode users."
:global t
:keymap evil-tabs-mode-map
(let ((prev-state evil-state))
(evil-normal-state)
(evil-change-state prev-state)
(elscreen-start)))
;;;###autoload
(defun turn-on-evil-tabs-mode ()
"Enable `evil-tabs-mode' in the current buffer."
(evil-tabs-mode 1))
;;;###autoload
(defun turn-off-evil-tabs-mode ()
"Disable `evil-tabs-mode' in the current buffer."
(evil-tabs-mode -1))
;;;###autoload
(define-globalized-minor-mode global-evil-tabs-mode evil-tabs-mode turn-on-evil-tabs-mode)
(provide 'evil-tabs)
;;; evil-tabs.el ends here