unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: 16190@debbugs.gnu.org
Subject: bug#16190: 23.4; M-x captialize-word works incorrectly
Date: Sat, 28 Dec 2013 12:31:16 -0700	[thread overview]
Message-ID: <l9n8tm$4ga$1@ger.gmane.org> (raw)
In-Reply-To: <CANdFEAEPMPyMmujdAS47vPVwP_vjfmfX=WayjSYDtHBUELC+iQ@mail.gmail.com>

On 12/27/13 10:31 PM, Josh wrote:
> On Thu, Dec 26, 2013 at 7:30 PM, Kevin Rodgers
> <kevin.d.rodgers@gmail.com>  wrote:
>> On 12/23/13 11:59 AM, Josh wrote:
>>>
>>> On Mon, Dec 23, 2013 at 8:12 AM, Eli Zaretskii<eliz@gnu.org>   wrote:
>>>>
>>>> If you want a function that capitalizes the word at point after
>>>> looking back for its beginning, you need to code that using
>>>> thing-at-point or some such.
>>>
>>>
>>> When point is not already at the start of the word, `capitalize-word'
>>> can already do this pretty easily via `M-- M-c'.
>>
>> (defun capitalize-word-at-point ()
>>    "Capitalize the word at point (i.e. around point), without moving point."
>>    (interactive)
>>    (capitalize-word -1))
>
> Unfortunately it's not quite that simple, because calling that function
> when point is before the first character of a word will capitalize the
> preceding word instead of the word following point.  Something like
>    (defun capitalize-word-at-point ()
>      "Capitalize the word at point."
>      (interactive)
>      (save-excursion
>        (forward-word)
>        (backward-word)
>        (capitalize-word 1)))
> should suffice, though there are probably more elegant approaches.

How about:

(defun capitalize-word-at-point ()
   "Capitalize the word at point.
If point is within a word, don't move point."
   (interactive)
   (if (looking-at "\\b")
       (capitalize-word 1)
     (capitalize-word -1)))

Or:

(defadvice capitalize-word (before point-within-word activate)
   "When point is within a word, capitalize the word around point
-- but only when called interactively."
   (if (and (called-interactively-p 'any)
	   (not (looking-at "\\b")))
       (backward-word (prefix-numeric-value current-prefix-arg))))

-- 
Kevin Rodgers
Denver, Colorado, USA






      reply	other threads:[~2013-12-28 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13  4:03 bug#16190: 23.4; M-x captialize-word works incorrectly Caleb Wakeman
2013-12-19  3:51 ` Eli Zaretskii
2013-12-19  8:36   ` Stephen Berman
2013-12-19 16:28     ` Drew Adams
2013-12-19 17:54     ` Eli Zaretskii
2013-12-23  4:20       ` Caleb Wakeman
2013-12-23  5:35         ` Caleb Wakeman
2013-12-23 16:12         ` Eli Zaretskii
2013-12-23 18:59           ` Josh
2013-12-27  3:30             ` Kevin Rodgers
2013-12-28  5:31               ` Josh
2013-12-28 19:31                 ` Kevin Rodgers [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='l9n8tm$4ga$1@ger.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=16190@debbugs.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).