all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Zachary Kanfer <zkanfer@gmail.com>
To: rms@gnu.org
Cc: 21501@debbugs.gnu.org
Subject: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Mon, 21 Sep 2015 14:52:01 -0400	[thread overview]
Message-ID: <CAFXT+RP89DEQXj3_4SzXfL4eyZfrmsrM_zSsqah1n679Lg=jEQ@mail.gmail.com> (raw)
In-Reply-To: <E1ZdjHJ-0006NT-1i@fencepost.gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1297 bytes --]

Here's an updated patch with Eli's comments addressed. Now, these new
commands seem to have all the functionality of the existing *-region and
*-word commands.

Is the "dwim" acronym well known enough as "Do What I Mean" that that it
doesn't need to be included in the docstring? I can put it in if necessary,
but it's somewhat awkward.

I'm fine putting these commands in Emacs, and waiting to see if people like
them enough that it's worth changing the bindings. Is there any specific
user feedback or data we'd be looking for to know if we want to change the
bindings? Or is it more a concern of waiting to see if any bugs shake out?

On Sun, Sep 20, 2015 at 2:23 PM, Richard Stallman <rms@gnu.org> wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I'm tempted to bind M-u, M-l, and M-c to those new commands.
>
> Please let's try them privately first.  There is no need to be
> precipitous about this.  There is no hurry.
>
> --
> Dr Richard Stallman
> President, Free Software Foundation (gnu.org, fsf.org)
> Internet Hall-of-Famer (internethalloffame.org)
> Skype: No way! See stallman.org/skype.html.
>
>

[-- Attachment #1.2: Type: text/html, Size: 2097 bytes --]

[-- Attachment #2: 0003-Add-functions-for-capitalizing-text-intelligently.patch --]
[-- Type: text/x-patch, Size: 2188 bytes --]

From cbc9d4691cb9dfce670f9ce07178d4d29e99a562 Mon Sep 17 00:00:00 2001
From: Zachary Kanfer <zkanfer@gmail.com>
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 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/lisp/simple.el b/lisp/simple.el
index f80faae..24732e1 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8424,6 +8424,38 @@ contains the list of implementations currently supported for this command."
                            command-name)))))))
 
 \f
+;;; Functions for changing capitalization that Do What I Mean
+(defun upcase-dwim (arg)
+  "Upcase words in the region, if active.  If not, upcase word at point.
+If the region is active, this function calls `upcase-region'.
+Otherwise, it calls `upcase-word', with prefix argument passed to it
+to upcase ARG words."
+  (interactive "*p")
+  (if (use-region-p)
+      (upcase-region (region-beginning) (region-end))
+    (upcase-word arg)))
+
+(defun downcase-dwim (arg)
+    "Downcase words in the region, if active.  If not, downcase word at point.
+If the region is active, this function calls `downcase-region'.
+Otherwise, it calls `downcase-word', with prefix argument passed to it
+to downcase ARG words."
+  (interactive "*p")
+  (if (use-region-p)
+      (downcase-region (region-beginning) (region-end))
+    (downcase-word arg)))
+
+(defun capitalize-dwim (arg)
+  "Capitalize words in the region, if active.  If not, capitalize word at point.
+If the region is active, this function calls `capitalize-region'.
+Otherwise, it calls `capitalize-word', with prefix argument passed to it
+to capitalize ARG words."
+  (interactive "*p")
+  (if (use-region-p)
+      (capitalize-region (region-beginning) (region-end))
+    (capitalize-word arg)))
+
+\f
 
 (provide 'simple)
 
-- 
2.5.2


  reply	other threads:[~2015-09-21 18:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17  4:32 bug#21501: new Emacs functions for capitalizing text intelligently Zachary Kanfer
2015-09-19 20:27 ` Stefan Monnier
2015-09-20  6:13   ` Zachary Kanfer
2015-09-20  6:46     ` Eli Zaretskii
2015-09-20 18:23   ` Richard Stallman
2015-09-21 18:52     ` Zachary Kanfer [this message]
2015-09-26  8:13       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFXT+RP89DEQXj3_4SzXfL4eyZfrmsrM_zSsqah1n679Lg=jEQ@mail.gmail.com' \
    --to=zkanfer@gmail.com \
    --cc=21501@debbugs.gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.