-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefuns.el
66 lines (56 loc) · 2.43 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
(defun wacky-add-watchwords ()
(font-lock-add-keywords
nil '(("\\<\\(FIX\\(_?ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\|XXX\\)"
1 font-lock-warning-face t))))
(defun iwb ()
"Indent and cleanup whitespace on buffer"
(interactive)
(untabify (point-min) (point-max))
(indent-region (point-min) (point-max))
(delete-trailing-whitespace))
;; Use % to match various kinds of brackets...
;; See: http://www.lifl.fr/~hodique/uploads/Perso/patches.el
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(let ((prev-char (char-to-string (preceding-char)))
(next-char (char-to-string (following-char))))
(cond ((string-match "[[{(<]" next-char) (forward-sexp 1))
((string-match "[\]})>]" prev-char) (backward-sexp 1))
(t (self-insert-command (or arg 1))))))
;; re-builder functions from http://www.emacswiki.org/emacs/ReBuilder
;; reb-query-replace modified to push point to beginning of buffer.
(defun reb-query-replace (to-string)
"Replace current RE from point with `query-replace-regexp'."
(interactive
(progn (barf-if-buffer-read-only)
(list (query-replace-read-to (reb-target-binding reb-regexp)
"Query replace" t))))
(with-current-buffer reb-target-buffer
(goto-char (point-min))
(query-replace-regexp (reb-target-binding reb-regexp) to-string)))
(defun reb-beginning-of-buffer ()
"In re-builder, move target buffer point position back to beginning."
(interactive)
(set-window-point (get-buffer-window reb-target-buffer)
(with-current-buffer reb-target-buffer (point-min))))
(defun reb-end-of-buffer ()
"In re-builder, move target buffer point position back to beginning."
(interactive)
(set-window-point (get-buffer-window reb-target-buffer)
(with-current-buffer reb-target-buffer (point-max))))
(global-set-key [remap goto-line] 'goto-line-with-feedback)
;; http://whattheemacsd.com/key-bindings.el-01.html
(defun goto-line-with-feedback ()
"Show line numbers temporarily, while prompting for the line number input"
(interactive)
(unwind-protect
(progn
(linum-mode 1)
(goto-line (read-number "Goto line: ")))
(linum-mode -1)))
(defun wacky-darken ()
"Load dark theme, since I have odd reasons for not doing this at startup"
(interactive)
(require 'color-theme-solarized)
(color-theme-solarized-dark) )