GNU bug report logs -
#16190
23.4; M-x captialize-word works incorrectly
Previous Next
Reported by: caleb <at> compwizard.net
Date: Thu, 19 Dec 2013 01:53:02 UTC
Severity: minor
Tags: notabug
Found in version 23.4
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 16190 in the body.
You can then email your comments to 16190 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Thu, 19 Dec 2013 01:53:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
caleb <at> compwizard.net
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 19 Dec 2013 01:53:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
With point in the middle of a word, I ran M-x capitalize-word. Rather
than capitalize the first letter of the word, as I expected, it
capitalized the character at point and moved point to the end of the
word. (Specifically, rather than change `word' (wo-!-rd) to `Word', it
changed it to `woRd'.)
I checked this in the message edit buffer, and it seems pretty
consistent to me.
I was able to reproduce this with M-c as well as M-x capitalize-word (as
well as ESC c and ESC x capitalize word on the Mac mentioned below).
I was also able to reproduce this in (apparently vanilla?) GNU Emacs
22.1.1 under Mac OS X (tested in the scratch buffer).
--!Autofilled content from M-x report-emacs-bug!--
This bug report will be sent to the Free Software Foundation, not to
your local site managers! Please write in English if possible, because
the Emacs maintainers usually do not have translators to read other
languages for them. Your report will be posted to the
bug-gnu-emacs <at> gnu.org mailing list and the gnu.emacs.bug news group, and
at http://debbugs.gnu.org. Please describe exactly what actions
triggered the bug and the precise symptoms of the bug. If you can, give
a recipe starting from `emacs -Q': If Emacs crashed, and you have the
Emacs process in the gdb debugger, please include the output from the
following gdb commands: `bt full' and `xbacktrace'. For information
about debugging Emacs, please read the file
/usr/share/emacs/23.4/etc/DEBUG. In GNU Emacs 23.4.1
(x86_64-pc-linux-gnu, GTK+ Version 2.24.12) of 2012-09-22 on allspice,
modified by Debian Windowing system distributor `The X.Org Foundation',
version 11.0.11303000 configured using `configure '--build'
'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu' '--prefix=/usr'
'--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.4/site-lisp:/usr/share/emacs/site-lisp'
'--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
'--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall
-DDEBIAN -O2' 'CPPFLAGS=-D_FORTIFY_SOURCE=2'' Important settings:
value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE:
nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of
$LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8
value of $XMODIFIERS: nil locale-coding-system: utf-8-unix
default enable-multibyte-characters: t Major mode: Text Minor modes in
effect: longlines-mode: t iswitchb-mode: t
minibuffer-depth-indicate-mode: t icicle-mode: t server-mode: t
global-whitespace-mode: t display-battery-mode: t tooltip-mode: t
mouse-wheel-mode: t tool-bar-mode: t use-hard-newlines: t
menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t
font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t
auto-compression-mode: t size-indication-mode: t line-number-mode: t
transient-mark-mode: t Recent input: T M L , SPC o r SPC P D
<backspace> <backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> SPC o r SPC H T M L , SPC t h a n <backspace> <backspace>
e n SPC a n y o n e SPC w o u l d SPC b e SPC a b l e SPC t o SPC r e a
d SPC i t . <help-echo> <help-echo> <down-mouse-1> <mouse-1> ( e
<backspace> E v e n SPC p e o p l e SPC w i t h SPC i <backspace> M i c
r o s o f t SPC w o r d SPC m a y SPC n o t SPC b e SPC a b l e SPC t
o SPC r e a d SPC i t , <backspace> <backspace> <backspace> t h e SPC f
i l e , SPC i f SPC <help-echo> <help-echo> <down-mouse-1> <help-echo>
<mouse-movement> <mouse-movement> <drag-mouse-1> i t SPC w a s SPC m a
d e SPC w i t h SPC a SPC n e w e r SPC v e r s i o n SPC o f SPC w o r
<backspace> <backspace> <backspace> W r o <backspace> <backspace> o r d
SPC t h a n SPC t h e y SPC h a v e . ) SPC SPC <down-mouse-1>
<mouse-1> <help-echo> C-x C-f <M-backspace> G o <return> SPC C-_ M-v
C-v C-v C-x C-f l i b <tab> <return> C-x k <return> C-x k <return>
<down-mouse-1> <mouse-1> <menu> c a p t i <backspace> <backspace> i t
<tab> - w o <tab> <return> C-_ M-c C-_ M-b M-c C-n C-n C-n C-n <menu>
r e p o r t - e m <tab> <return> Recent messages: Auto-saving...done
Auto-saving...done Auto-saving...done Auto-saving...done
Auto-saving...done Undo! call-interactively: Beginning of buffer
call-interactively: End of buffer Auto-saving...done Undo! [2 times]
Load-path shadows: ~/.emacslisp/icicles/lacarte hides
~/.emacslisp/lacarte /usr/share/emacs/23.4/site-lisp/debian-startup
hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs23/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/23.4/lisp/textmodes/ispell
/usr/share/emacs23/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/23.4/lisp/textmodes/flyspell
/usr/share/emacs23/site-lisp/latex-cjk-thai/thai-word hides
/usr/share/emacs/23.4/lisp/language/thai-word
/usr/share/emacs23/site-lisp/auctex/tex-jp hides
/usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs23/site-lisp/auctex/tex-fold hides
/usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs23/site-lisp/auctex/tex hides
/usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs23/site-lisp/auctex/preview hides
/usr/share/emacs/site-lisp/auctex/preview
/usr/share/emacs23/site-lisp/auctex/bib-cite hides
/usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs23/site-lisp/auctex/tex-mik hides
/usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs23/site-lisp/auctex/context-nl hides
/usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs23/site-lisp/auctex/multi-prompt hides
/usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs23/site-lisp/auctex/latex hides
/usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs23/site-lisp/auctex/font-latex hides
/usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs23/site-lisp/auctex/toolbar-x hides
/usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs23/site-lisp/auctex/tex-font hides
/usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs23/site-lisp/auctex/tex-bar hides
/usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs23/site-lisp/auctex/prv-emacs hides
/usr/share/emacs/site-lisp/auctex/prv-emacs
/usr/share/emacs23/site-lisp/auctex/tex-style hides
/usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs23/site-lisp/auctex/context hides
/usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs23/site-lisp/auctex/tex-info hides
/usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs23/site-lisp/auctex/texmathp hides
/usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs23/site-lisp/auctex/context-en hides
/usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs23/site-lisp/auctex/plain-tex hides
/usr/share/emacs/site-lisp/auctex/plain-tex
/usr/share/emacs23/site-lisp/auctex/tex-buf hides
/usr/share/emacs/site-lisp/auctex/tex-buf Features: (shadow sort message
sendmail ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies
mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums
mailabbrev nnheader gnus-util netrc mm-util mail-prsvr gmm-utils
mailheader canlock sha1 hex-util hashcash mail-utils emacsbug mail-extr
ispell debug jka-compr multi-isearch vc-hg face-remap image-file org-wl
org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs
org-html org-exp org-exp-blocks org-agenda org-info org-gnus org-bibtex
org-bbdb longlines iswitchb two-column mb-depth info bookmark pp icicles
icicles-mode icicles-cmd2 icicles-cmd1 cus-edit icicles-mcmd help-mode
view image-dired format-spec dired regexp-opt doremi ring+ ring
icicles-fn icicles-var icicles-opt ffap wid-edit thingatpt icicles-face
hexrgb remember org-remember org-datetree org byte-opt warnings bytecomp
byte-compile org-footnote org-src org-list org-faces org-compat org-macs
easymenu time-date noutline outline easy-mmode edmacro kmacro disp-table
saveplace uniquify advice help-fns advice-preload server whitespace
battery cus-start cus-load slime-autoloads magit-install bbdb-autoloads
preview-latex tex-site auto-loads tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Thu, 19 Dec 2013 04:00:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 16190 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 12 Dec 2013 23:03:28 -0500
> From: Caleb Wakeman <cdw1992 <at> twcny.rr.com>
>
> With point in the middle of a word, I ran M-x capitalize-word. Rather
> than capitalize the first letter of the word, as I expected, it
> capitalized the character at point and moved point to the end of the
> word. (Specifically, rather than change `word' (wo-!-rd) to `Word', it
> changed it to `woRd'.)
That's how capitalize-word is supposed to work. It's not a bug, but
intended behavior.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Thu, 19 Dec 2013 08:38:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 16190 <at> debbugs.gnu.org (full text, mbox):
On Thu, 19 Dec 2013 05:51:02 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Date: Thu, 12 Dec 2013 23:03:28 -0500
>> From: Caleb Wakeman <cdw1992 <at> twcny.rr.com>
>>
>> With point in the middle of a word, I ran M-x capitalize-word. Rather
>> than capitalize the first letter of the word, as I expected, it
>> capitalized the character at point and moved point to the end of the
>> word. (Specifically, rather than change `word' (wo-!-rd) to `Word', it
>> changed it to `woRd'.)
>
> That's how capitalize-word is supposed to work. It's not a bug, but
> intended behavior.
Then its doc string is incorrect:
capitalize-word is an interactive built-in function in `C source code'.
It is bound to M-c.
(capitalize-word ARG)
Capitalize the following word (or ARG words), moving over.
This gives the word(s) a first character in upper case
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and the rest lower case.
^^^^^^^^^^^^^^^^^^^^^^^^
With negative argument, capitalize previous words but do not move.
Steve Berman
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Thu, 19 Dec 2013 16:29:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 16190 <at> debbugs.gnu.org (full text, mbox):
> > That's how capitalize-word is supposed to work. It's not a bug, but
> > intended behavior.
>
> Then its doc string is incorrect:
>
> capitalize-word is an interactive built-in function in `C source code'.
>
> It is bound to M-c.
>
> (capitalize-word ARG)
>
> Capitalize the following word (or ARG words), moving over.
> This gives the word(s) a first character in upper case
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> and the rest lower case.
> ^^^^^^^^^^^^^^^^^^^^^^^^
> With negative argument, capitalize previous words but do not move.
The key here is the *word that starts at point*. With point after the `n'
here: "another", the word that starts at point is "other".
It could help for the doc to explicitly emphasize this, as an extra tip.
That is, to point out that there is no scanning backward to find the
maximal word, i.e., to find a non word-constituent character.
But this should be treated as extra info, implied by a statement
(missing, it seems) that the word starts at point. "The following word"
is too loose a description to make this clear.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Thu, 19 Dec 2013 17:54:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
caleb <at> compwizard.net
:
bug acknowledged by developer.
(Thu, 19 Dec 2013 17:54:04 GMT)
Full text and
rfc822 format available.
Message #19 received at 16190-done <at> debbugs.gnu.org (full text, mbox):
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: caleb <at> compwizard.net, 16190 <at> debbugs.gnu.org
> Date: Thu, 19 Dec 2013 09:36:54 +0100
>
> On Thu, 19 Dec 2013 05:51:02 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> >> Date: Thu, 12 Dec 2013 23:03:28 -0500
> >> From: Caleb Wakeman <cdw1992 <at> twcny.rr.com>
> >>
> >> With point in the middle of a word, I ran M-x capitalize-word. Rather
> >> than capitalize the first letter of the word, as I expected, it
> >> capitalized the character at point and moved point to the end of the
> >> word. (Specifically, rather than change `word' (wo-!-rd) to `Word', it
> >> changed it to `woRd'.)
> >
> > That's how capitalize-word is supposed to work. It's not a bug, but
> > intended behavior.
>
> Then its doc string is incorrect:
Fair enough, I fixed the doc string to be more explicit on this matter
(in trunk revision 115612).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Mon, 23 Dec 2013 05:00:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 16190 <at> debbugs.gnu.org (full text, mbox):
(paraphrased quotes)
>>> That's the intended behavior
>> Then its docstring is incorrect
> Fair enough, fixed
Erm, well...
I've had several days to think it over, and I don't agree [that it's
fixed]. Yes, the docstring is (was) incorrect; and if it hadn't been
incorrect, I wouldn't have reported it as a bug.
However, the function would still be doing 'The Wrong Thing' (for me, I
can imagine that cases exist where this isn't), and if I ever used it
again, it would only be because I forgot that it didn't do what I expected.
I think this is also the point where if I want something more done, I
really should do it myself. I'd take it on for sure if it were in
elisp. I dunno if I could do it in C.
This seems reasonable as a 'workaround' fix, though.
[I'd agree that "Severity: minor" is correct.]
(I can re-create my mental state leading up to actually sending the bug
report, or share my mental image of what the function does, if either of
those would be helpful.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Mon, 23 Dec 2013 13:57:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 16190 <at> debbugs.gnu.org (full text, mbox):
It occurred to me that there may be two separate "bugs", and me
conflating them.
First is "M-x capitalize-word has an incorrect docstring". That's been
fixed (or I should say, I take your word for it).
Second is "M-x capitalize-word does the wrong thing". Whether that's a
bug may be open to debate (I think it is a bug, or at least a problem,
obviously), but that hasn't changed.
On 12/22/2013 11:20 PM, Caleb Wakeman wrote:
> (paraphrased quotes)
> >>> That's the intended behavior
> >> Then its docstring is incorrect
> > Fair enough, fixed
>
> Erm, well...
>
> I've had several days to think it over, and I don't agree [that it's
> fixed]. Yes, the docstring is (was) incorrect; and if it hadn't been
> incorrect, I wouldn't have reported it as a bug.
>
> However, the function would still be doing 'The Wrong Thing' (for me, I
> can imagine that cases exist where this isn't), and if I ever used it
> again, it would only be because I forgot that it didn't do what I expected.
>
> I think this is also the point where if I want something more done, I
> really should do it myself. I'd take it on for sure if it were in
> elisp. I dunno if I could do it in C.
>
> This seems reasonable as a 'workaround' fix, though.
>
> [I'd agree that "Severity: minor" is correct.]
>
> (I can re-create my mental state leading up to actually sending the bug
> report, or share my mental image of what the function does, if either of
> those would be helpful.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Mon, 23 Dec 2013 16:14:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 16190 <at> debbugs.gnu.org (full text, mbox):
> Date: Sun, 22 Dec 2013 23:20:33 -0500
> From: Caleb Wakeman <cdw1992 <at> twcny.rr.com>
> CC: Eli Zaretskii <eliz <at> gnu.org>
>
> (paraphrased quotes)
> >>> That's the intended behavior
> >> Then its docstring is incorrect
> > Fair enough, fixed
>
> Erm, well...
>
> I've had several days to think it over, and I don't agree [that it's
> fixed]. Yes, the docstring is (was) incorrect; and if it hadn't been
> incorrect, I wouldn't have reported it as a bug.
>
> However, the function would still be doing 'The Wrong Thing' (for me, I
> can imagine that cases exist where this isn't), and if I ever used it
> again, it would only be because I forgot that it didn't do what I expected.
The 3 functions that change letter-case in words, capitalize-word,
upcase-word, and downcase-word work in the same way when moving
forward: they start with the current buffer position.
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Mon, 23 Dec 2013 19:01:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 16190 <at> debbugs.gnu.org (full text, mbox):
On Mon, Dec 23, 2013 at 8:12 AM, Eli Zaretskii <eliz <at> 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'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Fri, 27 Dec 2013 03:32:01 GMT)
Full text and
rfc822 format available.
Message #34 received at submit <at> debbugs.gnu.org (full text, mbox):
On 12/23/13 11:59 AM, Josh wrote:
> On Mon, Dec 23, 2013 at 8:12 AM, Eli Zaretskii<eliz <at> 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'.
So for the OP:
(defun capitalize-word-at-point ()
"Capitalize the word at point (i.e. around point), without moving point."
(interactive)
(capitalize-word -1))
(global-set-key "\M-c" 'capitalize-word-at-point) ; was capitalize-word
--
Kevin Rodgers
Denver, Colorado, USA
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Sat, 28 Dec 2013 05:32:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 16190 <at> debbugs.gnu.org (full text, mbox):
On Thu, Dec 26, 2013 at 7:30 PM, Kevin Rodgers
<kevin.d.rodgers <at> gmail.com> wrote:
> On 12/23/13 11:59 AM, Josh wrote:
>>
>> On Mon, Dec 23, 2013 at 8:12 AM, Eli Zaretskii<eliz <at> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16190
; Package
emacs
.
(Sat, 28 Dec 2013 19:32:02 GMT)
Full text and
rfc822 format available.
Message #40 received at submit <at> debbugs.gnu.org (full text, mbox):
On 12/27/13 10:31 PM, Josh wrote:
> On Thu, Dec 26, 2013 at 7:30 PM, Kevin Rodgers
> <kevin.d.rodgers <at> gmail.com> wrote:
>> On 12/23/13 11:59 AM, Josh wrote:
>>>
>>> On Mon, Dec 23, 2013 at 8:12 AM, Eli Zaretskii<eliz <at> 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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 26 Jan 2014 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 65 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.