Skip to content

Instantly share code, notes, and snippets.

@cfx
Last active October 6, 2015 18:58
Show Gist options
  • Save cfx/3038719 to your computer and use it in GitHub Desktop.
Save cfx/3038719 to your computer and use it in GitHub Desktop.
latest emacs config
;; paths
(if (not (getenv "TERM_PROGRAM"))
(let ((path (shell-command-to-string
"$SHELL -cl \"printf %s \\\"\\\$PATH\\\"\"")))
(setenv "PATH" path)
(setq exec-path (split-string path ":"))))
;;remove vc-git
(setq vc-handled-backends ())
(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.
'(column-number-mode t)
'(js2-basic-offset 2)
'(scheme-program-name "mit-scheme")
'(show-paren-mode t))
;; lisp
(add-to-list 'load-path "~/Projects/slime/")
(setq inferior-lisp-program "/opt/boxen/homebrew/bin/clisp")
(require 'slime)
(slime-setup)
;; js2-mode
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;; keyboard
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
(global-set-key [(hyper h)] 'help-command)
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
(global-set-key (kbd "C-x O") (lambda ()
(interactive)
(other-window -1)))
;; Translate `C-h' to <DEL>.
(keyboard-translate ?\C-h ?\C-?)
;; Translate <DEL> to `C-h'.
(keyboard-translate ?\C-? ?\C-h)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(global-auto-revert-mode t)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
(setq confirm-kill-emacs 'yes-or-no-p)
(fset 'yes-or-no-p 'y-or-n-p)
(delete-selection-mode t)
(setq css-indent-offset 2)
(blink-cursor-mode t)
(show-paren-mode t)
(column-number-mode t)
(set-frame-font "Menlo-12")
(load-theme 'tango-dark)
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(require 'package)
(setq package-archives
(cons '("marmalade" . "http://marmalade-repo.org/packages/")
(cons '("tromey" . "http://tromey.com/elpa/")
package-archives)))
(package-initialize)
;; window size
(if window-system
(set-frame-size (selected-frame) 157 40)
(menu-bar-mode -1))
;; yaml-mode
(autoload 'yaml-mode "yaml-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))
;; ruby
(autoload 'ruby-mode "ruby-mode" nil t)
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(setq ruby-deep-arglist t)
(setq ruby-deep-indent-paren nil)
(setq c-tab-always-indent nil)
(add-hook 'ruby-mode-hook 'flymake-ruby-load)
;;(require 'inf-ruby)
;; rhtml
(add-to-list 'load-path "~/.emacs.d/git/rhtml")
(autoload 'rhtml-mode "rhtml-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.erb\\'" . rhtml-mode))
(add-to-list 'auto-mode-alist '("\\.handlebars\\'" . rhtml-mode))
(add-to-list 'auto-mode-alist '("\\.rjs\\'" . rhtml-mode))
;; indent after RET key
(defun newline-and-indent-for (modes)
(dolist (mode modes)
(add-hook mode '(lambda ()
(local-set-key (kbd "RET")
'newline-and-indent)))))
(newline-and-indent-for '(ruby-mode-hook css-mode-hook))
;; perl
(add-to-list 'auto-mode-alist '("\\.pp\\'" . perl-mode))
;; ack
(autoload 'ack-and-a-half-same "ack-and-a-half" nil t)
(autoload 'ack-and-a-half "ack-and-a-half" nil t)
(autoload 'ack-and-a-half-find-file-same "ack-and-a-half" nil t)
(autoload 'ack-and-a-half-find-file "ack-and-a-half" nil t)
;; Create shorter aliases
(defalias 'ack 'ack-and-a-half)
(defalias 'ack-same 'ack-and-a-half-same)
(defalias 'ack-find-file 'ack-and-a-half-find-file)
(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)
;; coffee
(setq whitespace-action '(auto-cleanup))
(setq whitespace-style '(trailing space-before-tab indentation empty space-after-tab))
;; ido
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(setq ido-create-new-buffer 'always)
;; sessions
(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.
)
(when window-system
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1))
;; automatically indenting yanked text if in programming-modes
(defvar yank-indent-modes '(emacs-lisp-mode lisp-mode ruby-mode
c-mode c++-mode js2-mode python-mode
tcl-mode sql-mode
perl-mode cperl-mode
java-mode jde-mode
;lisp-interaction-mode
LaTeX-mode TeX-mode
scheme-mode clojure-mode)
"Modes in which to indent regions that are yanked (or yank-popped)")
(defadvice yank (after indent-region activate)
"If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)."
(if (member major-mode yank-indent-modes)
(let ((mark-even-if-inactive t))
(indent-region (region-beginning) (region-end) nil))))
(defadvice yank-pop (after indent-region activate)
"If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)."
(if (member major-mode yank-indent-modes)
(let ((mark-even-if-inactive t))
(indent-region (region-beginning) (region-end) nil))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment