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. --- init.el | 8 ++------ lisp/acdw.el | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/init.el b/init.el index 52eab26..a810370 100644 --- a/init.el +++ b/init.el @@ -386,16 +386,12 @@ (:with-map case-map (require 'titlecase) + (require 'acdw) (:bind "c" #'capitalize-dwim "t" #'titlecase-dwim "u" #'upcase-dwim "l" #'downcase-dwim - "s" (defun studlify-dwim (count) - "Studlify region if active, or COUNT words if not." - (interactive "*p") - (if (region-active-p) - (studlify-region (region-beginning) (region-end)) - (studlify-word count))))) + "s" #'spongebob-case-dwim)) (add-hook 'after-make-frame-functions (defun after-make-frame@maximize (frame) 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