-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraps.el
52 lines (41 loc) · 1.34 KB
/
scraps.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
(defun increment-number-at-point ()
(interactive)
(skip-chars-backward "0-9")
(or (looking-at "[0-9]+")
(error "No number at point"))
(replace-match (number-to-string (1+ (string-to-number (match-string 0))))))
(defun decrement-number-at-point ()
(interactive)
(skip-chars-backward "0-9")
(or (looking-at "[0-9]+")
(error "No number at point"))
(replace-match (number-to-string (1- (string-to-number (match-string 0))))))
;; yas
;; PropertySchema.${1:$(upcase yas-text)}: '$1_value',
;; $0
(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
(defun expand-macro ()
(interactive)
(backward-kill-sexp)
(prin1 (macroexpand-1 (read (current-kill 0)))
(current-buffer)))
(defun to-underscore ()
(interactive)
(replace-regexp "\\([A-Z]\\)" "_\\1" nil (region-beginning) (region-end))
(downcase-region (region-beginning) (region-end)))
(defun unfill-paragraph ()
(interactive)
(let ((fill-column 100000))
(fill-paragraph)))
(defun dedicate-window (&optional arg)
"Dedicate the current window."
(interactive)
(set-window-dedicated-p (selected-window) (not arg)))