-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.el
113 lines (93 loc) · 3.19 KB
/
func.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
;;; func --- useful functions
;;; Commentary:
;;; Useful editing functions
;;; Code:
;; Comment line. Only useful on Emacs version < 25
(defun comment-line ()
"Comment or uncomment the current line. Your cursor doesn't move."
(interactive)
(comment-or-uncomment-region (point-at-bol) (point-at-eol)))
(global-set-key (kbd "C-x C-;") 'comment-line)
(defun backward-delete-word-no-kill-ring (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (backward-word arg) (point))))
(defun forward-delete-word-no-kill-ring (arg)
"Delete characters forward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (forward-word arg) (point))))
(defun vsplit-last-buffer ()
(interactive)
(split-window-vertically)
(other-window 1 nil)
(switch-to-next-buffer))
(defun hsplit-last-buffer ()
(interactive)
(split-window-horizontally)
(other-window 1 nil)
(switch-to-next-buffer))
(global-set-key (kbd "C-x 2") 'vsplit-last-buffer)
(global-set-key (kbd "C-x 3") 'hsplit-last-buffer)
(defun kill-and-delete-window ()
(interactive)
(kill-buffer)
(if (equal 1 (length (window-list)))
nil
(delete-window)))
(defun beginning-of-line-edit ()
"Move to the beginnging of the line and switch to edit mode."
(interactive)
(move-beginning-of-line nil)
(modalka-mode -1))
(defun end-of-line-edit ()
"Move to the end of the line and switch to edit mode."
(interactive)
(move-end-of-line nil)
(modalka-mode -1))
(defun forward-word-edit (&optional n)
"N is how many words you wish to jump.
Jump the word and switch to edit mode."
(interactive "p\n")
(forward-word n)
(modalka-mode -1))
(defun backward-word-edit (&optional n)
"N is how many words you wish to jump.
Jump the word backwards and switch to edit mode."
(interactive "p\n")
(backward-word n)
(modalka-mode -1))
(defun replace-char ()
"Replace the character underneath the cursor."
(interactive)
(let ((c (read-key)))
(delete-char 1)
(insert c)))
(defun iy-go-to-char-correctly (n char)
"N is the number of occurances, CHAR is the character you wish to goto.
This function fixes a flaw that the original has with not landing directly on the char you pick."
(interactive "p\ncGo to char: ")
(iy-go-to-char n char)
(backward-char))
(defun delete-forward-word-edit (&optional n)
"N is how many words you wish to delete.
Delete the word forwards and switch to edit mode."
(interactive "p\n")
(forward-delete-word-no-kill-ring n)
(modalka-mode -1))
(defun delete-backward-word-edit (&optional n)
"N is how many words you wish to delete.
Delete the word backwards and switch to edit mode."
(interactive "p\n")
(backward-delete-word-no-kill-ring n)
(modalka-mode -1))
(defun zap-to-char-edit (arg char)
"ARG is how many characters you wish to delete, CHAR is the character.
Delete to character and switch to edit mode."
(interactive (list (prefix-numeric-value current-prefix-arg)
(read-char "Zap to char: " t)))
(zap-to-char arg char)
(modalka-mode -1))
(provide 'func)
;;; func.el ends here