Skip to content

Instantly share code, notes, and snippets.

@etscrivner
Created March 28, 2012 01:36
Show Gist options
  • Save etscrivner/2222728 to your computer and use it in GitHub Desktop.
Save etscrivner/2222728 to your computer and use it in GitHub Desktop.
My emacs config
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs Configuration
;; Author: Eric Scrivner
;;
;; Description:
;; My emacs preferences
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'cl)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs Path Info
(defvar emacs-root "/Users/eric/")
(labels ((add-path (p)
(add-to-list 'load-path
(concat emacs-root p))))
(add-path ".emacs.d/")
(add-path ".emacs.d/lisp/")
(add-path ".emacs.d/icicles/")
(add-path ".emacs.d/color-theme/")
(add-path ".emacs.d/plugins/yasnippet/"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; YASnippet
(require 'yasnippet)
(yas/global-mode 1)
(require 'php-mode)
(require 'coffee-mode)
(require 'mustache-mode)
(require 'less-mode)
(setq ido-enable-flex-matching t)
(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
;; (let ((buffer (url-retrieve-synchronously
;; "http://tromey.com/elpa/package-install.el")))
;; (save-excursion
;; (set-buffer buffer)
;; (goto-char (point-min))
;; (re-search-forward "^$" nil 'move)
;; (eval-region (point) (point-max))
;; (kill-buffer (current-buffer))))
;; (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;;(require 'icicles)
;;(icy-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Better PHP-Mode
(defun clean-php-mode ()
(interactive)
(php-mode)
(setq c-basic-offset 2) ; 2 tabs indenting
(setq indent-tabs-mode nil)
(setq fill-column 78)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-close 'c-lineup-arglist-operators)
(c-set-offset 'arglist-intro '+) ; for FAPI arrays and DBTNG
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math) ; for DBTNG fields and values
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Color Theming
(require 'color-theme)
(load "~/.emacs.d/color-theme-almost-monokai")
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-almost-monokai)))
(color-theme-almost-monokai)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Key Bindings
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
(global-set-key "\M-g" 'goto-line)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GUI Settings
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Registers
(set-register ?e '(file . "~/.emacs"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Editor Miscellaneous
(prefer-coding-system 'utf-8)
(ido-mode t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq line-number-mode t)
(setq column-number-mode t)
(setq c-default-style "linux"
c-basic-offset 1)
(setq-default c-basic-offset 2
tab-width 2
indent-tabs-mode nil)
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(display-time-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Startup
(load "~/.emacs.d/max-frame")
(defvar maxframe-maximized-p nil "maxframe is in fullscreen mode")
(defun toggle-maxframe ()
"Toggle maximized frame"
(interactive)
(setq maxframe-maximized-p (not maxframe-maximized-p))
(cond (maxframe-maximized-p (maximize-frame))
(t (restore-frame))))
(defun toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen (if (frame-parameter nil 'fullscreen)
nil 'fullboth)))
(toggle-maxframe)
(split-window-horizontally)
(shell)
(server-start)
(add-hook 'emacs-startup-hook 'set-initial-buffers)
(defun set-initial-buffers ()
(switch-to-buffer "*shell*")
(kill-buffer "*GNU Emacs*"))
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file name new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment