Skip to content

Instantly share code, notes, and snippets.

@edavis
Created June 26, 2011 03:48
Show Gist options
  • Save edavis/1047206 to your computer and use it in GitHub Desktop.
Save edavis/1047206 to your computer and use it in GitHub Desktop.
Emacs config
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/contrib/")
(setenv "PATH"
(concat (getenv "PATH")
":/usr/local/bin:/usr/local/texlive/2010/bin/universal-darwin/"))
;; https://github.com/marktran/color-theme-chocolate-rain
(progn
(require 'color-theme)
(load "themes/color-theme-chocolate-rain")
(color-theme-chocolate-rain))
(defun count-words ()
"Count the number of words either in the region or in the buffer."
(interactive)
(let ((start (if (use-region-p)
(region-beginning)
(point-min)))
(end (if (use-region-p)
(region-end)
(point-max)))
(n 0))
(save-excursion
(goto-char start)
(while (< (point) end)
(when (forward-word 1)
(setq n (1+ n)))))
(message "%d" n)))
(defun now ()
"Insert current timestamp in form of 05/31/11 11:58:28 AM"
(interactive)
(insert (format-time-string "%D %r")))
(global-set-key (kbd "\C-xp") 'hippie-expand)
(global-set-key (kbd "\C-c #") 'comment-dwim)
(global-set-key (kbd "\C-x SPC") 'just-one-space)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "\C-x\C-m") 'execute-extended-command)
(global-set-key (kbd "\C-c o") 'browse-url-at-point)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "\C-c \C-x a") 'align-regexp)
(setq html-mode-hook '(lambda ()
(turn-off-auto-fill)))
(setq LaTeX-mode-hook '(lambda ()
(TeX-PDF-mode 1)
(longlines-mode 1)
(preview-mode-setup)))
(setq after-save-hook '(lambda ()
(executable-make-buffer-file-executable-if-script-p)))
(setq Info-mode-hook '(lambda ()
(add-to-list 'Info-additional-directory-list "~/elisp/share/info/")))
(setq python-mode-hook '(lambda ()
(setq show-trailing-whitespace t)))
(setq shell-script-mode-hook '(lambda ()
(setq show-trailing-whitespace t)))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'blink-cursor-mode) (blink-cursor-mode -1))
(add-to-list 'auto-mode-alist '("\\.scss\\'" . css-mode))
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG" . diff-mode))
;; Don't wrap lines if they extend past the window border
(setq-default truncate-lines t)
(setq-default indent-tabs-mode nil)
(setq mac-command-modifier 'meta
ring-bell-function 'ignore
inhibit-splash-screen t
inhibit-startup-message t
vc-handled-backends nil
backup-inhibited t
auto-save-list-file-prefix "/tmp/saves-"
auto-save-default nil
vc-follow-symlinks t
custom-file "~/.emacs.d/custom.el"
kill-do-not-save-duplicates t
display-time-day-and-date t
confirm-kill-emacs 'yes-or-no-p)
(fset 'yes-or-no-p 'y-or-n-p)
(prefer-coding-system 'utf-8-unix)
(column-number-mode 1)
(line-number-mode 1)
(transient-mark-mode 1)
(show-paren-mode 1)
(display-time-mode 1)
;; Overwrite selected text when yanking
(delete-selection-mode 1)
(load custom-file)
(setq frame-title-format (list
'(:eval
(if buffer-file-name
(replace-regexp-in-string (getenv "HOME") "~" buffer-file-name)
(buffer-name)))
" - Emacs "
emacs-version))
(windmove-default-keybindings)
;; ---------------------------------------------------------------------------
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t
ido-create-new-buffer 'always)
(define-key ido-file-completion-map "\C-w" 'ido-delete-backward-updir)
(add-to-list 'load-path "~/elisp/share/emacs/site-lisp/")
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-hook 'org-mode-hook '(lambda ()
(auto-fill-mode 1)))
(setq org-hide-leading-stars t
org-return-follows-link t
org-read-date-prefer-future nil
org-agenda-include-diary nil
org-popup-calendar-for-date-prompt nil
org-odd-levels-only t
org-deadline-warning-days 21
org-agenda-span 'week
org-time-stamp-rounding-minutes '(0 0))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(require 'tramp)
(setq tramp-default-method "scp")
(when (equal (system-name) "Eric-Daviss-iMac.local")
(progn
(setq ispell-program-name "/usr/local/bin/aspell")
(add-to-list 'load-path "~/elisp")
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(set-face-attribute 'default nil :font "Monaco 18")
(add-to-list 'load-path "/usr/local/Cellar/git/1.7.4.4/share/doc/git-core/contrib/emacs")
(require 'git)))
(defun toggle-fullscreen-laptop (&optional f)
(interactive)
(let ((current-value (frame-parameter nil 'fullscreen)))
(set-frame-parameter nil 'fullscreen
(if (equal 'fullboth current-value)
(if (boundp 'old-fullscreen) old-fullscreen nil)
(progn (setq old-fullscreen current-value)
'fullboth)))))
(when (equal (system-name) "laptop")
(progn
(global-set-key (kbd "<f11>") 'toggle-fullscreen-laptop)
(setq battery-mode-line-format " [%b%p%%(%t)]")
(display-battery-mode)
(add-to-list 'load-path "/usr/share/doc/git-core/contrib/emacs/")
(require 'git)
(global-set-key (kbd "C-x g") 'git-status)))
(server-start)
;; Reminders:
;;
;; set-buffer-file-coding-system to change from DOS to UNIX
;; http://xahlee.org/emacs/emacs_line_ending_char.html
;;
;; flush-lines with '^$' to delete blank lines
;;
;; C-c C-t C-p -> toggles between DVI and PDF output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment