unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16190: 23.4; M-x captialize-word works incorrectly
@ 2013-12-13  4:03 Caleb Wakeman
  2013-12-19  3:51 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Caleb Wakeman @ 2013-12-13  4:03 UTC (permalink / raw)
  To: 16190

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@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)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2013-12-19  3:51 UTC (permalink / raw)
  To: caleb; +Cc: 16190

> Date: Thu, 12 Dec 2013 23:03:28 -0500
> From: Caleb Wakeman <cdw1992@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.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  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
  0 siblings, 2 replies; 12+ messages in thread
From: Stephen Berman @ 2013-12-19  8:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: caleb, 16190

On Thu, 19 Dec 2013 05:51:02 +0200 Eli Zaretskii <eliz@gnu.org> wrote:

>> Date: Thu, 12 Dec 2013 23:03:28 -0500
>> From: Caleb Wakeman <cdw1992@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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-19  8:36   ` Stephen Berman
@ 2013-12-19 16:28     ` Drew Adams
  2013-12-19 17:54     ` Eli Zaretskii
  1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2013-12-19 16:28 UTC (permalink / raw)
  To: Stephen Berman, Eli Zaretskii; +Cc: caleb, 16190

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  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
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2013-12-19 17:54 UTC (permalink / raw)
  To: Stephen Berman; +Cc: caleb, 16190-done

> From: Stephen Berman <stephen.berman@gmx.net>
> Cc: caleb@compwizard.net,  16190@debbugs.gnu.org
> Date: Thu, 19 Dec 2013 09:36:54 +0100
> 
> On Thu, 19 Dec 2013 05:51:02 +0200 Eli Zaretskii <eliz@gnu.org> wrote:
> 
> >> Date: Thu, 12 Dec 2013 23:03:28 -0500
> >> From: Caleb Wakeman <cdw1992@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).





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  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
  0 siblings, 2 replies; 12+ messages in thread
From: Caleb Wakeman @ 2013-12-23  4:20 UTC (permalink / raw)
  To: 16190

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-23  4:20       ` Caleb Wakeman
@ 2013-12-23  5:35         ` Caleb Wakeman
  2013-12-23 16:12         ` Eli Zaretskii
  1 sibling, 0 replies; 12+ messages in thread
From: Caleb Wakeman @ 2013-12-23  5:35 UTC (permalink / raw)
  To: 16190

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  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
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2013-12-23 16:12 UTC (permalink / raw)
  To: caleb; +Cc: 16190

> Date: Sun, 22 Dec 2013 23:20:33 -0500
> From: Caleb Wakeman <cdw1992@twcny.rr.com>
> CC: Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-23 16:12         ` Eli Zaretskii
@ 2013-12-23 18:59           ` Josh
  2013-12-27  3:30             ` Kevin Rodgers
  0 siblings, 1 reply; 12+ messages in thread
From: Josh @ 2013-12-23 18:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: caleb, 16190

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-23 18:59           ` Josh
@ 2013-12-27  3:30             ` Kevin Rodgers
  2013-12-28  5:31               ` Josh
  0 siblings, 1 reply; 12+ messages in thread
From: Kevin Rodgers @ 2013-12-27  3:30 UTC (permalink / raw)
  To: 16190

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

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






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-27  3:30             ` Kevin Rodgers
@ 2013-12-28  5:31               ` Josh
  2013-12-28 19:31                 ` Kevin Rodgers
  0 siblings, 1 reply; 12+ messages in thread
From: Josh @ 2013-12-28  5:31 UTC (permalink / raw)
  To: Kevin Rodgers; +Cc: 16190

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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#16190: 23.4; M-x captialize-word works incorrectly
  2013-12-28  5:31               ` Josh
@ 2013-12-28 19:31                 ` Kevin Rodgers
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2013-12-28 19:31 UTC (permalink / raw)
  To: 16190

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






^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-12-28 19:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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