;; Turn off mouse interface early in startup to avoid momentary display (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; No splash screen please ... (setq inhibit-startup-message t) ;; display tool tips in echo area only (tooltip-mode -1) (setq tooltip-use-echo-area t) ;; disable mouse scrolling (mouse-wheel-mode -1) (add-to-list 'load-path user-emacs-directory) (add-to-list 'load-path "/usr/share/emacs/site-lisp/") (require 'cask "~/.cask/cask.el") (cask-initialize) (require 'better-defaults) ;; Keep emacs Custom-settings in separate file (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (load custom-file) (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") '("marmalade" . "http://marmalade-repo.org/packages/")) (package-initialize) ; sublime-themes must be installed (load-theme 'spolsky t) (set-cursor-color "White") (setq evil-default-cursor '("white" box)) (set-background-color "#181818") ; smart mode line (setq sml/theme 'respectful) (sml/setup) (require 'visual-regexp-steroids) (define-key global-map (kbd "C-c r") 'vr/replace) (define-key global-map (kbd "C-c q") 'vr/query-replace) ;; use visual-regexp-steroids's isearch instead of the built-in regexp ;; isearch (define-key esc-map (kbd "C-r") 'vr/isearch-backward) ;; C-M-r (define-key esc-map (kbd "C-s") 'vr/isearch-forward) ;; C-M-s ; C-d on an empty line in the shell terminates the process. (defun comint-delchar-or-eof-or-kill-buffer (arg) (interactive "p") (if (null (get-buffer-process (current-buffer))) (kill-buffer) (comint-delchar-or-maybe-eof arg))) (add-hook 'shell-mode-hook (lambda () (define-key shell-mode-map (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer))) ;; TODO: this isn't working (add-hook 'term-mode-hook (lambda () (define-key term-mode-map (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer))) (add-hook 'haskell-mode-hook (lambda () (turn-on-haskell-indentation) (turn-on-haskell-doc))) ;; jump to first or last file in dired, not to the very top or bottom (require 'dired) (defun dired-back-to-top () (interactive) (beginning-of-buffer) (dired-next-line 4)) (define-key dired-mode-map (vector 'remap 'beginning-of-buffer) 'dired-back-to-top) (defun dired-jump-to-bottom () (interactive) (end-of-buffer) (dired-next-line -1)) (define-key dired-mode-map (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom) (define-key dired-mode-map (kbd "") 'dired-find-alternate-file) ; was dired-advertised-find-file (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) ; was dired-up-directory (require 'tramp) (setq tramp-default-method "ssh") ;; for root connections to remote hosts, log in via ssh with normal ;; user account first, then su/sudo to root (add-to-list 'tramp-default-proxies-alist '(".*" "\\`root\\'" "/ssh:%h:")) ;; Backup (file~) disabled and auto-save (#file#) locally to prevent delays in editing remote files (add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil)) (setq tramp-auto-save-directory temporary-file-directory) (setq tramp-verbose 3) ;; Write backup files to own directory ;; TODO: conflicts with previous manipulation of backup-directory-alist (setq backup-directory-alist `(("." . ,(expand-file-name (concat user-emacs-directory "backups"))))) ;; Make backups of files, even when they're in version control (setq vc-make-backup-files t) (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) (autoload 'js2-mode "js2-mode" nil t) (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) ;; full screen magit-status (require 'magit) (defadvice magit-status (around magit-fullscreen activate) (window-configuration-to-register :magit-fullscreen) ad-do-it (delete-other-windows)) (defun magit-quit-session () "Restores the previous window configuration and kills the magit buffer" (interactive) (kill-buffer) (jump-to-register :magit-fullscreen)) (defun magit-toggle-whitespace () "Toggles git option -w" (interactive) (if (member "-w" magit-diff-options) (magit-dont-ignore-whitespace) (magit-ignore-whitespace))) (defun magit-ignore-whitespace () "Adds git option -w" (interactive) (add-to-list 'magit-diff-options "-w") (magit-refresh)) (defun magit-dont-ignore-whitespace () "Removes git option -w" (interactive) (setq magit-diff-options (remove "-w" magit-diff-options)) (magit-refresh)) (define-key magit-status-mode-map (kbd "q") 'magit-quit-session) (define-key magit-status-mode-map (kbd "W") 'magit-toggle-whitespace) ;; ido mode (require 'ido) (ido-mode 1) ;; hit ~ to go straight to the home directory in ido mode (add-hook 'ido-setup-hook (lambda () ;; Go straight home (define-key ido-file-completion-map (kbd "~") (lambda () (interactive) (if (looking-back "/") (insert "~/") (call-interactively 'self-insert-command)))))) ;; Use ido everywhere (require 'ido-ubiquitous) (ido-ubiquitous-mode 1) ;; use ido for yes/no questions (ido-yes-or-no-mode 1) ;; fullscreen mode with F11 (fullscreen-mode 1) (global-set-key (kbd "") 'fullscreen-mode-fullscreen-toggle) (setq scss-compile-at-save nil) (global-whitespace-mode 1) (set-face-attribute 'whitespace-space nil :background nil :foreground "gray20") (set-face-attribute 'whitespace-newline nil :background nil :foreground "gray20") (setq whitespace-style '(face spaces tabs newline space-mark tab-mark newline-mark)) (setq whitespace-display-mappings ;; all numbers are Unicode codepoint in decimal. try ;; (insert-char 182 ) to see it '( (space-mark 32 [183] [46]) ; 32 SPACE, 183 MIDDLE DOT 「·」, ; 46 FULL STOP 「.」 (newline-mark 10 [182 10]) ; 10 LINE FEED (tab-mark 9 [9655 9] [92 9]) ; 9 TAB, 9655 WHITE ; RIGHT-POINTING TRIANGLE 「▷」 )) (desktop-save-mode t) ;; use cat as the pager in shell mode, because shell-mode is not an ANSI terminal (setenv "PAGER" "cat") ;; ediff settings (setq ediff-diff-options "-w") ;; TODO: what does this do? (put 'dired-find-alternate-file 'disabled nil) ;; cause Emacs to fully redraw the display *before* it processes queued input events. (setq redisplay-dont-pause t) ;; fewer backslashes in regexp builder (require 're-builder) (setq reb-re-syntax 'string) ;; remove prompt on killing process buffer (setq kill-buffer-query-functions (remq 'process-kill-buffer-query-function kill-buffer-query-functions)) ;; enable narrow-to-region feature (put 'narrow-to-region 'disabled nil) ;; http://blog.vivekhaldar.com/post/4809065853/dotemacs-extract-interactively-change-font-size (defun zoom-in () "Increase font size by 10 points" (interactive) (set-face-attribute 'default nil :height (+ (face-attribute 'default :height) 10))) (defun zoom-out () "Decrease font size by 10 points" (interactive) (set-face-attribute 'default nil :height (- (face-attribute 'default :height) 10))) ;; change font size, interactively (global-set-key (kbd "C-.") 'zoom-in) (global-set-key (kbd "C-,") 'zoom-out) ;; easier way to jump to other window (global-set-key (kbd "M-o") 'other-window) (require 'smex) (smex-initialize) (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "M-X") 'smex-major-mode-commands) (global-set-key (kbd "") 'smex) (global-set-key (kbd "S-") 'smex-major-mode-commands) ;; expand region (global-set-key (kbd "M-@") 'er/expand-region) ;; Swap C-t and C-x, so it's easier to type on Dvorak layout (keyboard-translate ?\C-t ?\C-x) (keyboard-translate ?\C-x ?\C-t) ;; kill current buffer (global-set-key (kbd "C-x C-k") (lambda () (interactive) (kill-buffer (current-buffer)))) (require 'shell-switcher) (setq shell-switcher-mode t) (add-hook 'eshell-mode-hook 'shell-switcher-manually-register-shell) (load "email.el") (require 'rekado-mode) (rekado-mode 1) ;; author: KaiGrossjohann on EmacsWiki (defun eshell/ff (&rest args) "Invoke `find-file' on the file. \"ff +42 foo\" also goes to line 42 in the buffer." (while args (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args)) (let* ((line (string-to-number (match-string 1 (pop args)))) (file (pop args))) (find-file file) (goto-line line)) (find-file (pop args)))))