Subject: bug#21501: new Emacs functions for capitalizing text intelligently

From: Zachary Kanfer <[email-masked]>
Date: Sun, 20 Sep 2015 02:13:39 -0400

Here's a changed patch. The first line is the first line of the changelog
entry without "simple.el"; it doesn't fit.

I'm in favor of changing M-u, M-l, and M-c to the new commands; I think
it's much improved behavior. The only time a user would have to do more
work to perform a capitalization action is if they've selected a region,
but want to act only on the next word. I would bet that's rare, and even
so, the user only has to press C-g before the capitalization. So if we're
ok changing default commands, I think changing M-u, M-l, and M-c is a win.

On Sat, Sep 19, 2015 at 4:27 PM, Stefan Monnier <[email-masked]>
wrote:

> > I'm submitting some additional -dwim functions to that change the
> > capitalization of text the way the user probably wants.
>
> Looks OK to me.
>
> > Changelog entry:
> > * simple.el: Add functions for capitalizing text intelligently.
> > (capitalize-dwim): New function.
> > (upcase-dwim): New function.
> > (downcase-dwim): New function.
>
> Thanks.  Please add that to the commit message.  More specifically, use
> the first line above as the first line of the commit message, and add
>
>    (capitalize-dwim, upcase-dwim, downcase-dwim): New functions.
>
> at the end.
>
> I'm tempted to bind M-u, M-l, and M-c to those new commands.
>
> WDYT?
>
>
>         Stefan
>
From 70cc75c3e6ee2eb3c75d062ced5950ca36cb27d2 Mon Sep 17 00:00:00 2001
From: Zachary Kanfer <[email-masked]>
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.

(capitalize-dwim, upcase-dwim, downcase-dwim): New functions.
---
 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