forked from beet-aizu/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeet.el
37 lines (33 loc) · 1.14 KB
/
beet.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
(defun beet ()
(interactive)
(let ((pos (point)))
(beginning-of-buffer)
(goto-char (- (search-forward "//INSERT ABOVE HERE") 19))
(let (file buf str from to)
(setq file (read-file-name "File Name: " "~/git-library/"))
(setq buf (find-file-noselect file))
(setq str
(with-current-buffer buf
(buffer-substring-no-properties (point-min) (point-max))))
(setq from (+ (search "//BEGIN CUT HERE" str) 17))
(setq to (+ (search "//END CUT HERE" str) 1))
(insert
(with-current-buffer buf
(buffer-substring-no-properties from to)))
(insert "\n")
(setq pos (+ pos (- to from) 1)))
(goto-char pos)))
(define-key global-map (kbd "C-x l") 'beet)
(defun repl ()
(interactive)
(let ((pos (point)))
(setq case-fold-search nil)
(beginning-of-buffer)
(replace-regexp "\\([^a-zA-z0-9_\"]\\)int\\([^a-zA-z0-9_\"]\\)" "\\1Int\\2")
(beginning-of-buffer)
(replace-regexp "\\([(),<]\\)int\\([(),>]\\)" "\\1Int\\2")
(save-buffer)
(mark-whole-buffer)
(kill-ring-save (region-beginning) (region-end))
(goto-char pos)))
(define-key global-map (kbd "C-x r") 'repl)