legacy-dotfiles/emacs/.emacs.d/init.el

899 lines
29 KiB
EmacsLisp
Raw Normal View History

2014-08-21 00:23:56 +02:00
;;; init.el --- My Emacs init -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
2015-04-20 00:53:05 +02:00
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; (package-initialize)
(eval-when-compile
;; Just necessary for now, also included in init.org.
2014-08-21 00:23:56 +02:00
(require 'cask "~/projects/ext/cask/cask.el")
(cask-initialize)
2014-08-21 00:23:56 +02:00
(require 'cl)
(require 'dash)
(require 'esh-io)
(require 'esh-proc)
(require 'fill-column-indicator)
(require 'magit)
2015-05-02 17:23:34 +02:00
(require 'yasnippet)
(require 'ispell)
(require 'eww)
(require 'php-mode)
2015-07-26 22:02:54 +02:00
(require 'projectile)
2015-05-02 17:23:34 +02:00
(require 'slime)
(require 'smex))
2014-08-21 00:23:56 +02:00
(load (concat user-emacs-directory "init2"))
;;;; Autoloads
(autoload 'sawfish-mode "sawfish" nil t)
(autoload 'tagedit-mode "tagedit" nil t)
(autoload 'tern-mode "tern" nil t)
(autoload 'xmodmap-mode "xmodmap-mode" nil t)
2015-07-26 22:02:16 +02:00
(autoload 'rvm-activate-ruby-for "rvm")
2014-08-21 00:23:56 +02:00
;;;; Macros
(defmacro auto-init (library)
"Load a file for LIBRARY after loading the library.
The loaded file should be `LIBRARY-init', either `.el' or `.elc'
will do."
2015-05-09 19:12:55 +02:00
(let ((name (if (symbolp library)
(symbol-name library)
library)))
`(with-eval-after-load ',library
(load ,(concat name "-init")))))
2014-08-21 00:23:56 +02:00
;; http://www.lunaryorn.com/2013/06/25/introducing-with-eval-after-load/
(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))
`(,(if (or (not byte-compile-current-file)
(if (symbolp feature)
(require feature nil :noerror)
(load feature :no-message :no-error)))
`progn
(message "stante-after: cannot find %s" feature)
'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro oni:add-hooks (hook &rest functions)
"Add to HOOK each function in FUNCTIONS."
(declare (indent 1))
`(progn
,@(mapcar (lambda (func) `(add-hook ,hook ,func)) functions)))
(defmacro oni:add-function-to-hooks (func &rest hooks)
"Add FUNCTION to each hook in HOOKS."
(declare (indent 1))
`(progn
,@(mapcar (lambda (hook) `(add-hook ,hook ,func)) hooks)))
(defmacro oni:email (user at host dot com)
"Turn arguments into an email address.
The resulting email address will look like: USER@HOST.COM, AT and
DOT are intentionally being skipped."
(ignore at dot)
(concat (symbol-name user) "@" (symbol-name host) "."
(symbol-name com)))
(defmacro oni:eval-after-init (&rest body)
"Defer execution of BODY until after Emacs init."
(declare (indent 0))
`(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
(defmacro oni:link-modes (mode1 mode2)
"Whenever MODE1 is started, also start MODE2. Same for stopping.
If INVERSE is specified, make sure MODE2 is turned off whenever
MODE1 is enabled and vice-versa."
(let* ((mode1-name (symbol-name mode1))
(mode2-name (symbol-name mode2))
(function-name (intern (concat "toggle-" mode2-name
"-by-" mode1-name))))
`(progn
(defun ,function-name ()
,(concat "Toggle `" mode2-name "' according to the variable `"
mode1-name "'.")
(,mode2 (or ,mode1 -1)))
(add-hook ',(intern (concat mode1-name "-hook"))
#',function-name))))
(defmacro oni:exclude-modes (mode1 mode2)
"Whenever MODE1 is started, stop MODE2. Switch for stopping."
(let* ((mode1-name (symbol-name mode1))
(mode2-name (symbol-name mode2))
(function-name
(intern (concat "toggle-" mode2-name
"-inverse-of-" mode1-name))))
`(progn
(defvar ,mode1)
(defun ,function-name ()
,(concat "Toggle `" mode2-name
"' according to the inverse of `" mode1-name "'.")
(,mode2 (or (not ,mode1) -1)))
(add-hook ',(intern (concat mode1-name "-hook"))
#',function-name))))
;;;;; Vacuous
(defvar elnode-do-init)
(defvar eshell-prompt-regexp)
(defvar gnus-init-file)
(defvar sql-product)
(defvar sql-prompt-regexp)
(defvar whitespace-style)
(defvar *jabber-connected*)
(defvar *jabber-current-status*)
;;;; Functions
(defun oni:enable (functions)
"Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions))
(defun oni:show-org-index ()
"Show the index of my org files."
(interactive)
(find-file "~/documents/org/index.org"))
(defun oni:split-window-interactive (dir)
"Split windows in direction DIR.
Can also delete or switch to another window."
(interactive
(list (read-char "Direction (h,v,q,d,o): ")))
(case dir
((?v) (split-window-vertically))
((?h) (split-window-horizontally))
((?q) (delete-other-windows))
((?d) (delete-window))
((?o) (other-window 1))))
(defun oni:split-window-interactively (window)
"Ask for a direction and split WINDOW that way.
If no direction is given, don't split."
(let ((dir (read-char "Direction (h,v): ")))
(case dir
((?v) (split-window-vertically))
((?h) (split-window-horizontally))
(t window))))
(defun oni:start-python-test-mail-server ()
"Run the python test mailserver."
(interactive)
(start-process "python-test-mail-server" "*py-mail-server*" "python" "-m"
"smtpd" "-n" "-c" "DebuggingServer" "localhost:1025"))
(defun oni:stop-python-test-mail-server ()
"Stop the python test mailserver."
(interactive)
(kill-process "python-test-mail-server"))
(defun oni:switch-to-other-buffer ()
"Switch to the most recently viewed buffer."
(interactive)
(switch-to-buffer (other-buffer)))
(defun oni:term-mode-func ()
"Function for `term-mode-hook'."
(setq truncate-lines nil))
(defun oni:vala-mode-func ()
"Function for `vala-mode-hook'."
(setq indent-tabs-mode nil))
(defun oni:write-file-func ()
"Function for `write-file-hooks'."
(time-stamp))
(defun oni:yas-minor-mode-func ()
"Function for `yas-minor-mode-hook'."
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand))
2015-04-27 16:05:18 +02:00
(defun oni:outline-toggle-entry ()
(interactive)
(if (outline-on-heading-p)
(if (eql (save-excursion
(end-of-line)
(outline-invisible-p))
'outline)
(outline-show-entry)
(outline-hide-entry))))
(defun multiplication-table (number &optional upto)
2015-05-02 17:23:34 +02:00
"Print a multiplication table of NUMBER up to UPTO."
(interactive "nMultiplication table for: \nP")
(let ((upto (or upto 10))
(buffer (get-buffer-create "*Multiplication*")))
(with-current-buffer buffer
(erase-buffer)
(cl-loop for i from 1 to upto do (insert (format "%5d: %d\n" i (* number i)))))
(pop-to-buffer buffer)))
2015-07-26 22:02:16 +02:00
(defun oni:select-corresponding-ruby ()
(when (and (not (projectile-rails--ignore-buffer-p))
(projectile-rails-root))
(rvm-activate-ruby-for (projectile-rails-root))))
2014-08-21 00:23:56 +02:00
;;;; Module-specific settings
(auto-init appt)
(auto-init avandu)
2015-09-03 15:57:48 +02:00
(stante-after align
;; Keep these in order. They are each added to the _front_ of the
;; list and are applied in order. Changing their order will change
;; the results.
(add-to-list 'align-rules-list
'(css-closing-brace
(regexp . "\\([ \t]*\\)}$")
(group . (1))
(modes . '(scss-mode css-mode))))
(add-to-list 'align-rules-list
'(css-colons
(regexp . "[:;]\\([ \t]*\\)")
(group . (1))
(modes . '(scss-mode css-mode))
(repeat . t)))
(add-to-list 'align-rules-list
'(css-opening-brace
(regexp . "^[ \t]*[#.a-zA-Z0-9, &-]*[a-zA-Z0-9]\\([ \t]*\\){.*")
(group . (1))
(modes . '(scss-mode css-mode)))))
(stante-after auto-complete
(add-to-list 'ac-modes 'slime-repl-mode))
2014-08-21 00:23:56 +02:00
(stante-after "bindings"
(setq mode-line-default-help-echo ""))
(stante-after cc-vars
(setq-default c-basic-offset 4)
(setq c-offsets-alist
'((statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . 0)
(label . 0)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . +)
(arglist-close . 0)
(inline-open . 0)
(brace-list-open . +)
(topmost-intro-cont first c-lineup-topmost-intro-cont
c-lineup-gnu-DEFUN-intro-cont))))
2015-12-17 00:50:21 +01:00
(with-eval-after-load 'cc-mode
(define-key c-mode-map (kbd "<f9>") 'compile))
2015-09-03 15:56:18 +02:00
(stante-after circe
2015-10-03 00:19:21 +02:00
(require 'circe-init))
2015-09-03 15:56:18 +02:00
2014-08-21 00:23:56 +02:00
(stante-after compile
(setq compilation-scroll-output t))
(stante-after custom
(setq custom-theme-directory "~/.emacs.d/themes"))
(stante-after desktop
(setq desktop-restore-frames nil)
(setq desktop-load-locked-desktop t)
(setq desktop-clear-preserve-buffers
(append (list (rx (and bol (or (and "+" (1+ nonl))
"dailies" "work" "tasks" "org"
(or "bookmarks.org"
"contacts.org")) eol))
(rx (or "*ielm*" "*-jabber-roster-*" "*eshell*"
"*ansi-term*" "*slime-repl sbcl*"
"*slime-events*"))
(rx (and "*" (or "magit" "scratch-") (1+ nonl)
"*"))
(rx (or "irc.freenode.net:6667"
(and "#" (1+ nonl)))))
desktop-clear-preserve-buffers))
(setq desktop-files-not-to-save
(rx (or (regexp "\\(^/[^/:]*:\\|(ftp)$\\)")
(and "/" (or "dailies" "tasks" "org" "bookmarks.org"
"contacts.org" "work") eol))))
(add-to-list 'desktop-globals-to-clear 'desktop-dirname))
(stante-after eap
(setq eap-music-library "/mnt/music")
(setq eap-playlist-library "~/music/playlists"))
(stante-after ediff-wind
(setq ediff-window-setup-function 'ediff-setup-windows-plain))
(stante-after eltuki
(setq eltuki-blog-dir "~/documents/blog"))
(stante-after em-prompt
(setq eshell-highlight-prompt nil))
2014-08-21 00:23:56 +02:00
(stante-after em-term
(add-to-list 'eshell-visual-commands "unison"))
(stante-after emms
(emms-minimalistic)
(emms-default-players)
(require 'emms-player-mpd)
(require 'emms-mode-line))
(stante-after emms-mode-line
(emms-mode-line 1))
(stante-after emms-player-mpd
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-music-directory "/mnt/music/mp3"))
(stante-after esh-mode
(add-to-list 'eshell-output-filter-functions 'oni:eshell-buttonize-url)
2014-08-21 00:23:56 +02:00
(add-to-list 'eshell-output-filter-functions #'eshell-truncate-buffer))
(stante-after eww
2015-05-02 17:23:34 +02:00
(setq eww-download-directory ; Don't go to ~/Downloads
2014-08-21 00:23:56 +02:00
"~/downloads/"))
(stante-after files
(setq-default require-final-newline t)
(setq auto-mode-case-fold nil)
(setq auto-save-file-name-transforms
`((".*" "~/.local/share/emacs/autosave/" t)))
(setq backup-directory-alist
`((".*" . "~/.local/share/emacs/backup/")))
(setq auto-mode-alist
(append '(("/PKGBUILD$" . sh-mode)
(".install$" . sh-mode)
("\\.jl$" . sawfish-mode)
("\\.js\\(on\\)?$" . js2-mode)
("\\.m\\(ark\\)?d\\(?:o?wn\\)?$" . markdown-mode)
("\\.php[345]?$" . php-mode)
("\\.tm?pl$" . html-mode)
2015-04-20 01:01:02 +02:00
("^\\.Xmodmap$" . xmodmap-mode)
("^Cask$" . emacs-lisp-mode))
2014-08-21 00:23:56 +02:00
auto-mode-alist)))
(stante-after fill-column-indicator
(setq fci-rule-column 73))
(stante-after fiplr
(add-to-list 'fiplr-root-markers ".emacs.desktop")
(push "*.pyc" (cadr (assoc 'files fiplr-ignored-globs)))
(push "*.cache" (cadr (assoc 'files fiplr-ignored-globs)))
(push "*.elc" (cadr (assoc 'files fiplr-ignored-globs)))
(push ".emacs.desktop*" (cadr (assoc 'files fiplr-ignored-globs)))
(push ".cask" (cadr (assoc 'directories fiplr-ignored-globs)))
(push "migrations" (cadr (assoc 'directories fiplr-ignored-globs)))
(push "vendor-lisp" (cadr (assoc 'directories fiplr-ignored-globs))))
(stante-after geiser-repl
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history"))
(stante-after gnutls
(add-to-list
'gnutls-trustfiles
(expand-file-name "~/ssl_20130810/sub.class1.server.ca.pem")))
(stante-after grep
(add-to-list 'grep-find-ignored-directories "migrations")
(add-to-list 'grep-find-ignored-directories "vendor")
(add-to-list 'grep-find-ignored-directories "tmp")
(add-to-list 'grep-find-ignored-directories "log")
(add-to-list 'grep-find-ignored-files "TAGS"))
2015-09-03 15:58:47 +02:00
(stante-after helm
(setq helm-split-window-in-side-p t))
2014-08-21 00:23:56 +02:00
(stante-after help-at-pt
(setq help-at-pt-display-when-idle t))
(stante-after ido
(setq ido-ignore-buffers
2015-09-03 15:58:55 +02:00
(list "^\\` " "^irc\\." "^\\*Customize Option:"
2014-08-21 00:23:56 +02:00
(rx (or "*-jabber-roster-*" "*Messages*" "*fsm-debug*"
"*magit-process*" "*magit-edit-log*" "*Backtrace*"
"*Ibuffer*"))))
(setq ido-auto-merge-work-directories-length -1)
(setq ido-default-buffer-method 'pop-to-buffer)
(setq ido-max-window-height 1)
(setq ido-save-directory-list-file nil)
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil))
(stante-after imenu
(setq imenu-auto-rescan t))
(stante-after jabber (load "jabber-init"))
(stante-after jedi
(setq jedi:tooltip-method nil))
(stante-after jit-lock
(setq jit-lock-defer-time 0.2))
(stante-after message
(setq message-send-mail-function 'message-send-mail-with-sendmail)
(setq message-sendmail-extra-arguments '("-a" "ryuslash")))
(stante-after minibuf-eldef
(setq minibuffer-eldef-shorten-default t))
(stante-after mouse
(setq mouse-yank-at-point t))
(stante-after org
(require 'org-init)
(setq org-special-ctrl-a/e t))
(stante-after org2blog
(setq org2blog/wp-blog-alist
'(("ryublog"
:url "https://ryuslash.org/blog/xmlrpc.php"
:username "ryuslash"))))
(stante-after "paragraphs"
(setq sentence-end-double-space nil))
(stante-after php-mode
(setq-default php-mode-warn-if-mumamo-off nil)
(setq php-mode-force-pear t))
(stante-after prodigy
(prodigy-define-service
:name "Python test mailserver"
:command "python"
:args '("-m" "smtpd" "-n" "-c" "DebuggingServer" "localhost:1025")
:tags '(work mail)
:kill-process-buffer-on-stop t)
(prodigy-define-service
:name "Picturefix mollie-bank"
:command "mollie-bank"
2014-08-21 00:23:56 +02:00
:cwd "~/projects/work/photension/picturefix"
:tags '(work)
:kill-signal 'sigkill)
(prodigy-define-service
:name "Picturefix"
:command "rails"
:args '("server")
2014-08-21 00:23:56 +02:00
:cwd "~/projects/work/photension/picturefix"
:tags '(work)
:kill-signal 'sigkill)
(prodigy-define-service
:name "Picturefix sidekiq"
:command "sidekiq"
2014-08-21 00:23:56 +02:00
:cwd "~/projects/work/photension/picturefix"
:tags '(work)
2014-10-15 09:13:55 +02:00
:kill-signal 'sigkill)
(prodigy-define-service
:name "Picturefix mailcatcher"
:command "mailcatcher"
2014-10-15 09:13:55 +02:00
:cwd "~/projects/work/photension/picturefix"
:tags '(work)
2014-08-21 00:23:56 +02:00
:kill-signal 'sigkill))
(stante-after projectile-rails
(setq projectile-rails-expand-snippet nil))
2014-08-21 00:23:56 +02:00
(stante-after python-environment
(setcar python-environment-virtualenv "virtualenv2"))
(stante-after scheme
(require 'ac-geiser))
(stante-after sendmail
(setq send-mail-function 'sendmail-send-it)
(setq sendmail-program "/usr/bin/msmtp"))
(stante-after simple
(setq read-mail-command 'gnus)
(define-key special-mode-map "z" #'kill-this-buffer))
(with-eval-after-load 'slime
(setq slime-lisp-implementations
'((sbcl ("sbcl" "--noinform") :coding-system utf-8-unix)
(clisp ("clisp") :coding-system utf-8-unix))
slime-default-lisp 'sbcl))
(stante-after smex
(setq smex-save-file "~/.emacs.d/smex-items"))
(stante-after "startup"
(setq inhibit-default-init t)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil))
(stante-after tern
(require 'tern-auto-complete)
(tern-ac-setup))
2014-08-21 00:23:56 +02:00
(stante-after time-stamp
(setq time-stamp-active t)
(setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)"))
2015-09-28 23:10:28 +02:00
(stante-after tracking
(add-hook 'tracking-buffer-added-hook 'oni:update-mowedline-irclist)
(add-hook 'tracking-buffer-removed-hook 'oni:update-mowedline-irclist))
2014-08-21 00:23:56 +02:00
(stante-after type-break
(setq type-break-good-rest-interval (* 60 10))
(setq type-break-interval (* 60 50))
(setq type-break-keystroke-threshold '(nil . nil)))
(stante-after uniquify
(setq uniquify-buffer-name-style 'post-forward))
(stante-after "window"
(setq split-height-threshold 40)
2015-05-09 19:14:14 +02:00
(add-to-list 'display-buffer-alist
2015-11-09 14:06:49 +01:00
`(,(rx bol "*" (or (and (optional (one-or-more any) "-") "scratch*")
2015-12-17 00:40:24 +01:00
(and (or "magit:" "WoMan") " " (one-or-more any)))
2015-11-09 14:06:49 +01:00
eol)
2015-05-09 19:14:14 +02:00
display-buffer-same-window))
(add-to-list 'display-buffer-alist
`(,(rx bol "*" (or "Flycheck errors*"
(and (or "ielm" "eshell") "*" eol)))
oni:pop-to-buffer-in-side-window))
(add-to-list 'display-buffer-alist
`(,(rx bol "*server*" eol) display-buffer-in-side-window))
2014-08-21 00:23:56 +02:00
(add-to-list
'display-buffer-alist
2015-12-17 00:41:16 +01:00
'("^\\*Help\\*$" oni:pop-to-buffer-in-side-window))
2015-09-03 15:58:47 +02:00
(add-to-list
'display-buffer-alist
2015-12-17 00:41:16 +01:00
`(,(rx bol "*helm") display-buffer-in-side-window (side . right)))
(add-to-list
'display-buffer-alist
`(,(rx bol "*" (or "grunt" "compilation*"))
oni:pop-to-buffer-in-side-window)))
2014-08-21 00:23:56 +02:00
(stante-after woman
(setq woman-fill-column 72))
(stante-after yasnippet
(setq yas-fallback-behavior nil)
(setq yas-prompt-functions '(yas-ido-prompt)))
;;;; Hooks
(add-hook 'eshell-first-time-mode-hook 'oni-eshell-set-prompt)
2015-12-16 22:38:30 +01:00
;; Automatically make shell scripts executable after saving.
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p :append)
;; Delete tailing whitespace except in Markdown mode buffers.
(add-hook 'before-save-hook 'oni:delete-trailing-whitespace-unless-markdown)
;; Replace certain characters with html entities in HTML mode buffers.
(add-hook 'before-save-hook 'oni:replace-html-special-chars-in-html-mode)
2014-08-21 00:23:56 +02:00
(add-hook 'css-mode-hook #'rainbow-mode)
2015-12-17 01:04:01 +01:00
(add-hook 'diary-display-hook 'diary-fancy-display)
;; Make sure git commit messages are always checked in english.
(add-hook 'git-commit-mode-hook 'oni:set-ispell-local-en-dict)
2015-12-16 22:56:38 +01:00
(add-hook 'gnus-exit-group-hook 'oni:update-mailcount)
(add-hook 'gnus-exit-gnus-hook 'oni:update-mailcount)
2015-12-17 01:11:33 +01:00
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
2015-12-18 20:48:59 +01:00
;; Make tab toggle outlines on outline headings.
(add-hook 'outline-minor-mode-hook 'oni:set-tab-maybe-toggle-outline)
(add-hook 'scheme-mode-hook (lambda () (setq ac-sources '(ac-source-geiser))))
2014-08-21 00:23:56 +02:00
(add-hook 'slime-mode-hook #'set-up-slime-ac)
2015-12-16 22:47:43 +01:00
;; Support the prompt from MariaDB
(add-hook 'sql-interactive-mode-hook 'oni:augment-sql-prompt)
2014-08-21 00:23:56 +02:00
(add-hook 'term-mode-hook 'oni:term-mode-func)
(add-hook 'vala-mode-hook #'oni:vala-mode-func)
(add-hook 'write-file-hooks 'oni:write-file-func)
(add-hook 'yas-global-mode-hook 'oni:yas-minor-mode-func)
2015-04-08 15:04:58 +02:00
(add-hook 'ert-results-mode-hook (lambda () (setq truncate-lines nil)))
2015-04-27 16:04:17 +02:00
(add-hook 'ruby-mode-hook (lambda () (setq-local fci-rule-column 80)))
2015-09-28 23:12:50 +02:00
(add-hook 'projectile-rails-mode-hook (lambda () (define-key projectile-rails-mode-map (kbd "C-c r") 'hydra-projectile-rails/body)))
2015-07-26 22:03:24 +02:00
(add-hook 'projectile-mode-hook 'projectile-rails-on)
(add-hook 'ruby-mode-hook 'yard-mode)
(add-hook 'ruby-mode-hook 'eldoc-mode)
(add-hook 'ruby-mode-hook 'ruby-tools-mode)
(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch)
(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'projectile-after-switch-project-hook #'oni:select-corresponding-ruby)
2015-09-03 15:57:33 +02:00
(add-hook 'prog-mode-hook 'highlight-numbers-mode)
2015-12-17 00:42:32 +01:00
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
2014-08-21 00:23:56 +02:00
2015-12-18 00:31:39 +01:00
;; Set the FCI column to the PSR-2 recommended column
(add-hook 'php-mode-hook 'oni:set-psr2-margin)
;; Set the argument list opener and closer according to the PSR-2
;; recommendation.
(add-hook 'php-mode-hook 'oni:set-psr2-arglist-intro)
(add-hook 'php-mode-hook 'oni:set-psr2-arglist-close)
;; Notify me of the finished status of compilation.
(add-hook 'compilation-finish-functions 'oni:alert-compilation-finish)
;; Only autofill comments in programming buffers.
(add-hook 'prog-mode-hook 'oni:auto-fill-only-comments)
;; Set Python mode-specific keybindings.
(add-hook 'python-mode-hook 'oni:set-keys-for-python)
;; Set PEP 8 margin settings for Python
(add-hook 'python-mode-hook 'oni:set-pep8-margin)
(add-hook 'python-mode-hook 'oni:set-pep8-fill-column)
;; Make `whitespace-mode' show tabs
(add-hook 'python-mode-hook 'oni:set-whitespace-tab-display)
2015-12-18 20:21:24 +01:00
;; Set Dired-specific keybindings
(add-hook 'dired-mode-hook 'oni:set-keys-for-dired)
2015-12-18 00:39:29 +01:00
(oni:add-function-to-hooks 'oni:make-readable
2014-08-21 00:23:56 +02:00
'Info-mode-hook 'gnus-article-mode-hook 'gnus-group-mode-hook
'org-agenda-mode-hook)
(oni:add-function-to-hooks #'paredit-mode
'clojure-mode-hook 'geiser-repl-mode-hook 'sawfish-mode-hook
'scheme-mode-hook)
(oni:add-hooks 'emacs-lisp-mode-hook
(lambda ()
(setf ac-sources '(ac-source-emacs-lisp-features
ac-source-functions
ac-source-variables
ac-source-symbols)))
'oni:locally-enable-double-spaces 'oni:set-emacs-lisp-symbols
#'paredit-mode #'eldoc-mode 'oni:set-emacs-lisp-keys)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'eshell-mode-hook
2015-12-17 01:24:36 +01:00
#'buffer-disable-undo 'oni:set-keys-for-eshell
2014-08-21 00:23:56 +02:00
#'eshell-fringe-status-mode)
(oni:add-hooks 'gnus-summary-mode-hook
(lambda ()
(local-set-key (kbd "M-d") (lambda ()
(interactive)
(gnus-summary-delete-article)
(gnus-summary-next-subject 1)))))
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'html-mode-hook
2015-12-17 01:45:13 +01:00
'oni:maybe-fci-mode #'tagedit-mode #'turn-off-flyspell
2014-08-21 00:23:56 +02:00
#'turn-off-auto-fill)
(oni:add-hooks 'hy-mode-hook
2015-12-18 20:26:13 +01:00
#'paredit-mode 'oni:set-keys-for-hy)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'ielm-mode-hook
#'paredit-mode #'eldoc-mode 'oni:set-emacs-lisp-keys)
2014-08-21 00:23:56 +02:00
2015-12-18 20:29:53 +01:00
;; Bind Jabber chat-specific keys
(add-hook 'jabber-chat-mode-hook 'oni:set-keys-for-jabber-chat)
;; Make jabber chat buffers a little bit more readable
(add-hook 'jabber-chat-mode-hook 'oni:make-readable)
;; Reset the `default-directory' to my $HOME in jabber chat buffers.
(add-hook 'jabber-chat-mode-hook 'oni:reset-default-directory)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'js2-mode-hook
2015-04-21 21:40:14 +02:00
#'tern-mode #'moz-minor-mode)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'lisp-mode-hook
(lambda () (setf ac-sources '(ac-source-slime-simple)))
'oni:set-emacs-lisp-symbols #'paredit-mode)
2014-08-21 00:23:56 +02:00
2015-12-17 01:33:52 +01:00
(oni:add-hooks 'lua-mode-hook 'oni:set-keys-for-lua)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'markdown-mode-hook
#'whitespace-mode 'oni:show-trailing-whitespace)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'prog-mode-hook
'oni:maybe-fci-mode #'rainbow-delimiters-mode
2015-12-17 01:45:13 +01:00
'oni:maybe-prettify-symbols-mode)
2014-08-21 00:23:56 +02:00
;; Set autocompletion sources for Python
(add-hook 'python-mode-hook 'oni:set-python-completion-sources)
;; Set prettify-symbols symbols for Python
(add-hook 'python-mode-hook 'oni:set-python-symbols)
;; Use whitespace-mode in Python buffers
(add-hook 'python-mode-hook 'whitespace-mode)
;; Set the preferred imenu function for Python
(add-hook 'python-mode-hook 'oni:set-python-imenu-function)
;; Enable jedi in Python buffers
(add-hook 'python-mode-hook 'jedi:setup)
;; Enable subword-mode in Python buffers
(add-hook 'python-mode-hook 'subword-mode)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'slime-repl-mode-hook
2015-04-27 16:09:44 +02:00
#'paredit-mode #'set-up-slime-ac)
2014-08-21 00:23:56 +02:00
2015-12-18 20:38:07 +01:00
;; Use all the cool experimental tagedit features
(add-hook 'tagedit-mode-hook 'tagedit-add-experimental-features)
;; Make tagedit behave somewhat like tagedit.
(add-hook 'tagedit-mode-hook 'tagedit-add-paredit-like-keybindings)
;; Bind tagedit-specific keys
(add-hook 'tagedit-mode-hook 'oni:set-keys-for-tagedit)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'texinfo-mode-hook
2015-06-30 15:25:57 +02:00
#'outline-minor-mode)
2014-08-21 00:23:56 +02:00
(oni:add-hooks 'text-mode-hook
2015-12-18 00:39:29 +01:00
#'auto-fill-mode #'flyspell-mode 'oni:make-readable)
2014-08-21 00:23:56 +02:00
2015-12-18 21:03:50 +01:00
;; Load my theme
(if (daemonp)
(add-hook 'after-make-frame-functions 'oni:set-theme-graphically)
(add-hook 'emacs-startup-hook 'oni:set-theme))
2014-08-21 00:23:56 +02:00
;;;; Keybindings
(global-set-key (kbd "'") 'oni:self-insert-dwim)
(global-set-key (kbd "<XF86HomePage>") 'oni:raise-scratch)
(global-set-key (kbd "<XF86Mail>") 'gnus)
(global-set-key (kbd "<f10>") 'git-project-show-files)
2015-12-18 01:17:59 +01:00
(global-set-key (kbd "<f5>") 'oni:reload-buffer)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "<f7>") 'magit-status)
2015-12-18 01:09:53 +01:00
(global-set-key (kbd "<f8>") 'oni:raise-eshell)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "<hiragana>") 'oni:show-org-index)
(global-set-key (kbd "<next>") 'oni:scroll-up-or-next-page)
(global-set-key (kbd "<prior>") 'oni:scroll-down-or-prev-page)
(global-set-key (kbd "C-. C-.") #'oni:switch-to-other-buffer)
(global-set-key (kbd "C-<") 'indent-shift-left)
(global-set-key (kbd "C->") 'indent-shift-right)
(global-set-key (kbd "C-M-4") 'split-window-vertically)
(global-set-key (kbd "C-M-SPC") 'er/expand-region)
(global-set-key (kbd "C-M-d") 'kill-word)
(global-set-key (kbd "C-M-w") 'backward-kill-word)
(global-set-key (kbd "C-M-x") 'smex-major-mode-commands)
2015-12-17 01:15:30 +01:00
(global-set-key (kbd "C-M-z") 'oni:indent-defun)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "C-S-k") 'kill-whole-line)
2015-12-17 01:42:46 +01:00
(global-set-key (kbd "C-c +") 'oni:increase-number-at-point)
(global-set-key (kbd "C-c -") 'oni:decrease-number-at-point)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "C-c Q") #'delete-other-windows)
(global-set-key (kbd "C-c R") #'delete-window)
(global-set-key (kbd "C-c S") #'split-window-right)
2015-06-17 10:44:14 +02:00
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)
(global-set-key (kbd "C-c l") #'org-store-link)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "C-c d c") 'desktop-clear)
(global-set-key (kbd "C-c d d") 'desktop-registry-change-desktop)
(global-set-key (kbd "C-c d k") #'desktop-registry-remove-desktop)
(global-set-key (kbd "C-c d s") 'desktop-save-in-desktop-dir)
(global-set-key (kbd "C-c g b") 'magit-checkout)
(global-set-key (kbd "C-c g f") 'magit-fetch)
(global-set-key (kbd "C-c g i") 'magit-init)
(global-set-key (kbd "C-c g s") 'magit-status)
(global-set-key (kbd "C-c h r") 'hypo-region)
(global-set-key (kbd "C-c i p") 'identica-update-status-interactive)
(global-set-key (kbd "C-c m") 'gnus)
(global-set-key (kbd "C-c s") #'split-window-below)
(global-set-key (kbd "C-c t") 'oni:raise-ansi-term)
(global-set-key (kbd "C-c u") #'upcase-transient-mode)
(global-set-key (kbd "C-c w d") 'oni:downcase-prev)
(global-set-key (kbd "C-c w u") 'oni:upcase-prev)
(global-set-key (kbd "C-e") 'oni:move-end-of-dwim)
(global-set-key (kbd "C-x 4 f") #'fiplr-find-file-other-window)
(global-set-key (kbd "C-x 5 f") #'fiplr-find-file-other-frame)
(global-set-key (kbd "C-x 8 e") "")
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-x f") 'fiplr-find-file)
(global-set-key (kbd "M-0") 'delete-window)
(global-set-key (kbd "M-1") 'delete-other-windows)
(global-set-key (kbd "M-2") 'split-window-below)
(global-set-key (kbd "M-3") 'split-window-right)
(global-set-key (kbd "M-4") 'split-window-horizontally)
(global-set-key (kbd "M-n") 'idomenu)
(global-set-key (kbd "M-o") 'other-window)
(global-set-key (kbd "\"") 'oni:self-insert-dwim)
2015-12-18 00:17:05 +01:00
(global-set-key [remap move-beginning-of-line] 'oni:move-beginning-of-dwim)
2014-08-21 00:23:56 +02:00
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "M-+") 'mc/mark-next-like-this)
(global-set-key (kbd "M--") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
2015-07-26 22:04:16 +02:00
(global-set-key [remap query-replace-regexp] 'vr/query-replace)
2014-08-21 00:23:56 +02:00
2015-09-03 15:58:47 +02:00
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x b") 'helm-buffers-list)
(global-set-key (kbd "C-x r b") 'helm-bookmarks)
2015-09-28 23:13:17 +02:00
(global-set-key (kbd "C-x C-f") 'helm-find-files)
2015-09-03 15:58:47 +02:00
2015-07-26 22:04:57 +02:00
(setq org-completion-use-ido t)
(setq magit-completing-read-function 'magit-ido-completing-read)
(setq gnus-completing-read-function 'gnus-ido-completing-read)
(setq select-enable-primary t)
2015-09-03 15:58:47 +02:00
(setq projectile-completion-system 'helm)
2015-07-26 22:04:57 +02:00
;; Use the notifications library with alert.
(setq alert-default-style 'notifications)
2014-08-21 00:23:56 +02:00
;;;; Misc modes
(oni:enable '(downcase-region narrow-to-page narrow-to-region scroll-left
upcase-region))
(oni:link-modes outline-minor-mode persistent-outline-mode)
(oni:exclude-modes magit-blame-mode fci-mode)
(oni:eval-after-init
(require 'auto-complete-config)
(ac-config-default)
2014-08-21 00:23:56 +02:00
(ido-ubiquitous-mode)
(smex-initialize)
(global-diff-hl-mode)
(desktop-registry-auto-register)
(yas-global-mode)
2015-01-20 14:27:24 +01:00
(projectile-global-mode)
2015-09-03 15:57:33 +02:00
(hes-mode)
2014-08-21 00:23:56 +02:00
2015-07-26 22:05:35 +02:00
(global-wakatime-mode))
2014-08-21 00:23:56 +02:00
(with-eval-after-load 'ruby
(global-rinari-mode))
2015-05-02 17:23:34 +02:00
(when (equal (system-name) "drd")
2014-08-21 00:23:56 +02:00
(load "eap-autoloads"))
(auto-insert-mode)
(electric-indent-mode -1)
(ido-mode 1)
2015-07-26 22:05:47 +02:00
(ido-everywhere 1)
2014-08-21 00:23:56 +02:00
(minibuffer-electric-default-mode)
(savehist-mode)
(show-paren-mode)
(winner-mode)
(help-at-pt-set-timer)
(windmove-default-keybindings)
2015-05-02 17:23:34 +02:00
(load (system-name) :noerror)
(load "site-autoloads")
2014-08-21 00:23:56 +02:00
2015-04-20 01:01:23 +02:00
;;; Test
;; (defun my-special-buffer-predicate (buffer)
;; (string-prefix-p "*eshell*" (buffer-name buffer)))
;; (setq special-display-buffer-names
;; '(("*eshell*" (unsplittable . t) (buffer-predicate . my-special-buffer-predicate))))
(if (not (executable-find "hunspell"))
(warn "Hunspell is not installed, can't use it")
(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t))
2015-07-28 20:17:52 +02:00
(pinentry-start)
2014-08-21 00:23:56 +02:00
;;;; End
(provide 'init)
;;; init.el ends here