From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Zachary Kanfer Newsgroups: gmane.emacs.bugs Subject: bug#21501: new Emacs functions for capitalizing text intelligently Date: Thu, 17 Sep 2015 00:32:32 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=089e013c6a7a7bb0d7051fe9e815 X-Trace: ger.gmane.org 1442464403 18400 80.91.229.3 (17 Sep 2015 04:33:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Sep 2015 04:33:23 +0000 (UTC) To: 21501@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 17 06:33:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZcQsg-0001kF-R2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Sep 2015 06:33:11 +0200 Original-Received: from localhost ([::1]:55797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsg-0006V4-3B for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Sep 2015 00:33:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsa-0006Pm-1z for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:33:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcQsY-0000xA-Qx for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:33:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsY-0000x1-OB for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZcQsY-0007dp-H0 for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Sep 2015 04:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.144246438129363 (code B ref -1); Thu, 17 Sep 2015 04:33:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Sep 2015 04:33:01 +0000 Original-Received: from localhost ([127.0.0.1]:35578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZcQsW-0007dW-HU for submit@debbugs.gnu.org; Thu, 17 Sep 2015 00:33:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42007) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZcQsT-0007dN-N8 for submit@debbugs.gnu.org; Thu, 17 Sep 2015 00:32:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcQsS-0000vf-7a for submit@debbugs.gnu.org; Thu, 17 Sep 2015 00:32:57 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsS-0000vb-5O for submit@debbugs.gnu.org; Thu, 17 Sep 2015 00:32:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsQ-0006EI-Ud for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:32:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcQsP-0000vC-KQ for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:32:54 -0400 Original-Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:36375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcQsP-0000v6-AI for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2015 00:32:53 -0400 Original-Received: by obqa2 with SMTP id a2so4950755obq.3 for ; Wed, 16 Sep 2015 21:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=3FOLLuAvygsz7XqLBaToA7mYEIbiyHJfwKBterC37ik=; b=jYnKrYXXfxm6hfY1gvCZ84huFx3cgFtja3G2BlFjMoCmgIoPMxhXljwQ6VezoO3EEI k/Bg/XP8gPUrGGtCgpeuOaoxRHUjse8aJJM1gLU+pb9fIf/H/rLuic4LQM8uvp9TwJrs GVwogDyCq4GzN++ilEOiyey2sTokgrqqZniWrNvzx6SapThTqXV/ztsNkytIJM0HBmHC EZKa2TQ9uX7U8eEkth9O+GSBZFlmzDQKkpzdhlTrgxEpoYTJJpxlOI7HoNPjywMk3zY/ 0ba+o6bc6StbJMzUArJ+8hwp2J2NYWDvTx9bSi54IXFunQtx5qALYENrf89xop/LZQdO JfWg== X-Received: by 10.182.107.199 with SMTP id he7mr28105655obb.35.1442464371773; Wed, 16 Sep 2015 21:32:51 -0700 (PDT) Original-Received: by 10.76.170.164 with HTTP; Wed, 16 Sep 2015 21:32:32 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:106670 Archived-At: --089e013c6a7a7bb0d7051fe9e815 Content-Type: multipart/alternative; boundary=089e013c6a7a7bb0c9051fe9e813 --089e013c6a7a7bb0c9051fe9e813 Content-Type: text/plain; charset=UTF-8 I'm submitting some additional -dwim functions to that change the capitalization of text the way the user probably wants. These work similarly to comment-dwim, or count-words: they act on the region if and only if it's active (more specifically, if (use-region-p) is true), and otherwise act on the word starting at point. Either way, they use existing functions in Emacs: e.g. #'upcase-dwim delegates either to #'upcase-region or #'upcase-word. There are three functions: one for each of capitalizing text, upcasing text, and lowercasing text. The docstrings are based on the docstring for comment-dwim. In my init file, I've changed the default mappings of M-u, M-l, and M-c to these new functions, and would support changing Emacs's defaults to them. However, I am led to believe that changing defaults isn't preferred, so this patch doesn't contain any of that. Even without changing defaults, I believe these functions are worth adding to Emacs. The capitalization-related functions I'm using are all defined in C, so I can't put these new functions alongside them. I put the changes in simple.el, as that file's described as "A grab-bag of basic Emacs commands not specifically related to some major mode or to file-handling.". I'm happy to move the functions and create a new diff if there's a more appropriate file for them to live in. Changelog entry: * simple.el: Add functions for capitalizing text intelligently. (capitalize-dwim): New function. (upcase-dwim): New function. (downcase-dwim): New function. The diff is attached. -Zachary Kanfer --089e013c6a7a7bb0c9051fe9e813 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm submitting some additional -dwim functions to= that change the capitalization of text the way the user probably wants.
These work similarly to comment-dwim, or count-words: they act on the = region if and only if it's active (more specifically, if (use-region-p)= is true), and otherwise act on the word starting at point. Either way, the= y use existing functions in Emacs: e.g. #'upcase-dwim delegates either = to #'upcase-region or #'upcase-word.

There are three functio= ns: one for each of capitalizing text, upcasing text, and lowercasing text.= The docstrings are based on the docstring for comment-dwim.

In my i= nit file, I've changed the default mappings of M-u, M-l, and M-c to the= se new functions, and would support changing Emacs's defaults to them. = However, I am led to believe that changing defaults isn't preferred, so= this patch doesn't contain any of that. Even without changing defaults= , I believe these functions are worth adding to Emacs.

The capitaliz= ation-related functions I'm using are all defined in C, so I can't = put these new functions alongside them. I put the changes in simple.el, as = that file's described as "A grab-bag of basic Emacs commands not s= pecifically related to some major mode or to file-handling.". I'm = happy to move the functions and create a new diff if there's a more app= ropriate file for them to live in.

Changelog entry:

* simple.= el: Add functions for capitalizing text intelligently.
(capitalize-dwim)= : New function.
(upcase-dwim): New function.
(downcase-dwim): New fun= ction.

The diff is attached.

-Zachary Kanfer
--089e013c6a7a7bb0c9051fe9e813-- --089e013c6a7a7bb0d7051fe9e815 Content-Type: text/x-patch; charset=US-ASCII; name="0001-Add-functions-for-capitalizing-text-intelligently.patch" Content-Disposition: attachment; filename="0001-Add-functions-for-capitalizing-text-intelligently.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ienowmy80 RnJvbSBlYTQ4NTY0MzRjMWU1ZWRmM2UxZDUwOTU4YzkwOGVjM2U1YjE1MmI1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBaYWNoYXJ5IEthbmZlciA8emthbmZlckBnbWFpbC5jb20+CkRh dGU6IE1vbiwgMTQgU2VwIDIwMTUgMTU6MDQ6MzIgLTA0MDAKU3ViamVjdDogW1BBVENIXSBBZGQg ZnVuY3Rpb25zIGZvciBjYXBpdGFsaXppbmcgdGV4dCBpbnRlbGxpZ2VudGx5LgoKVGhpcyBwYXRj aCBhZGRzIHRocmVlIGZ1bmN0aW9uczogdXBjYXNlLWR3aW0sIGRvd25jYXNlLWR3aW0sIGFuZApj YXBpdGFsaXplLWR3aW0uIFRoZXNlIGZ1b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