summaryrefslogtreecommitdiffstats
path: root/.emacs.d/init.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-11-03 16:49:42 +0100
committerGravatar Tom Willemse2013-11-03 16:49:42 +0100
commit95fc334b2fcdb816cf5eb468d7fe54907a298f89 (patch)
tree65b838aad7fd50292f481f81a8f94794c62e1354 /.emacs.d/init.el
parent12d3ee93e777330bcf6902ebef65d026ef9393c2 (diff)
downloademacs-95fc334b2fcdb816cf5eb468d7fe54907a298f89.tar.gz
emacs-95fc334b2fcdb816cf5eb468d7fe54907a298f89.zip
Update emacs configuration
Diffstat (limited to '.emacs.d/init.el')
-rw-r--r--.emacs.d/init.el184
1 files changed, 66 insertions, 118 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index af4d432..93bc348 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -1,8 +1,10 @@
-;;; init.el --- My Emacs init
+;;; init.el --- My Emacs init -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
-(require 'uniquify)
+(eval-and-compile
+ (add-to-list 'load-path user-emacs-directory)
+ (load "init2"))
(eval-when-compile
(package-initialize)
@@ -12,7 +14,6 @@
(require 'esh-proc)
(require 'dash))
-(autoload 'gtags-mode "gtags" nil t)
(autoload 'jabber-connect "jabber" nil t)
(autoload 'jabber-message-libnotify "jabber-libnotify")
(autoload 'jabber-muc-libnotify "jabber-libnotify")
@@ -31,6 +32,12 @@
(defvar elnode-do-init)
(defvar whitespace-style)
(defvar eshell-prompt-regexp)
+(defvar sql-product)
+(defvar sql-prompt-regexp)
+
+(defvar init-stumpish-program
+ (expand-file-name
+ "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish"))
(defadvice org-agenda-redo (after ext:org-agenda-redo-add-appts)
"Pressing `r' on the agenda will also add appointments."
@@ -42,14 +49,35 @@
"Kill the term buffer if the process finished."
(kill-buffer (current-buffer)))
+(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 addf (place value)
"Prepend to PLACE VALUE."
`(setf ,place (cons ,value ,place)))
-(defmacro eval-after-init (&rest body)
- "Defer execution of BODY until after Emacs init."
+(defmacro stumpwm (&rest body)
+ "Execute BODY in stumpwm."
(declare (indent 0))
- `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+ `(call-process init-stumpish-program nil nil nil
+ ,(format "eval '%S'" `(progn ,@body))))
+
+(defun stumpwm-command (cmd)
+ "Execute CMD in stumpwm."
+ (call-process init-stumpish-program nil nil nil cmd))
+
+(defun init-augment-sql-prompt ()
+ "Add the MariaDB prompt to the `sql-pomrpt-regexp'."
+ (if (eq sql-product 'mysql)
+ (setq sql-prompt-regexp
+ (rx (and line-start
+ (or "mysql"
+ (and "MariaDB [" (1+ nonl) "]"))
+ "> ")))))
(defun init-eshell-C-d ()
"Either call `delete-char' interactively or quit."
@@ -65,6 +93,11 @@
"Make non-programming buffers a little more readable."
(setq line-spacing .2))
+(defun init-maybe-fci-mode ()
+ "Turn on `fci-mode' if there is a filename for the buffer."
+ (when (buffer-file-name)
+ (fci-mode)))
+
(defun init-set-keys-for-eshell ()
"Set some keybindings for `eshell'."
(local-set-key (kbd "C-d") #'init-eshell-C-d))
@@ -78,6 +111,12 @@
"Set some keybindings for `tagedit-mode'."
(local-set-key (kbd "M-k") #'tagedit-kill-attribute))
+(defun init-set-python-imenu-function ()
+ "Set the `imenu-create-index-function' variable.
+
+For `python-mode' I prefer `python-imenu-create-flat-index'."
+ (setq imenu-create-index-function #'python-imenu-create-flat-index))
+
(defmacro mode-hooks (&rest lst)
"Apply `add-mode-hooks' to each element of LST."
(declare (indent 0))
@@ -86,25 +125,6 @@
#'(lambda (itm)
(add-mode-hooks (car itm) (list 'quote (cadr itm)))) lst))))
-(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)))))))
-
(eval-and-compile
(defun add-hooks (hooks function &optional append local)
"`add-hook' for each in HOOKS."
@@ -138,13 +158,6 @@ FEATURE may be an unquoted feature symbol or a file name, see
(apply #'append lsts))))
(eval-and-compile
- (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))))
-
(defun make-mode-hook-name (mode)
"Get the hook name for MODE."
(intern (concat (symbol-name mode) "-mode-hook"))))
@@ -182,15 +195,6 @@ FEATURE may be an unquoted feature symbol or a file name, see
'face 'font-lock-function-name-face))
" \n> ")))
-(defun pp^L-ruler (win)
- "Just make a string ruler.
-
-Of either `fci-rule-column' or `fill-column' length -1. Use the
-`-' character. WIN is ignored."
- (ignore win)
- (make-string
- (1- (if (boundp 'fci-rule-column) fci-rule-column fill-column)) ?-))
-
(defun raise-eshell ()
"Start or switch back to `eshell'.
@@ -227,29 +231,10 @@ Also change directories to current working directory."
(local-set-key (kbd "M-J") 'sp-join-sexp)
(local-set-key (kbd "M-S") 'sp-split-sexp))
-(defun turn-off (modes)
- "Turn off each mode in MODES."
- (mapc (lambda (m) (funcall m -1)) modes))
-
(defun turn-on-compilation-shell-for-pony ()
"Turn on option `compilation-shell-minor-mode' for `pony-minor-mode'."
(add-hook 'pony-minor-mode-hook 'compilation-shell-minor-mode nil t))
-(defalias 'yes-or-no-p 'y-or-n-p)
-(defalias 'list-buffers 'ibuffer)
-(defalias 'dabbrev-expand 'hippie-expand)
-
-;; Get rid of annoying and useless
-(turn-off '(menu-bar-mode scroll-bar-mode tool-bar-mode blink-cursor-mode
- column-number-mode line-number-mode tooltip-mode))
-
-(eval-and-compile
- (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/eap" "/usr/share/emacs/site-lisp")))
-
(stante-after appt
(setq appt-disp-window-function #'oni:appt-display-window-and-jabber)
(setq appt-display-diary nil))
@@ -260,7 +245,6 @@ Also change directories to current working directory."
(stante-after auto-complete
(add-to-list 'ac-modes 'slime-repl-mode)
(setq-default ac-sources '(ac-source-imenu
- ac-source-gtags
ac-source-abbrev
ac-source-yasnippet
ac-source-words-in-buffer
@@ -270,7 +254,8 @@ Also change directories to current working directory."
ac-source-symbols
ac-source-variables
ac-source-features))
- (setq ac-auto-show-menu nil))
+ (setq ac-auto-show-menu nil
+ ac-use-quick-help nil))
(stante-after browse-url
(setq browse-url-browser-function 'browse-url-generic)
@@ -298,14 +283,15 @@ Also change directories to current working directory."
(stante-after custom
(setq custom-theme-directory "~/.emacs.d/themes")
- (eval-after-init (load-theme 'yoshi t)))
+ ;; (eval-after-init (load-theme 'yoshi t))
+ )
(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"
+ "dailies" "work" "tasks" "org"
(or "bookmarks.org"
"contacts.org")) eol))
(rx (or "*ielm*" "*-jabber-roster-*" "*eshell*"
@@ -318,7 +304,7 @@ Also change directories to current working directory."
desktop-clear-preserve-buffers))
(setq desktop-files-not-to-save
(rx (or (regexp "\\(^/[^/:]*:\\|(ftp)$\\)")
- (and "/" (or "dailies" "tasks" "bookmarks.org"
+ (and "/" (or "dailies" "tasks" "org" "bookmarks.org"
"contacts.org" "work") eol))))
(add-to-list 'desktop-globals-to-clear 'desktop-dirname))
@@ -403,19 +389,14 @@ Also change directories to current working directory."
(stante-after geiser-repl
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history"))
-(stante-after gnus
- (setq gnus-novice-user nil))
-
-(stante-after gnus-start
- (setq gnus-init-file "~/.emacs.d/gnus"))
-
(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 "migrations")
+ (add-to-list 'grep-find-ignored-files "TAGS"))
(stante-after help-at-pt
(setq help-at-pt-display-when-idle t))
@@ -431,10 +412,6 @@ Also change directories to current working directory."
(setq ido-max-window-height 1)
(setq ido-save-directory-list-file nil))
-(stante-after ido-ubiquitous
- (setq ido-ubiquitous-command-exceptions
- '(org-refile org-capture-refile)))
-
(stante-after imenu
(setq imenu-auto-rescan t))
@@ -477,8 +454,7 @@ Also change directories to current working directory."
'(("melpa" . "http://melpa.milkbox.net/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
- (setq package-load-list '((dispass "1.1.2.1")
- (desktop-registry "1.1.0")
+ (setq package-load-list '((dispass "1.1.2.2")
all)))
(stante-after "paragraphs"
@@ -489,10 +465,6 @@ Also change directories to current working directory."
(setq php-function-call-face 'font-lock-function-name-face)
(setq php-mode-force-pear t))
-(stante-after pp-c-l
- (setq pp^L-^L-string-function 'pp^L-ruler)
- (setq pp^L-^L-string-pre nil))
-
(stante-after sendmail
(setq send-mail-function 'sendmail-send-it)
(setq sendmail-program "/usr/bin/msmtp"))
@@ -500,9 +472,6 @@ Also change directories to current working directory."
(stante-after simple
(setq read-mail-command 'gnus))
-(stante-after slime
- (setq inferior-lisp-program "sbcl --noinform --no-linedit"))
-
(stante-after smartparens
(setq sp-cancel-autoskip-on-backward-movement nil
sp-autoskip-closing-pair 'always))
@@ -511,9 +480,6 @@ Also change directories to current working directory."
(setq smex-key-advice-ignore-menu-bar t)
(setq smex-save-file "~/.emacs.d/smex-items"))
-(stante-after smiley
- (setq smiley-style 'medium))
-
(stante-after "startup"
(setq inhibit-default-init t)
(setq inhibit-startup-message t)
@@ -530,9 +496,6 @@ Also change directories to current working directory."
(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 w3m
(setq w3m-fill-column 72))
@@ -566,7 +529,7 @@ Also change directories to current working directory."
((git-commit text) auto-fill-mode)
((git-commit text) flyspell-mode)
((html org prog) yas-minor-mode)
- ((html prog) fci-mode)
+ ((html prog) init-maybe-fci-mode)
((html) tagedit-mode)
((html) turn-off-flyspell)
((html) turn-off-auto-fill)
@@ -578,20 +541,18 @@ Also change directories to current working directory."
info org-agenda jabber-chat)
init-make-readable)
((prog) rainbow-delimiters-mode)
+ ((python) init-set-python-imenu-function)
((python) jedi:setup)
((python) subword-mode)
((slime slime-repl) set-up-slime-ac)
((smartparens) set-smartparens-keys)
+ ((sql-interactive) init-augment-sql-prompt)
((tagedit) tagedit-add-experimental-features)
((tagedit) tagedit-add-paredit-like-keybindings)
((tagedit) init-set-keys-for-tagedit)
((vala) oni:vala-mode-func))
-(add-hook 'emacs-startup-hook 'pretty-control-l-mode)
-(add-hook 'after-make-frame-functions
- '(lambda (arg) (pretty-control-l-mode)))
-
(setq-default bidi-paragraph-direction 'left-to-right)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
@@ -603,7 +564,7 @@ Also change directories to current working directory."
(vertical-scroll-bars . nil)
(menu-bar-lines . nil)
(tool-bar-lines . nil)
- (font . "PT Mono:pixelsize=16")))
+ (font . "PT Mono:pixelsize=15")))
(setq frame-title-format '(:eval (concat "emacs: " (buffer-name))))
(setq message-log-max 1000)
(setq redisplay-dont-pause t)
@@ -647,7 +608,6 @@ Also change directories to current working directory."
(add-hook 'css-mode-hook 'oni:css-mode-func)
(add-hook 'diary-display-hook 'oni:diary-display-func)
(add-hook 'go-mode-hook 'oni:go-mode-func)
-(add-hook 'gtags-mode-hook 'oni:gtags-mode-func)
(add-hook 'haskell-mode-hook 'oni:haskell-mode-func)
(add-hook 'java-mode-hook 'oni:java-mode-func)
(add-hook 'js-mode-hook 'oni:js-mode-func)
@@ -703,6 +663,7 @@ Also change directories to current working directory."
(global-set-key (kbd "C-c m") 'gnus)
(global-set-key (kbd "C-c g s") 'magit-status)
(global-set-key (kbd "C-c g i") 'magit-init)
+(global-set-key (kbd "C-c g b") 'magit-checkout)
(global-set-key (kbd "C-c h r") 'hypo-region)
(if (daemonp)
@@ -759,6 +720,7 @@ Depending on the value of `buffer-narrowed-p'."
"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)))
@@ -833,11 +795,6 @@ DOT are intentionally being skipped."
(setq indent-tabs-mode nil)
(local-set-key "\C-j" 'oni:newline-and-indent))
-(defun oni:gtags-mode-func ()
- "Function for `gtags-mode-hook'."
- (local-set-key "\M-," 'gtags-find-tag)
- (local-set-key "\M-." 'gtags-find-rtag))
-
(defun oni:haskell-mode-func ()
"Function for `haskell-mode-hook'."
(turn-on-haskell-indentation))
@@ -934,14 +891,12 @@ code. Found at http://xahlee.org/emacs/elisp_parse_time.html"
EMMS only shows me the absolute path of a song, this function
extracts the parts I want to know about."
- (let* ((song (emms-track-name (emms-playlist-current-selected-track)))
- (matchp (string-match "\\([^/]+\\)/\\([0-9]\\{4\\}\\) - \\(.+\\)/\\([0-9]\\{2,3\\}\\) - \\(.+\\)\\..\\{3,4\\}$" song))
- (band (substring song (match-beginning 1) (match-end 1)))
- (year (substring song (match-beginning 2) (match-end 2)))
- (album (substring song (match-beginning 3) (match-end 3)))
- (track (substring song (match-beginning 4) (match-end 4)))
- (title (substring song (match-beginning 5) (match-end 5))))
- (format "[%s - %s]" band title)))
+ (let ((song (emms-track-name (emms-playlist-current-selected-track))))
+ (if (string-match "\\([^/]+\\)/\\([0-9]\\{4\\}\\) - \\(.+\\)/\\([0-9]\\{2,3\\}\\) - \\(.+\\)\\..\\{3,4\\}$" song)
+ (let ((band (substring song (match-beginning 1) (match-end 1)))
+ (title (substring song (match-beginning 5) (match-end 5))))
+ (format "[%s - %s]" band title))
+ song)))
(defun oni:move-end-of-dwim ()
"Move to end of line, either before any comments or after."
@@ -1109,13 +1064,6 @@ insert at the end of the region and at the beginning."
(interactive)
(find-file "~/documents/org/index.org"))
-(defun oni:skip-ex-tag ()
- (let ((tags (org-entry-get (point) "TAGS")))
- (when (and tags (string-match-p ":ex:" tags))
- (save-excursion
- (org-forward-element)
- (point)))))
-
(defun oni:split-window-interactive (dir)
"Split windows in direction DIR.