summaryrefslogtreecommitdiff
path: root/tab-conf.el
blob: f55259c790a5700ef0f446e088d89018a6c29998 (plain)
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
;;; tab-conf.el --- My configurations of the tabs -*- lexical-binding: t; -*-

(require 'tab-bar)

(define-key tab-switcher-mode-map (vector ?n) 'tab-switcher-next-or-first)
(define-key tab-switcher-mode-map (vector ?p) 'tab-switcher-prev-or-last)
(define-key tab-prefix-map (vector 'tab) 'tab-switcher)

;;;###autoload
(defun tab-switcher-first ()
  "Go to the first window configuration line."
  (interactive)
  (goto-char (point-min))
  (skip-chars-forward "[:space:]\n")
  (forward-char -1))

;;;###autoload
(defun tab-switcher-last ()
  "Go to the last window configuration line."
  (interactive)
  (goto-char (point-max))
  (skip-chars-backward "[:space:]\n")
  (goto-char (line-beginning-position))
  (skip-chars-forward "[:space:]")
  (forward-char -1))

;;;###autoload
(defun tab-switcher-next-or-first ()
  "Go to the next configuration line.
If the next line is not a configuration line, 
then go to the first configuration line."
  (interactive)
  (forward-line 1)
  (cond
   ((looking-at "^\\s-*$")
    (tab-switcher-first))
   (t (skip-chars-forward "[:space:]")
      (forward-char -1))))

;;;###autoload
(defun tab-switcher-prev-or-last ()
  "Go to the previous configuration line.
If the previous line is not a configuration line, 
then go to the last configuration line."
  (interactive)
  (forward-line -1)
  (cond
   ((looking-at "^\\s-*$")
    (tab-switcher-last))
   (t (skip-chars-forward "[:space:]")
      (forward-char -1))))