Skip to content

Instantly share code, notes, and snippets.

@Philonous
Created December 28, 2013 13:37
Show Gist options
  • Save Philonous/8159582 to your computer and use it in GitHub Desktop.
Save Philonous/8159582 to your computer and use it in GitHub Desktop.
(defun smart-hyphen (n)
"Capitalize the next word, or behave as the usual '-'."
(interactive "p")
(if (memq (get-text-property (point) 'face)
'(font-lock-doc-face
font-lock-comment-face
font-lock-string-face))
(self-insert-command n)
(progn (insert ?-)
(let ((next (read-char)))
(insert (if (eq ?w (char-syntax next))
(progn
(delete-char -1)
(upcase next))
next))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment