Skip to content

Instantly share code, notes, and snippets.

Created March 15, 2018 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/f4f2c965b1ac26ba2d89e9986f1a9bf7 to your computer and use it in GitHub Desktop.
Save anonymous/f4f2c965b1ac26ba2d89e9986f1a9bf7 to your computer and use it in GitHub Desktop.
Auto-insert " * " in block comments in Emacs
(defun elmord-block-comment-auto-prefix ()
(when (eq last-command-event ?\n)
(let ((last-comment-start
(save-excursion (search-backward "/*" nil t)))
(last-comment-end
(save-excursion (search-backward "*/" nil t))))
(when (and last-comment-start
(or (null last-comment-end)
(> last-comment-start last-comment-end)))
(insert "* ")
(indent-for-tab-command)))))
(add-hook 'scala-mode-hook
(defun elmord-scala-mode-hook ()
(add-hook 'post-self-insert-hook
'elmord-block-comment-auto-prefix
nil t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment