-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscamx-command.el
129 lines (115 loc) · 3.79 KB
/
scamx-command.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
;;;###autoload
(defun scamx-shrink-window-horizontally ()
(interactive)
(shrink-window-horizontally 40))
;;;###autoload
(defun scamx-enlarge-window-horizontally ()
(interactive)
(enlarge-window-horizontally 40))
;;;###autoload
(defun scamx-kill-line (&optional arg)
"Kill line if no region is selected, otherwise kill the region."
(interactive "P")
(when (meow--allow-modify-p)
(if (use-region-p)
(kill-region (region-beginning) (region-end))
(if arg
(kill-line (prefix-numeric-value arg))
(kill-line)))))
;;;###autoload
(defun scamx-kill-sentence (&optional arg)
"Kill sentence if no region is selected, otherwise kill the region."
(interactive "P")
(when (meow--allow-modify-p)
(if (use-region-p)
(kill-region (region-beginning) (region-end))
(if arg
(kill-sentence (prefix-numeric-value arg))
(kill-sentence)))))
;;;###autoload
(defun scamx-kill-paragraph (arg)
"Kill paragraph if no region is selected, otherwise kill the region."
(interactive "p")
(when (meow--allow-modify-p)
(if (use-region-p)
(kill-region (region-beginning) (region-end))
(if arg
(kill-paragraph arg)
(kill-paragraph)))))
;;;###autoload
(defun scamx-delete-char (arg &optional killp)
"delete char if no region is selected, otherwise, delete region without storing to killring.
With a prefix ARG, delete ARG characters. If KILLP is non-nil, also kill
the deleted text (similar to `kill-region`)."
(interactive "p")
(when (meow--allow-modify-p)
(if (use-region-p)
(delete-active-region nil)
(if arg
(if killp
(delete-char arg killp)
(delete-char arg))
(delete-char)))))
;;;###autoload
(defun scamx-backward-delete-char (arg &optional killp)
"backward delete char if no region is selected, otherwise, delete region without storing to killring.
With a prefix ARG, delete ARG characters. If KILLP is non-nil, also kill
the deleted text (similar to `kill-region`)."
(interactive "p")
(when (meow--allow-modify-p)
(if (use-region-p)
(delete-active-region nil)
(if arg
(if killp
(backward-delete-char-untabify arg killp)
(backward-delete-char-untabify arg))
(backward-delete-char-untabify)))))
;;;###autoload
(defun scamx-kill-word (arg)
"kill word if no region is selected, otherwise, delete region without storing to killring."
(interactive "p")
(when (meow--allow-modify-p)
(if (use-region-p)
(delete-active-region nil)
(if arg
(kill-word arg)
(kill-word)))))
;;;###autoload
(defun scamx-backward-kill-word (arg)
"backward kill word if no region is selected, otherwise, delete region without storing to killring."
(interactive "p")
(when (meow--allow-modify-p)
(if (use-region-p)
(delete-active-region nil)
(if arg
(backward-kill-word arg)
(backward-kill-word)))))
;;;###autoload
(defun scamx-forward-paragraph (&optional arg)
"Kill line if no region is selected, otherwise kill the region."
(interactive "P")
(if (minibufferp)
(if arg
(next-history-element arg)
(next-history-element 1))
(forward-paragraph arg)))
;;;###autoload
(defun scamx-backward-paragraph (&optional arg)
"Kill line if no region is selected, otherwise kill the region."
(interactive "P")
(if (minibufferp)
(if arg
(previous-history-element arg)
(previous-history-element 1))
(backward-paragraph arg)))
;;;###autoload
(defun scamx-suspend (&optional arg)
(interactive "P")
(when (meow-convert-mode-p)
(meow--switch-state 'normal)
(let ((key (read-key-sequence "Suspend to execute a command in Normal mode: ")))
(if (not (equal (key-binding key) 'undefined))
(execute-kbd-macro key arg)
(message "%s is undefined" key)))
(meow--switch-state 'convert)))
(provide 'scamx-command)