Created
July 7, 2010 17:57
-
-
Save taoeffect/467011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; add this to your ~/.emacs or ~/.emacs.d/init.el file | |
;; jump parens | |
(defun match-paren (arg) | |
(interactive "p") | |
(cond | |
((looking-at "\\s\(") (forward-list 1) (backward-char 1)) | |
((looking-at "\\s\)") (forward-char 1) (backward-list 1)) | |
((looking-at "\\s\{") (forward-list 1) (backward-char 1)) | |
((looking-at "\\s\}") (forward-char 1) (backward-list 1)) | |
(t (self-insert-command (or arg 1))) | |
) | |
) | |
;; this enables trailing parenthesis support | |
(defadvice lisp-indent-line (after my-lisp-indentation) | |
"makes close parens on their own line indent like C" | |
(interactive) ; NOT (interactive "p") | |
(let ((col-num)) | |
(save-excursion | |
(beginning-of-line) | |
(when (looking-at "^\\s-*\)") | |
(search-forward "\)") | |
(backward-sexp) | |
(setf col-num (current-column)) | |
(forward-sexp) | |
(backward-char) | |
(delete-region (line-beginning-position) (point)) | |
(indent-to col-num) | |
) | |
) | |
(if col-num (move-to-column col-num)) | |
) | |
) | |
(ad-activate 'lisp-indent-line) | |
(global-set-key "\C-j" 'match-paren) | |
(setq line-spacing 1) ; makes things a little less cluttered | |
(setq-default tab-width 4) | |
(setq-default indent-tabs-mode t) ; use tabs instead of spaces | |
(setq lisp-indent-offset 4) | |
(defalias 'sh-newline-and-indent 'newline-and-indent) | |
(defalias 'backward-delete-char-untabify 'backward-delete-char) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks for this Greg!