Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Last active December 11, 2015 06:18
Show Gist options
  • Save kristopherjohnson/4558310 to your computer and use it in GitHub Desktop.
Save kristopherjohnson/4558310 to your computer and use it in GitHub Desktop.
My .emacs
;; .emacs
;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)
;; Add MELPA package repository
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
)
(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.
'(auto-compression-mode t nil (jka-compr))
'(c-basic-offset 4)
'(c-default-style (quote ((c-mode . "stroustrup") (c++-mode . "stroustrup") (java-mode . "java") (other . "k&r"))))
'(case-fold-search t)
'(column-number-mode t)
'(compile-command "scons -u simvlt=1 simcentral=1")
'(current-language-environment "UTF-8")
'(custom-enabled-themes (quote (zenburn)))
'(custom-safe-themes (quote ("27470eddcaeb3507eca2760710cc7c43f1b53854372592a3afa008268bcf7a75" default)))
'(default-input-method "rfc1345")
'(delete-selection-mode t nil (delsel))
'(find-grep-options "-q")
'(global-font-lock-mode t nil (font-lock))
'(grep-command "grep -n -e ")
'(grep-find-command "find . -type f | egrep \"\\.cpp$|\\.c$|\\.h$|\\.m4$\" | xargs -e grep -n -e ")
'(indent-tabs-mode nil)
'(large-file-warning-threshold 250000000)
'(tool-bar-mode nil nil (tool-bar))
'(truncate-partial-width-windows nil))
(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.
'(default ((t (:inherit nil :background "#242424" :foreground "#f6f3e8" :weight normal :height 160 :family "Bitstream Vera Sans Mono")))))
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
;; Mac OS X setup
(setq-default mac-command-modifier 'meta) ;; Use Command key for Meta
(setq-default mac-option-modifier 'alt) ;; Use Option key for Alt
(global-set-key "\M-c" (quote kill-ring-save)) ;; M-c now emulates Mac "Copy" (Cmd-C)
(global-set-key "\M-v" (quote yank)) ;; M-v now emulates Mac "Paste" (Cmd-V)
;; set default window size to 40x132
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(width . 132))
(setq initial-frame-alist default-frame-alist)
(setq special-display-frame-alist default-frame-alist)
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" system-name))
;; default to unified diffs
(setq diff-switches "-u")
;; in C/C++ mode, indent and open indented new line
(defun c-return( ) (interactive) (c-indent-line) (newline-and-indent))
(add-hook
'c-mode-hook
'(lambda()
(local-set-key [13] 'c-return)
))
(add-hook
'c++-mode-hook
'(lambda()
(local-set-key [13] 'c-return)
))
;; M-0 M-.
(fset 'find-next-matching-tag
"\260\256")
(global-set-key [(control \,)] 'goto-line)
(global-set-key [(control \.)] 'call-last-kbd-macro)
(global-set-key [(control tab)] 'indent-region)
(global-set-key [(control j)] 'join-line)
;; (global-set-key [f1] 'man)
;; (global-set-key [f2] 'igrep-find)
;; (global-set-key [f3] 'shell)
;; (global-set-key [f4] 'next-error)
;; (global-set-key [f5] 'gdb)
;; (global-set-key [f6] 'compile)
;; (global-set-key [f7] 'recompile)
;; (global-set-key [f8] 'shell)
;; (global-set-key [f9] 'find-next-matching-tag)
;; (global-set-key [f11] 'list-buffers)
;; (global-set-key [f12] 'shell)
;; Python
(setq auto-mode-alist (cons '("SConstruct" . python-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("SConscript" . python-mode) auto-mode-alist))
(setq-default py-indent-offset 4)
;; Use C++ mode for .h files (instead of plain-old C mode)
(setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))
;; Parse CppUnit failure reports in compilation-mode
(require 'compile)
(setq compilation-error-regexp-alist
(cons '("\\(!!!FAILURES!!!\nTest Results:\nRun:[^\n]*\n\n\n\\)?\\([0-9]+\\)) test: \\([^(]+\\)(F) line: \\([0-9]+\\) \\([^ \n]+\\)" 5 4)
compilation-error-regexp-alist))
;; "M-x reload-buffer" will revert-buffer without requiring confirmation
(defun reload-buffer ()
"revert-buffer without confirmation"
(interactive)
(revert-buffer t t))
;; Enable cmake-mode from http://www.cmake.org/Wiki/CMake_Emacs_mode_patch_for_comment_formatting
;;(require 'cmake-mode)
;;(setq auto-mode-alist
;; (append '(("CMakeLists\\.txt\\'" . cmake-mode)
;; ("\\.cmake\\'" . cmake-mode))
;; auto-mode-alist))
;; Erlang
;;(setq load-path (cons "/usr/lib/erlang/lib/tools-2.5.2/emacs"
;; load-path))
;;(setq erlang-root-dir "/usr/lib/erlang")
;;(setq exec-path (cons "/usr/lib/erlang/bin" exec-path))
;;(require 'erlang-start)
;; PHP mode
(add-to-list 'load-path "~/elisp")
;;(require 'php-mode)
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment