;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/case.el (defun upcase-p (char) (and (numberp char) (<= ?A char) (<= char ?Z) )) (defun downcase-p (char) (and (numberp char) (<= ?a char) (<= char ?z) )) (defun ucase (beg end) (interactive (if (region-active-p) (list (region-beginning) (region-end)) (list (point) (+ (point) (or (and (listp current-prefix-arg) (car current-prefix-arg) ) current-prefix-arg 1) )))) (upcase-region beg end) ) (defun ccase (beg end) (let*((str (buffer-substring-no-properties beg end)) (chars (string-to-list str)) (new) ) (dolist (c chars) (push (cond ((upcase-p c) (downcase c)) ((downcase-p c) (upcase c)) (t c) ) new)) (delete-region beg end) (dolist (c (nreverse new)) (insert c) ))) (provide 'case)