blob: fa36f6dd6a1b64b8d3692283ffe4f1d9e0951e5c (
plain)
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 change (old-pat new-pat) "Replace all occurences of old-pat to new-pat in current buffer."
(interactive "r")
(goto-char (point-min))
(replace-string old-pat new-pat))
(defun changereg (old-regexp new-regexp) "Replace all occurences of old-regexp to new-regexp in current buffer."
(interactive "r")
(goto-char (point-min))
(replace-regexp old-regexp new-regexp))
(defun querychangereg (old-regexp new-regexp) "Replace all occurences of old-regexp to new-regexp in current buffer, with query."
(interactive "r")
(goto-char (point-min))
(query-replace-regexp old-regexp new-regexp))
(set-variable 'case-fold-search nil)
(change " + " "+")
(change " - " "-")
(change " * " "*")
(change " / " "/")
(change " = " "=")
(change " --" "--")
(change "-- " "--")
(change " ++" "++")
(change "++ " "++")
(change " .. " "..")
(change " ^^ " "^^")
(change " & " "&")
(change " :: " "::")
(change ";--" "; --")
(change " (" "(")
(change " )" ")")
(change " }" "}")
(changereg "( \\([^/]\\)" "(\\1")
(changereg "{ \\([^/]\\)" "{\\1")
(changereg "\\([^ ]\\)\\?" "\\1 ?")
(changereg "\\?\\([^ ]\\)" "? \\1")
(changereg ";\\([^ \\}
]\\)" "; \\1")
;;(changereg "\\([^ ]\\):" "\\1 :")
(changereg ":\\([^ ]\\)" ": \\1")
(changereg "\\([+-*/=!]\\)=\\([^ ]\\)" "\\1= \\2")
(changereg "\\([^ ]\\)\\([+-*/=!]\\)=" "\\1 \\2=")
(changereg "\\([]\\)\\([^ =]\\)" "\\1 \\2")
(changereg "\\([^ ]\\)\\([]\\)" "\\1 \\2")
(changereg "&&\\([^ ]\\)" "&& \\1")
(changereg "||\\([^ ]\\)" "|| \\1")
(changereg "\\[\\]\\([^ []\\)" "[] \\1")
(indent-region (point-min) (point-max))
(querychangereg ", " ",")
|