Skip to content

Instantly share code, notes, and snippets.

@taoeffect
Created July 7, 2010 17:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taoeffect/467011 to your computer and use it in GitHub Desktop.
Save taoeffect/467011 to your computer and use it in GitHub Desktop.
;; 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)
@makestuff
Copy link

Awesome, thanks for this Greg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment