Last active
December 27, 2015 05:09
-
-
Save margnus1/7272485 to your computer and use it in GitHub Desktop.
My ever-growing emacs init file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(TeX-PDF-mode t) | |
'(adaptive-wrap-extra-indent 1) | |
'(c-basic-offset 4) | |
'(column-number-mode t) | |
'(cua-enable-cua-keys nil) | |
'(cua-mode t nil (cua-base)) | |
'(cua-remap-control-z nil) | |
'(custom-safe-themes (quote ("70ef61cc7736345eb1d2d449a9251e683625ba977f53a4d7cdbd4b9e81425b5e" default))) | |
'(display-battery-mode t) | |
'(fill-column 80) | |
'(indent-tabs-mode nil) | |
'(inhibit-startup-screen t) | |
'(latex-run-command "pdflatex") | |
'(mouse-drag-copy-region nil) | |
'(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/")))) | |
'(semantic-mode t) | |
'(show-paren-mode t) | |
'(show-trailing-whitespace t) | |
'(tab-width 4) | |
'(tool-bar-mode nil) | |
'(truncate-lines t) | |
'(whitespace-style (quote (face tabs trailing space-before-tab empty))) | |
'(word-wrap t)) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(rainbow-delimiters-depth-1-face ((t nil))) | |
'(rainbow-delimiters-depth-2-face ((t (:foreground "#7398f6")))) | |
'(rainbow-delimiters-depth-3-face ((t nil))) | |
'(rainbow-delimiters-depth-4-face ((t (:foreground "#75c878")))) | |
'(rainbow-delimiters-depth-5-face ((t nil))) | |
'(rainbow-delimiters-depth-6-face ((t (:foreground "#f0a093")))) | |
'(rainbow-delimiters-depth-7-face ((t nil))) | |
'(rainbow-delimiters-depth-8-face ((t (:foreground "#b286ef")))) | |
'(rainbow-delimiters-depth-9-face ((t nil))) | |
'(whitespace-tab ((t (:background "grey13" :foreground "grey22"))))) | |
;; This custom variable caused table headers to be too tall | |
;; '(face-font-family-alternatives (quote (("Impact" "Monospace" "courier" "fixed") ("courier" "CMU Typewriter Text" "fixed") ("Sans Serif" "helv" "helvetica" "arial" "fixed") ("helv" "helvetica" "arial" "fixed")))) | |
;; (add-to-list 'auto-coding-alist '(".*" . cp1252)) | |
(add-to-list 'load-path "C:/Program Files (x86)/emacs-24.2/site-lisp") | |
(add-to-list 'load-path "~/.emacs.d/site-lisp") | |
;;(add-to-list 'load-path "~/.emacs.d/site-lisp/tramp-2.2.7") | |
(setq backup-directory-alist | |
`((".*" . ,"C:/Users/Magnus/AppData/Roaming/.emacs.d/backups"))) | |
(setq auto-save-file-name-transforms | |
`((".*" ,"C:/Users/Magnus/AppData/Roaming/.emacs.d/backups" t))) | |
(message "Deleting old backup files...") | |
(let ((week (* 60 60 24 7)) | |
(current (float-time (current-time)))) | |
(dolist (file (directory-files temporary-file-directory t)) | |
(when (and (backup-file-name-p file) | |
(> (- current (float-time (fifth (file-attributes file)))) | |
week)) | |
(message file) | |
(delete-file file)))) | |
(message "Loading erlang-mode") | |
(setq load-path (cons "C:/Program Files/erl6.0/lib/tools-2.6.14/emacs" | |
load-path)) | |
(setq erlang-root-dir "C:/Program Files/erl5.10") | |
(setq exec-path (cons "C:/Program Files/erl5.10/bin" exec-path)) | |
(require 'erlang-start) | |
(message "Loading Haskell-Mode...") | |
(load "~/.emacs.d/site-lisp/haskell-mode/haskell-site-file") | |
;; Haskell files are always utf-8, but haskell-mode fails to configure this | |
(modify-coding-system-alist 'file "\\.hs\\'" 'utf-8) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) | |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) | |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) | |
(message "Loading color theme...") | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes") | |
(load-theme 'sunburst t) | |
(message "Loading linum-mode") | |
(global-linum-mode t) | |
(message "Loading...") | |
(global-set-key (kbd "<f11>") 'scroll-lock-mode) | |
(defun my-lisplike-hook () | |
(rainbow-delimiters-mode t)) | |
(add-hook 'lisp-mode-hook 'my-lisplike-hook) | |
(add-hook 'emacs-lisp-mode-hook 'my-lisplike-hook) | |
(add-hook 'racket-mode-hook 'my-lisplike-hook) | |
(defun dont-highlight-crap-hook () | |
(set-variable 'show-trailing-whitespace nil)) | |
(add-hook 'git-commit-mode-hook 'dont-highlight-crap-hook) | |
(add-hook 'diff-mode-hook 'dont-highlight-crap-hook) | |
(add-hook 'log-view-mode 'dont-highlight-crap-hook) | |
(if (eq (getenv "GOPATH") nil) | |
(setenv "GOPATH" "c:/users/magnus/go")) | |
(add-to-list 'exec-path (concat (getenv "GOPATH") "/bin")) | |
(defun my-go-mode-hook () | |
;;(linum-mode) | |
(require 'flycheck) | |
(flycheck-select-checker 'go-gofmt) | |
(set-variable 'flycheck-check-syntax-automatically '(save mode-enabled)) | |
(set-variable 'flycheck-highlighting-mode 'lines) | |
(flycheck-mode t)) | |
(add-hook 'go-mode-hook 'my-go-mode-hook) | |
;; (message "Loading php-mode...") | |
(setq auto-mode-alist (cons '("\\.php$" . php-mode) auto-mode-alist)) | |
(autoload 'php-mode "php-mode" "Major mode for editing PHP." t) | |
(add-hook 'scheme-mode-hook 'rainbow-delimiters-mode) | |
(add-to-list 'load-path "~/.emacs.d/elpa/powershell-mode") | |
(add-to-list 'auto-mode-alist '("\\.ps1$" . powershell-mode)) | |
(autoload 'powershell-mode "powershell-mode" "Major mode for editing Powershell files." t) | |
(autoload 'javacc-mode "javacc-mode" nil t) | |
(add-to-list 'auto-mode-alist '("\\.jj\\'" . javacc-mode)) | |
(add-to-list 'auto-mode-alist '("\\.jjt\\'" . javacc-mode)) | |
(autoload 'glsl-mode "glsl-mode" nil t) | |
(add-to-list 'auto-mode-alist '("\\.glsl\\'" . glsl-mode)) | |
(add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode)) | |
(add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode)) | |
(add-to-list 'auto-mode-alist '("\\.geom\\'" . glsl-mode)) | |
(autoload 'llvm-mode "llvm-mode" nil t) | |
(add-to-list 'auto-mode-alist '("\\.ll\\'" . llvm-mode)) | |
;; (message "Loading sml-mode") | |
(autoload 'sml-mode "sml-mode" "Major mode for editing SML." t) | |
(autoload 'run-sml "sml-proc" "Run an inferior SML process." t) | |
(add-to-list 'auto-mode-alist '("\\.\\(sml\\|sig\\)\\'" . sml-mode)) | |
(add-hook 'LaTeX-mode-hook 'auto-fill-mode) | |
(modify-coding-system-alist 'file "\\.nfo\\'" 'cp850) | |
;; (setq exec-path (cons "C:/Program Files/Git/bin/" exec-path)) | |
(when window-system | |
(global-set-key [(control z)] 'undo) | |
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease) | |
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase) | |
;;(require 'redo) | |
;; ;; (autoload 'redo "redo" "Script for performing redo." t) | |
;;(global-set-key [(control shift z)] 'redo) | |
) | |
(add-hook | |
'after-init-hook | |
(lambda () | |
;; (smart-tabs-add-language-support go go-mode-hook | |
;; (go-mode-indent-line . tab-width)) | |
;; (smart-tabs-insinuate 'go) | |
(smart-tabs-insinuate 'c) | |
(require 'multiple-cursors) | |
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) | |
;; CUA mode might make the first C-S-c into a C-c | |
(global-set-key (kbd "C-c C-S-c") 'mc/edit-lines) | |
(global-set-key (kbd "C->") 'mc/mark-next-symbol-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-symbol-like-this) | |
(global-set-key (kbd "C-M->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-M-<") 'mc/mark-previous-like-this) | |
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) | |
(global-set-key (kbd "M-S-<down>") 'mc/mark-next-lines) | |
(global-set-key (kbd "M-S-<up>") 'mc/mark-previous-lines) | |
;; M-drag for mc rectangle selection | |
;; Without delete-selection-mode, but with CUA, only the selection on the line | |
;; with the point is deleted. | |
(delete-selection-mode t) | |
(defun mouse-drag-rectangle (start-event) | |
"Highlight a rectangular region of text as the the mouse is dragged over it. | |
This must be bound to a button-down mouse event." | |
(interactive "e") | |
(let* ((start-posn (event-start start-event)) | |
(start-point (posn-point start-posn)) | |
(start-window (posn-window start-posn)) | |
(start-frame (window-frame start-window)) | |
(bounds (window-edges start-window)) | |
(top (nth 1 bounds)) | |
(bottom (if (window-minibuffer-p start-window) | |
(nth 3 bounds) | |
;; Don't count the mode line. | |
(1- (nth 3 bounds)))) | |
(click-count (1- (event-click-count start-event)))) | |
(setq mouse-selection-click-count click-count) | |
(mouse-set-point start-event) | |
(set-rectangular-region-anchor) | |
(let (end-event | |
end-posn | |
end-point | |
end-window) | |
(track-mouse | |
(while (progn | |
(setq end-event (read-event) | |
end-posn (event-end end-event) | |
end-point (posn-point end-posn) | |
end-window (posn-window end-posn)) | |
(or (mouse-movement-p end-event) | |
(eq (car-safe end-event) 'switch-frame))) | |
(cond | |
;; Ignore switch-frame events. | |
((eq (car-safe end-event) 'switch-frame) | |
nil) | |
;; Are we moving within the original window? | |
((and (eq end-window start-window) | |
(integer-or-marker-p end-point)) | |
(goto-char end-point) | |
;; (rm-highlight-rectangle start-point end-point) | |
(rrm/repaint) | |
) | |
;; Are we moving on a different window on the same frame? | |
((and (windowp end-window) | |
(eq (window-frame end-window) start-frame)) | |
(let ((mouse-row (+ (nth 1 (window-edges end-window)) | |
(cdr (posn-col-row end-posn))))) | |
(cond | |
((< mouse-row top) | |
(mouse-scroll-subr (- mouse-row top) | |
nil start-point)) | |
((and (not (eobp)) | |
(>= mouse-row bottom)) | |
(mouse-scroll-subr (1+ (- mouse-row bottom)) | |
nil start-point))))) | |
(t | |
(let ((mouse-y (cdr (cdr (mouse-position)))) | |
(menu-bar-lines (or (cdr (assq 'menu-bar-lines | |
(frame-parameters))) | |
0))) | |
;; Are we on the menu bar? | |
(and (integerp mouse-y) (< mouse-y menu-bar-lines) | |
(mouse-scroll-subr (- mouse-y menu-bar-lines) | |
nil start-point))))))) | |
(and (eq (get (event-basic-type end-event) 'event-kind) 'mouse-click) | |
(eq end-window start-window) | |
(numberp end-point) | |
(if (= start-point end-point) | |
(setq deactivate-mark t) | |
(push-mark start-point t t) | |
(goto-char end-point) | |
;;(mc/create-fake-cursor-at-point) | |
;;(rm-kill-ring-save start-point end-point) | |
;;(rrm/switch-to-multiple-cursors) | |
;;(kill-ring-save start-point end-point) | |
)) | |
))) | |
(global-unset-key (kbd "M-<mouse-1>")) | |
(global-unset-key (kbd "M-<drag-mouse-1>")) | |
(global-set-key (kbd "M-<down-mouse-1>") 'mouse-drag-rectangle) | |
)) | |
;; TRAMP windows bug circumvention kludge | |
;;(set 'tramp-rsh-end-of-line "\r") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment