-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.el
47 lines (31 loc) · 1.2 KB
/
helpers.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 swap-windows ()
(interactive)
(save-excursion
(let ((current-buf (window-buffer (selected-window)))
(other-buf (window-buffer (next-window (selected-window)))))
(set-window-buffer (selected-window) other-buf)
(set-window-buffer (next-window (selected-window)) current-buf))))
(defmacro maybe-require (package &optional body)
"Tries to load the specified package. If it succeeds, then body is executed (if provided)."
(if body
`(lambda ()
(require ,package nil t)
(if (featurep ,package)
,@body))
`(require ,package nil t)))
(defun google ()
"Prompt for a query in the minibuffer, launch the web browser and query google."
(interactive)
(let ((search (read-from-minibuffer "Google Search: ")))
(browse-url (concat "http://www.google.com/search?q=" search))))
(defun indent-buffer ()
"indent whole buffer"
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
(defun esk-add-watchwords ()
(font-lock-add-keywords
nil '(("\\<\\(FIX\\|TODO\\|FIXME\\|HACK\\|REFACTOR\\|NOCOMMIT\\)"
1 font-lock-warning-face t))))
(add-hook 'prog-mode-hook 'esk-add-watchwords)