-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefuns.el
160 lines (141 loc) · 3.58 KB
/
defuns.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
(package-require-or-install 'frame-fns)
(package-require-or-install 'frame-cmds)
(defun replace-last-sexp ()
(interactive)
(let ((value (eval (preceding-sexp))))
(kill-sexp -1)
(insert (format "%s" value))))
(defun undosify ()
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))
(defun use-node()
(interactive)
(desktop-change-dir "~/projects/nodejs")
(cd "~/projects/nodejs")
(rename-frame "" "nodejs")
)
(defun use-home()
(interactive)
(desktop-change-dir "~")
(cd "~")
(rename-frame "" "~")
)
(defun use-scratch()
(interactive)
(desktop-change-dir "~/tmp")
(cd "~/tmp")
(rename-frame "" "scratch")
)
(defun use-hw()
(interactive)
(desktop-change-dir "~/hw")
(cd "~/hw")
(rename-frame "" "hw")
)
(cd "~")
(rename-frame "" "~")
; Font/color settings
(defface dim-braces-face '((t (:foreground "#5f5f5f")))
"*Face for highlighting whitespace at line ends in Font-Lock mode."
:group 'font-lock :group 'faces)
(defvar dim-braces-p t
"Non-nil means font-lock mode highlights whitespace at line ends.")
(defun dim-braces ()
(interactive)
(setq dim-braces-p
(not dim-braces-p))
(if dim-braces-p
(add-hook 'font-lock-mode-hook 'dim-braces-add-colors)
(remove-hook 'font-lock-mode-hook 'dim-braces-add-colors)
(dim-braces-remove-colors))
(font-lock-mode) (font-lock-mode)
(message "Dim braces is now %s."
(if dim-braces-p "ON" "OFF")))
(defun dim-braces-add-colors ()
(font-lock-add-keywords
nil '(("[\;\{\}]" (0 'dim-braces-face t)))))
(defun dim-braces-remove-colors ()
(when (fboundp 'font-lock-remove-keywords)
(font-lock-remove-keywords
nil '(("[\;\{\}]" (0 'dim-braces-face t))))))
(dim-braces)
;(add-hook 'font-lock-mode-hook 'dim-braces-add-colors)
(defun pres-display ()
(interactive)
(if dim-braces-p
(dim-braces)
)
(set-face-attribute 'default nil :height 320)
)
(defun pres-mid ()
(interactive)
(if dim-braces-p
(dim-braces)
)
(set-face-attribute 'default nil :height 240)
)
(defun pres-small ()
(interactive)
(if dim-braces-p
(dim-braces)
)
(set-face-attribute 'default nil :height 180)
)
(defun pres-done ()
(interactive)
(if (not dim-braces-p)
(dim-braces)
)
(set-face-attribute 'default nil :height 120)
)
(defun goog(term)
(interactive "sSearch term: ")
(browse-url
(concat "http://www.google.com/search?q="
(replace-regexp-in-string " " "+" term)
)
)
)
(defun phpref(term)
(interactive "sSearch term: ")
(browse-url
(concat "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=site%3Aphp.net+"
(replace-regexp-in-string " " "+" term)
)
)
)
(defun jsref(term)
(interactive "sSearch term: ")
(browse-url
(concat "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=site%3Adeveloper.mozilla.org/en/JavaScript/Reference+"
(replace-regexp-in-string " " "+" term)
)
)
)
(defun copy-whole-buffer()
(interactive)
(mark-whole-buffer)
(copy-region-as-kill (region-beginning) (region-end))
)
(defun delint()
(interactive)
(mark-whole-buffer)
(replace-regexp "}(" "} (")
(goto-char (point-min))
(replace-regexp "){" ") {")
(goto-char (point-min))
(replace-regexp "function(" "function (")
(goto-char (point-min))
(replace-regexp "if(" "if (")
(goto-char (point-min))
(replace-regexp "}else" "} else")
(goto-char (point-min))
(replace-regexp "else{" "else {")
(goto-char (point-min))
(replace-regexp "for(" "for (")
(goto-char (point-min))
(replace-regexp "catch(" "catch (")
(goto-char (point-min))
(replace-regexp "}catch" "} catch")
)