GNU bug report logs - #21501
new Emacs functions for capitalizing text intelligently

Previous Next

Package: emacs;

Reported by: Zachary Kanfer <zkanfer <at> gmail.com>

Date: Thu, 17 Sep 2015 04:33:02 UTC

Severity: wishlist

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21501 in the body.
You can then email your comments to 21501 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Thu, 17 Sep 2015 04:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zachary Kanfer <zkanfer <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 17 Sep 2015 04:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: new Emacs functions for capitalizing text intelligently
Date: Thu, 17 Sep 2015 00:32:32 -0400
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]
[0001-Add-functions-for-capitalizing-text-intelligently.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Sat, 19 Sep 2015 20:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 21501 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: 21501 <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Sat, 19 Sep 2015 16:27:34 -0400
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Sun, 20 Sep 2015 06:15:03 GMT) Full text and rfc822 format available.

Message #11 received at 21501 <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21501 <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Sun, 20 Sep 2015 02:13:39 -0400
[Message part 1 (text/plain, inline)]
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 <monnier <at> iro.umontreal.ca>
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
>
[Message part 2 (text/html, inline)]
[0002-Add-functions-for-capitalizing-text-intelligently.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Sun, 20 Sep 2015 06:47:02 GMT) Full text and rfc822 format available.

Message #14 received at 21501 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: monnier <at> iro.umontreal.ca, 21501 <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Sun, 20 Sep 2015 09:46:42 +0300
> From: Zachary Kanfer <zkanfer <at> gmail.com>
> Date: Sun, 20 Sep 2015 02:13:39 -0400
> Cc: 21501 <at> debbugs.gnu.org
> 
> Here's a changed patch.

Thanks.  Allow me a couple of minor comments.

> 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.

For us to be able to bind M-u etc. to these new commands, they need to
support the prefix argument to upcase-word etc.  The way you wrote
these new commands, that feature will be lost.

> +;;; 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'."

Every doc string should state the effect of the function/variable in
its first line, because some Help commands (like 'apropos') show only
the first line.  The above doc string (and the others in your patch)
don't do that; the effect is only clear if one reads the rest of the
doc string.

I suggest to change the doc strings like this:

  Upcase words in the region, if active; otherwise upcase word at point.
If the region is active, this function calls `upcase-region'.
Otherwise it calls `upcase-word'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Sun, 20 Sep 2015 18:26:01 GMT) Full text and rfc822 format available.

Message #17 received at 21501 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: zkanfer <at> gmail.com, 21501 <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Sun, 20 Sep 2015 14:23:57 -0400
[[[ 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.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21501; Package emacs. (Mon, 21 Sep 2015 18:53:01 GMT) Full text and rfc822 format available.

Message #20 received at 21501 <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: rms <at> gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 21501 <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Mon, 21 Sep 2015 14:52:01 -0400
[Message part 1 (text/plain, inline)]
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 <at> 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.
>
>
[Message part 2 (text/html, inline)]
[0003-Add-functions-for-capitalizing-text-intelligently.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 26 Sep 2015 08:14:01 GMT) Full text and rfc822 format available.

Notification sent to Zachary Kanfer <zkanfer <at> gmail.com>:
bug acknowledged by developer. (Sat, 26 Sep 2015 08:14:02 GMT) Full text and rfc822 format available.

Message #25 received at 21501-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: 21501-done <at> debbugs.gnu.org
Subject: Re: bug#21501: new Emacs functions for capitalizing text intelligently
Date: Sat, 26 Sep 2015 11:13:21 +0300
> From: Zachary Kanfer <zkanfer <at> gmail.com>
> Date: Mon, 21 Sep 2015 14:52:01 -0400
> Cc: 21501 <at> debbugs.gnu.org
> 
> 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.

Thanks, I pushed them.

Note that with this contribution you've exhausted your limit of code
submissions that can be accepted without legal paperwork, so if you'd
like to continue your contribution (we hope you do), you will have to
do that paperwork.

Also, please in the future always include with your patches a log
message in the format described in CONTRIBUTE.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 24 Oct 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 319 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.