Skip to content
Newer
Older
100644 167 lines (135 sloc) 5.71 KB
53627f5 @technomancy Clean up starter-kit-defuns.el.
authored Dec 9, 2010
1 ;;; starter-kit-defuns.el --- Saner defaults and goodies: function defs.
5fcb34d @technomancy initial commit
authored Nov 18, 2008
2 ;;
53627f5 @technomancy Clean up starter-kit-defuns.el.
authored Dec 10, 2010
3 ;; Copyright (c) 2008-2010 Phil Hagelberg and contributors
4 ;;
5 ;; Author: Phil Hagelberg <technomancy@gmail.com>
6 ;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
e0b9de2 @technomancy Version 2.0.2 of the base starter-kit.
authored Sep 13, 2011
7 ;; Version: 2.0.2
53627f5 @technomancy Clean up starter-kit-defuns.el.
authored Dec 10, 2010
8 ;; Keywords: convenience
9
10 ;; This file is not part of GNU Emacs.
11
12 ;;; Commentary:
13
14 ;; "Emacs outshines all other editing software in approximately the
15 ;; same way that the noonday sun does the stars. It is not just bigger
16 ;; and brighter; it simply makes everything else vanish."
17 ;; -Neal Stephenson, "In the Beginning was the Command Line"
18
19 ;; This file contains all the function definitions for the starter kit.
20
21 ;;; License:
22
23 ;; This program is free software; you can redistribute it and/or
24 ;; modify it under the terms of the GNU General Public License
25 ;; as published by the Free Software Foundation; either version 3
26 ;; of the License, or (at your option) any later version.
27 ;;
28 ;; This program is distributed in the hope that it will be useful,
29 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;; GNU General Public License for more details.
32 ;;
33 ;; You should have received a copy of the GNU General Public License
34 ;; along with GNU Emacs; see the file COPYING. If not, write to the
35 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 ;; Boston, MA 02110-1301, USA.
37
38 ;;; Code:
5fcb34d @technomancy initial commit
authored Nov 18, 2008
39
8967c61 @technomancy Switch to using prog-mode-hook instead of our own coding-hook.
authored May 19, 2011
40 ;;; These belong in prog-mode-hook:
b2ffdf1 @technomancy Make coding-hook a real hook instead of a defun.
authored Mar 11, 2009
41
a4a57d5 @technomancy Add a whitespace-mode function.
authored May 20, 2009
42 ;; We have a number of turn-on-* functions since it's advised that lambda
43 ;; functions not go in hooks. Repeatedly evaling an add-to-list with a
44 ;; hook value will repeatedly add it since there's no way to ensure
031dfc8 @technomancy Cleanup mostly for things that aren't necessary in 24 anymore.
authored Sep 13, 2011
45 ;; that a byte-compiled lambda doesn't already exist in the list.
a4a57d5 @technomancy Add a whitespace-mode function.
authored May 20, 2009
46
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
47 (defun esk-local-column-number-mode ()
5fcb34d @technomancy initial commit
authored Nov 18, 2008
48 (make-local-variable 'column-number-mode)
b2ffdf1 @technomancy Make coding-hook a real hook instead of a defun.
authored Mar 11, 2009
49 (column-number-mode t))
50
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
51 (defun esk-local-comment-auto-fill ()
b2ffdf1 @technomancy Make coding-hook a real hook instead of a defun.
authored Mar 11, 2009
52 (set (make-local-variable 'comment-auto-fill-only-comments) t)
53 (auto-fill-mode t))
54
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
55 (defun esk-turn-on-hl-line-mode ()
6c214af @technomancy Activate hl-line based on colors available, not window-system.
authored Sep 13, 2011
56 (when (> (display-color-cells) 8)
57 (hl-line-mode t)))
b2ffdf1 @technomancy Make coding-hook a real hook instead of a defun.
authored Mar 11, 2009
58
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
59 (defun esk-turn-on-save-place-mode ()
df65c4b @technomancy Trim down loads, use esk- prefix in starter-kit.el.
authored Dec 9, 2010
60 (require 'saveplace)
b2ffdf1 @technomancy Make coding-hook a real hook instead of a defun.
authored Mar 11, 2009
61 (setq save-place t))
62
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
63 (defun esk-pretty-lambdas ()
64 (font-lock-add-keywords
65 nil `(("(?\\(lambda\\>\\)"
66 (0 (progn (compose-region (match-beginning 1) (match-end 1)
67 ,(make-char 'greek-iso8859-7 107))
68 nil))))))
9e78e16 @technomancy Turn off toolbar even when in daemon-mode.
authored Jul 30, 2009
69
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
70 (defun esk-add-watchwords ()
c0b7ae5 @technomancy Add watchwords to coding hook.
authored Jan 6, 2010
71 (font-lock-add-keywords
0969080 @dgutov Fix FIXME highlighting
dgutov authored May 1, 2012
72 nil '(("\\<\\(FIX\\(ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\)"
c0b7ae5 @technomancy Add watchwords to coding hook.
authored Jan 7, 2010
73 1 font-lock-warning-face t))))
74
8967c61 @technomancy Switch to using prog-mode-hook instead of our own coding-hook.
authored May 19, 2011
75 (add-hook 'prog-mode-hook 'esk-local-column-number-mode)
76 (add-hook 'prog-mode-hook 'esk-local-comment-auto-fill)
77 (add-hook 'prog-mode-hook 'esk-turn-on-hl-line-mode)
78 (add-hook 'prog-mode-hook 'esk-turn-on-save-place-mode)
79 (add-hook 'prog-mode-hook 'esk-pretty-lambdas)
80 (add-hook 'prog-mode-hook 'esk-add-watchwords)
c71507f @drothlis Calling (paredit-mode) etc. from elisp code always enables, not toggl…
drothlis authored May 4, 2012
81 (add-hook 'prog-mode-hook 'idle-highlight-mode)
5fcb34d @technomancy initial commit
authored Nov 18, 2008
82
1bc0998 @technomancy Add a defun for running prog-mode-hook.
authored Sep 13, 2011
83 (defun esk-prog-mode-hook ()
84 (run-hooks 'prog-mode-hook))
85
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
86 (defun esk-turn-off-tool-bar ()
c405654 Ensure tool-bar-mode exists before running it (fixes emacsclient with…
hellekin authored Dec 1, 2011
87 (if (functionp 'tool-bar-mode) (tool-bar-mode -1)))
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
88
89 (defun esk-untabify-buffer ()
5fcb34d @technomancy initial commit
authored Nov 18, 2008
90 (interactive)
91 (untabify (point-min) (point-max)))
92
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
93 (defun esk-indent-buffer ()
5fcb34d @technomancy initial commit
authored Nov 18, 2008
94 (interactive)
95 (indent-region (point-min) (point-max)))
96
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
97 (defun esk-cleanup-buffer ()
1f6f58b @technomancy Extracted cleanup buffer function.
authored Dec 16, 2008
98 "Perform a bunch of operations on the whitespace content of a buffer."
99 (interactive)
53627f5 @technomancy Clean up starter-kit-defuns.el.
authored Dec 10, 2010
100 (esk-indent-buffer)
101 (esk-untabify-buffer)
1f6f58b @technomancy Extracted cleanup buffer function.
authored Dec 17, 2008
102 (delete-trailing-whitespace))
103
031dfc8 @technomancy Cleanup mostly for things that aren't necessary in 24 anymore.
authored Sep 14, 2011
104 ;; Commands
5fcb34d @technomancy initial commit
authored Nov 18, 2008
105
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
106 (defun esk-eval-and-replace ()
5fcb34d @technomancy initial commit
authored Nov 18, 2008
107 "Replace the preceding sexp with its value."
108 (interactive)
109 (backward-kill-sexp)
110 (condition-case nil
111 (prin1 (eval (read (current-kill 0)))
112 (current-buffer))
113 (error (message "Invalid expression")
114 (insert (current-kill 0)))))
115
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
116 (defun esk-sudo-edit (&optional arg)
5fcb34d @technomancy initial commit
authored Nov 18, 2008
117 (interactive "p")
e404594 @technomancy Fix sudo-edit and turn off toolbar always.
authored Aug 11, 2009
118 (if (or arg (not buffer-file-name))
5fcb34d @technomancy initial commit
authored Nov 18, 2008
119 (find-file (concat "/sudo:root@localhost:" (ido-read-file-name "File: ")))
120 (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
121
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
122 (defun esk-lorem ()
5fcb34d @technomancy initial commit
authored Nov 18, 2008
123 "Insert a lorem ipsum."
124 (interactive)
125 (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
126 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
127 "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut "
128 "aliquip ex ea commodo consequat. Duis aute irure dolor in "
129 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla "
130 "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
131 "culpa qui officia deserunt mollit anim id est laborum."))
132
ea2a11b @technomancy Add esk-suck-it defun thanks to David Leatherman.
authored Aug 11, 2011
133 (defun esk-suck-it (suckee)
134 "Insert a comment of appropriate length about what can suck it."
135 (interactive "MWhat can suck it? ")
136 (let ((prefix (concat ";; " suckee " can s"))
137 (postfix "ck it!")
138 (col (current-column)))
139 (insert prefix)
140 (dotimes (_ (- 80 col (length prefix) (length postfix))) (insert "u"))
141 (insert postfix)))
142
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
143 (defun esk-insert-date ()
e9a6168 @technomancy Bring clojure-mode up-to-date (add imenu), add M-x insert-date.
authored Jan 21, 2009
144 "Insert a time-stamp according to locale's date and time format."
145 (interactive)
146 (insert (format-time-string "%c" (current-time))))
147
3a979e0 @technomancy Add esk- prefixes; remove unneeded code.
authored Jul 22, 2010
148 (defun esk-pairing-bot ()
6c79eeb @technomancy Added pairing-bot function.
authored Dec 15, 2008
149 "If you can't pair program with a human, use this instead."
150 (interactive)
151 (message (if (y-or-n-p "Do you have a test for that? ") "Good." "Bad!")))
152
b418209 @technomancy Nonlisp paredit fixes; clojure-project bugfix.
authored Jul 20, 2009
153 (defun esk-paredit-nonlisp ()
154 "Turn on paredit mode for non-lisps."
8967c61 @technomancy Switch to using prog-mode-hook instead of our own coding-hook.
authored May 19, 2011
155 (interactive)
043ae0f @technomancy Fix esk-paredit-nonlisp for Paredit 22.
authored Dec 28, 2010
156 (set (make-local-variable 'paredit-space-for-delimiter-predicates)
157 '((lambda (endp delimiter) nil)))
b418209 @technomancy Nonlisp paredit fixes; clojure-project bugfix.
authored Jul 20, 2009
158 (paredit-mode 1))
159
71f9f3d @technomancy Make git annotate ignore whitespace.
authored Feb 19, 2009
160 ;; A monkeypatch to cause annotate to ignore whitespace
161 (defun vc-git-annotate-command (file buf &optional rev)
162 (let ((name (file-relative-name file)))
163 (vc-git-command buf 0 name "blame" "-w" rev)))
164
5fcb34d @technomancy initial commit
authored Nov 18, 2008
165 (provide 'starter-kit-defuns)
e3d337d Fixing mismatched parens in recompile-init
Alex Malinovich authored Dec 24, 2009
166 ;;; starter-kit-defuns.el ends here
Something went wrong with that request. Please try again.