summaryrefslogtreecommitdiffstats
path: root/.emacs.d/init.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/init.el')
-rw-r--r--.emacs.d/init.el198
1 files changed, 196 insertions, 2 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 3f1a90d..9a60f81 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -2,9 +2,203 @@
;;; Commentary:
;;; Code:
+(defmacro stante-after (feature &rest forms)
+ "After FEATURE is loaded, evaluate FORMS.
+
+FEATURE may be an unquoted feature symbol or a file name, see
+`eval-after-load'."
+ (declare (indent 1) (debug t))
+ ;; Byte compile the body. If the feature is not available, ignore
+ ;; warnings. Taken from
+ ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2012-11/msg01262.html
+ (let ((loaded (if (symbolp feature)
+ (require feature nil :no-error)
+ (load feature :no-error :no-message))))
+ `(,(if loaded
+ 'progn
+ (message "stante-after: cannot find %s" feature)
+ 'with-no-warnings)
+ (eval-after-load ',feature
+ `(funcall (function ,(lambda () ,@forms)))))))
+
+(defmacro eval-after-init (&rest body)
+ "Defer execution of BODY until after Emacs init."
+ (declare (indent 0))
+ `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+
(eval-and-compile
- (add-to-list 'load-path user-emacs-directory)
- (load "init2"))
+ (defun loadpath-add-and-autoload (path)
+ "Add PATH to `load-path' and load a `loaddefs.el' if it exists."
+ (add-to-list 'load-path path)
+ (let ((loaddefs (concat path "/loaddefs.el")))
+ (when (file-exists-p loaddefs)
+ (load loaddefs))))
+
+ (mapc #'loadpath-add-and-autoload
+ '("~/.emacs.d/site-lisp" "~/projects/emacs/pony-mode/src"
+ "~/.emacs.d/vendor-lisp/org/lisp"
+ "~/.emacs.d/vendor-lisp/org/contrib/lisp"
+ "~/.emacs.d/vendor-lisp/mozrepl"
+ "~/.emacs.d/vendor-lisp/eap" "/usr/share/emacs/site-lisp")))
+
+(defalias 'yes-or-no-p 'y-or-n-p)
+
+(defalias 'list-buffers 'ibuffer)
+
+(defalias 'dabbrev-expand 'hippie-expand)
+
+(require 'uniquify)
+
+(stante-after uniquify
+ (setq uniquify-buffer-name-style 'post-forward))
+
+(defvar gnus-init-file)
+(setq gnus-init-file "~/.emacs.d/site-lisp/gnus-init")
+
+(defmacro turn-off (&rest modes)
+ "Turn off each mode in MODES."
+ `(progn ,@(mapcar (lambda (m) `(,m -1)) modes)))
+
+(turn-off menu-bar-mode scroll-bar-mode tool-bar-mode blink-cursor-mode
+ column-number-mode line-number-mode tooltip-mode)
+
+(let ((theme (if (equal system-name "drd")
+ 'yoshi
+ 'leuven)))
+ (let ((setp (not (daemonp))))
+ (defun init-set-theme (frame)
+ "Try to set the theme for the current (first) frame."
+ (ignore frame)
+ (unless setp
+ (run-at-time .1 nil (lambda () (setq setp (load-theme theme t)))))))
+
+ (if (daemonp)
+ (add-hook 'after-make-frame-functions #'init-set-theme)
+ (eval-after-init (load-theme theme t))))
+
+(setq eww-download-path "~/downloads/")
+
+(defun init-locally-enable-double-spaces ()
+ (setq-local sentence-end-double-space t))
+
+(add-hook 'emacs-lisp-mode-hook #'init-locally-enable-double-spaces)
+
+(defun init-set-emacs-lisp-symbols ()
+ (when (boundp 'prettify-symbols-alist)
+ (setq prettify-symbols-alist
+ (append prettify-symbols-alist
+ '(("<=" . ?≤)
+ (">=" . ?≥)
+ ("sqrt" . ?√))))))
+
+(add-hook 'emacs-lisp-mode-hook #'init-set-emacs-lisp-symbols)
+
+(defun init-set-python-symbols ()
+ (when (boundp 'prettify-symbols-alist)
+ (setq prettify-symbols-alist
+ '(("lambda" . ?λ)
+ ("<=" . ?≤)
+ (">=" . ?≥)
+ ("!=" . ?≠)))))
+
+(add-hook 'python-mode-hook #'init-set-python-symbols)
+
+(when (and (>= emacs-major-version 24)
+ (> emacs-minor-version 3))
+ (add-hook 'prog-mode-hook 'prettify-symbols-mode))
+
+(stante-after slime
+ (setq slime-lisp-implementations
+ '((sbcl ("sbcl" "--noinform") :coding-system utf-8-unix)
+ (clisp ("clisp") :coding-system utf-8-unix))
+ slime-default-lisp 'sbcl))
+
+(set-fontset-font "fontset-default" 'unicode
+ (font-spec :family "Liberation Mono"
+ :width 'normal
+ :size 12.4
+ :weight 'normal))
+
+(defun sort-imports ()
+ (interactive)
+ (save-excursion
+ (sort-lines nil (1+ (search-backward "("))
+ (1- (search-forward ")")))))
+
+(stante-after simple
+ (define-key special-mode-map "z" #'kill-this-buffer))
+
+(defvar init-stumpish-program
+ (expand-file-name
+ "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish")
+ "The location of the stumpish executable.")
+
+(defun stumpwm-command (cmd)
+ "Execute CMD in stumpwm."
+ (call-process init-stumpish-program nil nil nil cmd))
+
+(defadvice windmove-do-window-select
+ (around init-windmove-stumpwm activate)
+ "If no window can be moved to, move stumpwm."
+ (condition-case err
+ ad-do-it
+ (error (stumpwm-command (format "move-focus %s" (ad-get-arg 0))))))
+
+(defmacro stumpwm (&rest body)
+ "Execute BODY in stumpwm."
+ (declare (indent 0))
+ `(call-process init-stumpish-program nil nil nil
+ ,(format "eval '%S'" `(progn ,@body))))
+
+(global-set-key (kbd "C-c S") #'split-window-right)
+(global-set-key (kbd "C-c s") #'split-window-below)
+(global-set-key (kbd "C-c Q") #'delete-other-windows)
+(global-set-key (kbd "C-c R") #'delete-window)
+
+(add-to-list 'load-path "/usr/lib/node_modules/tern/emacs/")
+(autoload 'tern-mode "tern" nil t)
+
+(stante-after tern
+ (require 'tern-auto-complete)
+ (tern-ac-setup))
+
+(add-hook 'js2-mode-hook #'tern-mode)
+
+(defun init-switch-to-other-buffer ()
+ "Switch to the most recently viewed buffer."
+ (interactive)
+ (switch-to-buffer (other-buffer)))
+
+(global-set-key (kbd "C-. C-.") #'init-switch-to-other-buffer)
+
+(stante-after woman
+ (setq woman-fill-column 72))
+
+(add-hook 'c-mode-hook #'smartparens-strict-mode)
+
+(autoload 'moz-minor-mode "moz" nil t)
+(add-hook 'javascript-mode-hook 'moz-minor-mode)
+
+(defun change-number-at-point (change-func)
+ "Use CHANGE-FUNC to change the number at `point'."
+ (let ((num (number-to-string (funcall change-func (number-at-point))))
+ (bounds (bounds-of-thing-at-point 'word)))
+ (save-excursion
+ (delete-region (car bounds) (cdr bounds))
+ (insert num))))
+
+(defun decrease-number-at-point ()
+ "Take the number at `point' and replace it with it decreased by 1."
+ (interactive)
+ (change-number-at-point #'1-))
+
+(defun increase-number-at-point ()
+ "Take the number at `point' and replace it with it increased by 1."
+ (interactive)
+ (change-number-at-point #'1+))
+
+(global-set-key (kbd "C-c -") #'decrease-number-at-point)
+(global-set-key (kbd "C-c +") #'increase-number-at-point)
(eval-when-compile
(package-initialize)