From ea4856434c1e5edf3e1d50958c908ec3e5b152b5 Mon Sep 17 00:00:00 2001 From: Zachary Kanfer Date: Mon, 14 Sep 2015 15:04:32 -0400 Subject: [PATCH] Add functions for capitalizing text intelligently. This patch adds three functions: upcase-dwim, downcase-dwim, and capitalize-dwim. These functions change the capitalization of text the way the user probably wants -- they act on the region if it's active, and on the next word if the region isn't. --- lisp/simple.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lisp/simple.el b/lisp/simple.el index f80faae..e2d4470 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8424,6 +8424,35 @@ contains the list of implementations currently supported for this command." command-name))))))) +;;; Functions relating to capitalization that Do What I Mean +(defun upcase-dwim () + "Call the upcase command you want (Do What I Mean). +If the region is active, call `upcase-region'. Otherwise call +`upcase-word'." + (interactive "*") + (if (use-region-p) + (upcase-region (region-beginning) (region-end)) + (upcase-word 1))) + +(defun downcase-dwim () + "Call the downcase command you want (Do What I Mean). +If the region is active, call `downcase-region'. Otherwise call +`downcase-word'." + (interactive "*") + (if (use-region-p) + (downcase-region (region-beginning) (region-end)) + (downcase-word 1))) + +(defun capitalize-dwim () + "Call the capitalize command you want (Do What I Mean). +If the region is active, call `capitalize-region'. Otherwise call +`capitalize-word'." + (interactive "*") + (if (use-region-p) + (capitalize-region (region-beginning) (region-end)) + (capitalize-word 1))) + + (provide 'simple) -- 2.5.2