-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyaoni-edit.el
70 lines (60 loc) · 2.02 KB
/
yaoni-edit.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
;; -*- lexical-binding: t; -*-
(defun yaoni/replace-buffer-content ()
"Erase buffer and paste the last content in kill-ring."
(interactive)
(erase-buffer)
(call-interactively 'evil-paste-before))
(defun yaoni/copy-buffer ()
"Copy the buffer content."
(interactive)
(let ((s (buffer-string)))
(if (> (length s) 10000)
(if (y-or-n-p "Buffer content too long. Proceed? (y/n)")
(kill-new s)
(message "Operation canclled."))
(kill-new s))))
(defun yaoni/copy-minibuffer ()
"Copy the minibuffer content with live candidates."
(interactive)
(mark-whole-buffer)
(kill-ring-save))
(defun yaoni/upcase-thing-at-point ()
"Upcase thing at point"
(interactive)
(yaoni/mark-node)
(upcase-region (region-beginning) (region-end)))
(defun yaoni/downcase-thing-at-point ()
"Downcase thing at point."
(interactive)
(yaoni/mark-node)
(downcase-region (region-beginning) (region-end)))
(evil-define-operator yaoni/evil-replace-with-kill-ring (beg end type register yank-handler)
"Replace current content from BEG to END with content in kill-ring."
(interactive "<R><x><y>")
;; somehow no need to call 'evil-delete interactively?
(evil-delete beg end type register yank-handler)
(insert (cadr kill-ring)))
(define-key evil-normal-state-map "r" 'yaoni/evil-replace-with-kill-ring)
(defun yaoni/indent-toggle-fold ()
"Toggle fold all lines larger than indentation on current line"
(interactive)
(let ((col 1))
(save-excursion
(back-to-indentation)
(setq col (+ 1 (current-column)))
(set-selective-display
(if selective-display nil (or col 1))))))
(defun yaoni/number-items (start end)
"Number the lines in the region from START to END."
(interactive "r")
(let ((line-number 0)
(end end)
(offset 3))
(goto-char start)
(while (< (point) end)
(setq line-number (1+ line-number))
(insert (format "%d. " line-number))
(setq end (+ end offset))
(forward-line 1))))
(provide 'yaoni-edit)
;;; yaoni-edit.el ends here