Skip to content

Instantly share code, notes, and snippets.

@billdozr
Last active October 10, 2015 10:57
Show Gist options
  • Save billdozr/3679559 to your computer and use it in GitHub Desktop.
Save billdozr/3679559 to your computer and use it in GitHub Desktop.
My .emacs file
;; =============================================================================
;; Emacs Lisp Packages
;; =============================================================================
;(require 'package)
;(add-to-list 'package-archives
; '("marmalade" . "http://marmalade-repo.org/packages/") t)
;(package-initialize)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
;; =============================================================================
;; Extra paths to load
;; =============================================================================
(add-to-list 'load-path "~/.emacs.d/ext_libs/")
;; =============================================================================
;; Unicode
;; =============================================================================
(message "Setting UTF-8 encoding")
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; =============================================================================
;; Tabbing customizations
;; =============================================================================
(setq-default indent-tabs-mode nil)
(setq default-tab-width 2)
;; =============================================================================
;; Visual customizations
;; =============================================================================
;; Theme
(load-theme 'deeper-blue)
;; Screen layout
(require 'cl)
(defun change-split-type-3-v (&optional arg)
"change 3 window style from horizon to vertical"
(interactive "P")
(change-split-type 'split-window-3-horizontally arg))
(defun change-split-type-3-h (&optional arg)
"change 3 window style from vertical to horizon"
(interactive "P")
(change-split-type 'split-window-3-vertically arg))
(defun split-window-3-horizontally (&optional arg)
"Split window into 3 while largest one is in horizon"
; (interactive "P")
(delete-other-windows)
(split-window-horizontally)
(if arg (other-window 1))
(split-window-vertically))
(defun split-window-3-vertically (&optional arg)
"Split window into 3 while largest one is in vertical"
; (interactive "P")
(delete-other-windows)
(split-window-vertically)
(if arg (other-window 1))
(split-window-horizontally))
(defun change-split-type (split-fn &optional arg)
"Change 3 window style from horizontal to vertical and vice-versa"
(let ((bufList (mapcar 'window-buffer (window-list))))
(select-window (get-largest-window))
(funcall split-fn arg)
(mapcar* 'set-window-buffer (window-list) bufList)))
(change-split-type-3-v t)
;; Remove tool-bar
(tool-bar-mode -1)
;; Remove scroll-bar
(scroll-bar-mode -1)
;; =============================================================================
;; Custom key bindings
;; =============================================================================
(defun other-window-backward ()
"Select the previous window."
(interactive)
(other-window -1))
(global-set-key "\C-xn" 'other-window)
(global-set-key "\C-xp" 'other-window-backward)
;; =============================================================================
;; Haskell
;; =============================================================================
(setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH")))
(add-to-list 'exec-path "~/.cabal/bin")
(setenv "PATH" (concat "~/Library/Haskell/ghc-7.6.3/lib/hasktags-0.69.0/bin:" (getenv "PATH")))
(add-to-list 'exec-path "~/Library/Haskell/ghc-7.6.3/lib/hasktags-0.69.0/bin")
(setenv "PATH" (concat "~/Library/Haskell/ghc-7.6.3/lib/stylish-haskell-0.5.10.2/bin:" (getenv "PATH")))
(add-to-list 'exec-path "~/Library/Haskell/ghc-7.6.3/lib/stylish-haskell-0.5.10.2/bin")
;(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;(setq haskell-program-name "/usr/bin/ghci")
(custom-set-variables '(haskell-tags-on-save t))
(require 'company)
(add-hook 'haskell-mode-hook 'company-mode)
(add-to-list 'company-backends 'company-ghc)
(custom-set-variables '(company-ghc-show-info t))
(autoload 'ghc-init "ghc" nil t)
(autoload 'ghc-debug "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;(custom-set-variables '(haskell-process-type 'cabal-repl))
(custom-set-variables
'(haskell-process-suggest-remove-import-lines t)
'(haskell-process-auto-import-loaded-modules t)
'(haskell-process-log t))
(eval-after-load 'haskell-mode '(progn
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
(define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
(define-key haskell-mode-map (kbd "C-c C-n C-t") 'haskell-process-do-type)
(define-key haskell-mode-map (kbd "C-c C-n C-i") 'haskell-process-do-info)
(define-key haskell-mode-map (kbd "C-c C-n C-c") 'haskell-process-cabal-build)
(define-key haskell-mode-map (kbd "C-c C-n c") 'haskell-process-cabal)
(define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)))
(eval-after-load 'haskell-cabal '(progn
(define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring)
(define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-ode-clear)
(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
(define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal)))
;; =============================================================================
;; OCaml
;; =============================================================================
;; Start Emacs from terminal in order to load `user` specific PATH:
;; /Applications/Emacs.app/Contents/MacOS/Emacs
;; otherwise `utop` executable is not found (Mac OS X quirk)
;; Update the emacs load path
(add-to-list 'load-path "~/.opam/4.01.0dev+trunk/share/emacs/site-lisp/")
;; Automatically load utop.el
(autoload 'utop "utop" "Toplevel for OCaml" t)
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-setup-ocaml-buffer)
;; =============================================================================
;; Lisp Stuff
;; =============================================================================
;; Clojure
;; -----------------------------------------------------------------------------
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
(add-to-list 'auto-mode-alist '("\\.cljs$" . clojurescript-mode))
(eval-after-load 'clojure-mode
'(define-clojure-indent
(exist 'defun)
(conde 'defun)
(conda 'defun)
(condu 'defun)
(matche 'defun)
(matcha 'defun)
(matchu 'defun)
(defne 'defun)
(defna 'defun)
(defnu 'defun)
(run 'defun)
(run* 'defun)
(run-nc 'defun)
(run-nc* 'defun)
(run-debug 'defun)
(run-debug* 'defun)
(project 'defun)
(nonrel/project 'defun)
(macro/symbol-macrolet 'defun)
(tabled 'defun)
(--> 'defun)
(-->e 'defun)
(defn--> 'defun)
(defn-->e 'defun)
(defmethod 'defun)))
;; =============================================================================
;; SBCL
;; -----------------------------------------------------------------------------
(setq inferior-lisp-program "/usr/local/bin/sbcl")
;; =============================================================================
;; Octave
;; -----------------------------------------------------------------------------
(add-to-list 'auto-mode-alist '("\\.m$" . octave-mode))
(setq inferior-octave-program "/usr/local/bin/octave")
;; =============================================================================
;; JavaScript
;; -----------------------------------------------------------------------------
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(require 'js-comint)
(setq inferior-js-program-command "/usr/bin/java -cp /Users/alen/Development/javascript/rhino1_7R4/js.jar org.mozilla.javascript.tools.shell.Main -opt -1")
(add-hook 'js2-mode-hook '(lambda ()
(local-set-key "\C-x\C-e" 'js-send-last-sexp)
(local-set-key "\C-\M-x" 'js-send-last-sexp-and-go)
(local-set-key "\C-cb" 'js-send-buffer)
(local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
(local-set-key "\C-cl" 'js-load-file-and-go)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment