Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created February 26, 2009 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/70738 to your computer and use it in GitHub Desktop.
Save patmaddox/70738 to your computer and use it in GitHub Desktop.
(add-hook 'javascript-mode-hook
(lambda ()
(textmate-mode)
(local-set-key "\r"
(lambda () (interactive)
(insert-line-before-closing-braces)
(newline-and-indent)))))
(defun insert-line-before-closing-braces ()
(interactive)
(save-excursion
(let ((content (buffer-substring (point) (line-end-position))))
(if (and (> (length content) 0)
(string= (replace-regexp-in-string ")\\\|}" "" content) ""))
(newline-and-indent)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment