From 3dd81b2efe906f664c0bca802058e525ed322a87 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 5 Oct 2021 08:32:54 -0500 Subject: Add spongebob-case Studlify is ... too complicated. --- lisp/acdw.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 792b9ef..e013fbc 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -793,6 +793,32 @@ This function is internal. Use `acdw/make-password-fetcher' instead." (insert "💩") (setq n (1- n))))) +(defun spongebob-case-region (beg end) + "Make region, defined by BEG and END, lOoK lIkE tHiS." + (interactive "*r") + (save-excursion + (let (case) + (goto-char beg) + (while (< (point) end) + (if (looking-at "[[:alpha:]]") + (if (setq case (not case)) + (upcase-region (point) (progn (forward-char 1) (point))) + (downcase-region (point) (progn (forward-char 1) (point)))) + (forward-char 1)))))) + +(defun spongebob-case-word (n) + "Spongebob-case N words forward, beginning at point, moving over." + (interactive "*p") + (spongebob-case-region (point) (progn (forward-word n) (point)))) + +(defun spongebob-case-dwim (arg) + "Spongebob-case words in the region if active, else word at point. +If ARG exists, it's passed to `spongebob-case-word'." + (interactive "*p") + (if (use-region-p) + (spongebob-case-region (region-beginning) (region-end)) + (spongebob-case-word arg))) + ;;; Fat finger solutions (defun acdw/fat-finger-exit (&optional prefix) -- cgit 1.4.1-21-gabe81