Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Emacs word toggles
(defun capitalize-word-toggle ()
(let ((start (car
(bounds-of-thing-at-point 'symbol)))))
(if start
(goto-char start)
(if (char-upcasep (char-after))
start (1+ start)))
(capitalize-word -1))))
(defun upcase-word-toggle ()
(let ((bounds (bounds-of-thing-at-point 'symbol))
beg end
(if (eq this-command last-command)
(setq regionp (get this-command 'regionp))
(put this-command 'regionp nil))
((or (region-active-p) regionp)
(setq beg (region-beginning)
end (region-end))
(put this-command 'regionp t))
(setq beg (car bounds)
end (cdr bounds)))
(setq beg (point)
end (1+ beg))))
(goto-char (1- beg))
(and (re-search-forward "[A-Za-z]" end t)
(funcall (if (char-upcasep (char-before))
beg end)))))
(defun char-upcasep (letter)
(eq letter (upcase letter)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.