forked from syl20bnr/spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
funcs.el
61 lines (53 loc) · 2.15 KB
/
funcs.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
(defun exwm/exwm-bind-command (key command &rest bindings)
"Bind KEYs to COMMANDs globally"
(while key
(exwm-input-set-key (kbd key)
`(lambda ()
(interactive)
(start-process-shell-command ,command nil
,command)))
(setq key (pop bindings)
command
(pop bindings))))
(defun exwm/exwm-workspace-next ()
"Switch to next exwm-workspace (to the right)."
(interactive)
(let* ((only-workspace? (equal exwm-workspace-number 1))
(overflow? (= exwm-workspace-current-index (1- exwm-workspace-number))))
(cond
(only-workspace? nil)
(overflow? (when exwm-workspace-switch-wrap
(exwm-workspace-switch 0)))
(t (exwm-workspace-switch (1+ exwm-workspace-current-index))))))
(defun exwm/exwm-workspace-prev ()
"Switch to next exwm-workspace (to the left)."
(interactive)
(let* ((only-workspace? (equal exwm-workspace-number 1))
(overflow? (= exwm-workspace-current-index 0)))
(cond
(only-workspace? nil)
(overflow? (when exwm-workspace-switch-wrap
(exwm-workspace-switch (1- exwm-workspace-number))))
(t (exwm-workspace-switch (1- exwm-workspace-current-index))))))
;; Quick swtiching between workspaces
(defvar exwm--toggle-workspace 0 "Previously selected workspace. Used with `exwm/jump-to-last-exwm'.")
(defun exwm/jump-to-last-exwm ()
(interactive)
(exwm-workspace-switch exwm--toggle-workspace))
(defadvice exwm-workspace-switch
(before save-toggle-workspace activate)
(setq exwm--toggle-workspace exwm-workspace-current-index))
(defun exwm/exwm-app-launcher ()
"Launches an application in your PATH.
Can show completions at point for COMMAND using helm"
(interactive)
(call-interactively
(if (configuration-layer/package-usedp 'helm)
'helm-run-external-command
'async-shell-command)))
(defun exwm/exwm-lock ()
(interactive)
(start-process "" nil exwm-locking-command))
;; Other utilities
(defun exwm//flatenum (i ls)
(if ls (cons i (cons (first ls) (exwm//flatenum (1+ i) (cdr ls)))) (list)))