about summary refs log tree commit diff
path: root/emacs.d/init-functions.el
diff options
context:
space:
mode:
authorVincent Ambo <vincent@spotify.com>2013-07-07T23·15+0200
committerVincent Ambo <vincent@spotify.com>2013-07-07T23·15+0200
commit0d133eceb395d44b7a234b5f455d9d92bba43f4e (patch)
tree10c09f8a56fdeb900e2ba62ba944642ad39838a9 /emacs.d/init-functions.el
parent90f95a6a3dd5a95a3df315a9dfcdf8ea94d59104 (diff)
Split up configuration in five files. I wrote a nice commit message explaining this, but I wrote it in vi and it died on me.
Diffstat (limited to 'emacs.d/init-functions.el')
-rw-r--r--emacs.d/init-functions.el53
1 files changed, 53 insertions, 0 deletions
diff --git a/emacs.d/init-functions.el b/emacs.d/init-functions.el
new file mode 100644
index 000000000000..5ede8ee7dc1d
--- /dev/null
+++ b/emacs.d/init-functions.el
@@ -0,0 +1,53 @@
+;; A few handy functions I use in init.el (or not, but they're nice to
+;; have)
+
+;; Ensure that the themes folder exists
+
+(defun custom-download-theme (url filename)
+  "Downloads a theme through HTTP and places it in ~/.emacs.d/themes"
+
+  ;; Ensure the directory exists
+  (unless (file-exists-p "~/.emacs.d/themes")
+    (make-directory "~/.emacs.d/themes"))
+
+  ;; Adds the themes folder to the theme load path (if not already
+  ;; there)
+  (unless (member "~/.emacs.d/themes" custom-theme-load-path)
+    (add-to-list 'custom-theme-load-path "~/.emacs.d/themes"))
+ 
+  ;; Download file if it doesn't exist.
+
+  (let ((file
+         (concat "~/.emacs.d/themes/" filename)))
+    (unless (file-exists-p file)
+      (url-copy-file url file))))
+
+
+;; These come from the emacs starter kit
+(defun esk-pretty-lambdas ()
+  (font-lock-add-keywords
+   nil `(("(?\\(lambda\\>\\)"
+          (0 (progn (compose-region (match-beginning 1) (match-end 1)
+                                    ,(make-char 'greek-iso8859-7 107))
+                    nil))))))
+
+(defun esk-add-watchwords ()
+  (font-lock-add-keywords
+   nil '(("\\<\\(FIX\\(ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\)"
+          1 font-lock-warning-face t))))
+
+(defun esk-sudo-edit (&optional arg)
+  (interactive "p")
+  (if (or arg (not buffer-file-name))
+      (find-file (concat "/sudo:root@localhost:" (ido-read-file-name "File: ")))
+    (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
+
+(defun esk-suck-it (suckee)
+  "Insert a comment of appropriate length about what can suck it."
+  (interactive "MWhat can suck it? ")
+  (let ((prefix (concat ";; " suckee " can s"))
+        (postfix "ck it!")
+        (col (current-column)))
+    (insert prefix)
+    (dotimes (_ (- 80 col (length prefix) (length postfix))) (insert "u"))
+    (insert postfix)))