* CamelHump word movement in Emacs
@ 2009-11-19 8:46 Tassilo Horn
2009-11-19 8:57 ` Giuseppe Scrivano
0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2009-11-19 8:46 UTC (permalink / raw)
To: emacs-devel
Hi all,
in many editors for "modern" programming languages like Java or C#, the
normal word movement commands also stop on CamelHumps. This is very
convenient, because nowadays the convention for identifiers names more
and more turns to using camelCaseNaming.
Here's an example:
int foo_bar_baz() {}
With the usual forward/backward-word commands, point always stops at the
_ (when moving forward) or the first char of the component word (when
moving backward). I really like that behavior.
Unfortunately, it doesn't work if the function uses camelCase naming.
int fooBarBaz() {}
Here, forward/backward-word jump over the complete identifier. What I
would really like to have, was that those commands move point to the
capital letters (the 2 Bs), too.
IMO, that would be the right thing to do, because camelCase is nearly
never used for something else than separating words.
What do you think?
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 8:46 CamelHump word movement in Emacs Tassilo Horn
@ 2009-11-19 8:57 ` Giuseppe Scrivano
2009-11-19 11:05 ` Tassilo Horn
0 siblings, 1 reply; 20+ messages in thread
From: Giuseppe Scrivano @ 2009-11-19 8:57 UTC (permalink / raw)
To: emacs-devel
have you considered "c-subword-mode"?
Cheers,
Giuseppe
Tassilo Horn <tassilo@member.fsf.org> writes:
> Hi all,
>
> in many editors for "modern" programming languages like Java or C#, the
> normal word movement commands also stop on CamelHumps. This is very
> convenient, because nowadays the convention for identifiers names more
> and more turns to using camelCaseNaming.
>
> Here's an example:
>
> int foo_bar_baz() {}
>
> With the usual forward/backward-word commands, point always stops at the
> _ (when moving forward) or the first char of the component word (when
> moving backward). I really like that behavior.
>
> Unfortunately, it doesn't work if the function uses camelCase naming.
>
> int fooBarBaz() {}
>
> Here, forward/backward-word jump over the complete identifier. What I
> would really like to have, was that those commands move point to the
> capital letters (the 2 Bs), too.
>
> IMO, that would be the right thing to do, because camelCase is nearly
> never used for something else than separating words.
>
> What do you think?
>
> Bye,
> Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 8:57 ` Giuseppe Scrivano
@ 2009-11-19 11:05 ` Tassilo Horn
2009-11-19 15:22 ` Stefan Monnier
0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2009-11-19 11:05 UTC (permalink / raw)
To: Giuseppe Scrivano; +Cc: emacs-devel
Giuseppe Scrivano <gscrivano@gnu.org> writes:
Hi Giuseppe,
> have you considered "c-subword-mode"?
Nope, I didn't know it till now, but it does exactly what I want.
I think this feature is generally useful and has nothing to do with C,
so I propose to rename it (and its commands and the file) to
`subword-mode' or `camelcase-mode'.
Also, it would be nice to have it as a global minor mode, too.
Any objections? If not, I'd volunteer to do that.
Bye,
Tassilo
> Tassilo Horn <tassilo@member.fsf.org> writes:
>
>> Hi all,
>>
>> in many editors for "modern" programming languages like Java or C#, the
>> normal word movement commands also stop on CamelHumps. This is very
>> convenient, because nowadays the convention for identifiers names more
>> and more turns to using camelCaseNaming.
>>
>> Here's an example:
>>
>> int foo_bar_baz() {}
>>
>> With the usual forward/backward-word commands, point always stops at the
>> _ (when moving forward) or the first char of the component word (when
>> moving backward). I really like that behavior.
>>
>> Unfortunately, it doesn't work if the function uses camelCase naming.
>>
>> int fooBarBaz() {}
>>
>> Here, forward/backward-word jump over the complete identifier. What I
>> would really like to have, was that those commands move point to the
>> capital letters (the 2 Bs), too.
>>
>> IMO, that would be the right thing to do, because camelCase is nearly
>> never used for something else than separating words.
>>
>> What do you think?
>>
>> Bye,
>> Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 11:05 ` Tassilo Horn
@ 2009-11-19 15:22 ` Stefan Monnier
2009-11-19 19:24 ` Tassilo Horn
0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2009-11-19 15:22 UTC (permalink / raw)
To: Giuseppe Scrivano; +Cc: emacs-devel
> I think this feature is generally useful and has nothing to do with C,
> so I propose to rename it (and its commands and the file) to
> `subword-mode' or `camelcase-mode'.
IIRC the same suggestion to make it generic came up right around the
Emacs-23 freeze, which is why it didn't happen. If someone wants to
make this generic *right now* he'd better hurry. Otherwise it'll have
to wait for Emacs-24 (or Emacs-23.3 maybe).
> Also, it would be nice to have it as a global minor mode, too.
> Any objections? If not, I'd volunteer to do that.
IIRC there was a general agreement that it would be a desirable feature.
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 15:22 ` Stefan Monnier
@ 2009-11-19 19:24 ` Tassilo Horn
2009-11-19 21:31 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Tassilo Horn @ 2009-11-19 19:24 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Giuseppe Scrivano, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 806 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
Hi Stefan,
>> I think this feature is generally useful and has nothing to do with
>> C, so I propose to rename it (and its commands and the file) to
>> `subword-mode' or `camelcase-mode'.
>
> IIRC the same suggestion to make it generic came up right around the
> Emacs-23 freeze, which is why it didn't happen. If someone wants to
> make this generic *right now* he'd better hurry.
Ok, here it is (attached to this mail). I removed all cc-mode
dependencies (which were all about XEmacs and old emacs version
compatibility anyway).
Is it ok to commit?
If yes, how do I do that with CVS? cvs delete progmodes/cc-subword.el
and cvs add subword.el? There seems to be no renaming command.
And what do I have to write into the ChangeLog?
Bye,
Tassilo
[-- Attachment #2: subword.el --]
[-- Type: application/emacs-lisp, Size: 9804 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 19:24 ` Tassilo Horn
@ 2009-11-19 21:31 ` Stefan Monnier
2009-11-20 7:25 ` Tassilo Horn
2009-11-20 15:09 ` Chong Yidong
2009-11-20 16:10 ` Dan Nicolaescu
2 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2009-11-19 21:31 UTC (permalink / raw)
To: Giuseppe Scrivano; +Cc: emacs-devel
>>> I think this feature is generally useful and has nothing to do with
>>> C, so I propose to rename it (and its commands and the file) to
>>> `subword-mode' or `camelcase-mode'.
>> IIRC the same suggestion to make it generic came up right around the
>> Emacs-23 freeze, which is why it didn't happen. If someone wants to
>> make this generic *right now* he'd better hurry.
> Ok, here it is (attached to this mail). I removed all cc-mode
> dependencies (which were all about XEmacs and old emacs version
> compatibility anyway).
> Is it ok to commit?
It needs to add some compatibility aliases or adjust the CC-mode (and
maybe other?) code that refers to those functions with their old name.
Also, I'd prefer to rename the functions so that they all share
a `subword-' prefix.
> If yes, how do I do that with CVS? cvs delete progmodes/cc-subword.el
> and cvs add subword.el?
Yes. Please make sure you commit the add and the delete as a single
commit rather than as two separate commits.
> There seems to be no renaming command.
Indeed, there's no support for renaming.
> And what do I have to write into the ChangeLog?
Usually I write one entry for the new name that says something like
"Rename from <oldname>". You can also add second entry for the old name
that says "Rename to <newname>". You'll also want to add to the entry
for the new name the changes performed (renaming of the functions, ...),
of course.
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 21:31 ` Stefan Monnier
@ 2009-11-20 7:25 ` Tassilo Horn
2009-11-20 13:43 ` Eli Zaretskii
2009-11-20 14:22 ` Stefan Monnier
0 siblings, 2 replies; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 7:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Giuseppe Scrivano, emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> Is it ok to commit?
>
> It needs to add some compatibility aliases or adjust the CC-mode (and
> maybe other?) code that refers to those functions with their old name.
I've grepped all code, and it seems to be only cc-mode. There, I
changed the code to use the new names.
> Also, I'd prefer to rename the functions so that they all share
> a `subword-' prefix.
In general I agree, but in this case I think fitting to naming of the
word movement functions is more desirable.
I'll try to compile emacs with those changes now, and then I'll commit.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 7:25 ` Tassilo Horn
@ 2009-11-20 13:43 ` Eli Zaretskii
2009-11-20 14:05 ` Tassilo Horn
2009-11-20 14:22 ` Stefan Monnier
1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2009-11-20 13:43 UTC (permalink / raw)
To: Tassilo Horn; +Cc: emacs-devel, monnier, gscrivano
> From: Tassilo Horn <tassilo@member.fsf.org>
> Date: Fri, 20 Nov 2009 08:25:19 +0100
> Cc: Giuseppe Scrivano <gscrivano@gnu.org>, emacs-devel@gnu.org
>
> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
> >> Is it ok to commit?
> >
> > It needs to add some compatibility aliases or adjust the CC-mode (and
> > maybe other?) code that refers to those functions with their old name.
>
> I've grepped all code, and it seems to be only cc-mode. There, I
> changed the code to use the new names.
>
> > Also, I'd prefer to rename the functions so that they all share
> > a `subword-' prefix.
>
> In general I agree, but in this case I think fitting to naming of the
> word movement functions is more desirable.
>
> I'll try to compile emacs with those changes now, and then I'll commit.
It looks like you didn't make the necessary changes in
lisp/Makefile.in and lisp/makefile.w32-in. They still refer to
cc-subword.el and cc-subword.elc.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 13:43 ` Eli Zaretskii
@ 2009-11-20 14:05 ` Tassilo Horn
2009-11-20 14:13 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 14:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel, monnier, gscrivano
Eli Zaretskii <eliz@gnu.org> writes:
Hi Eli,
>> I'll try to compile emacs with those changes now, and then I'll
>> commit.
>
> It looks like you didn't make the necessary changes in
> lisp/Makefile.in and lisp/makefile.w32-in. They still refer to
> cc-subword.el and cc-subword.elc.
Oh, indeed. I've changed that right now.
Thanks for the pointer,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 14:05 ` Tassilo Horn
@ 2009-11-20 14:13 ` Eli Zaretskii
2009-11-20 14:31 ` Tassilo Horn
0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2009-11-20 14:13 UTC (permalink / raw)
To: Tassilo Horn; +Cc: emacs-devel, monnier, gscrivano
> From: Tassilo Horn <tassilo@member.fsf.org>
> Date: Fri, 20 Nov 2009 15:05:49 +0100
> Cc: emacs-devel@gnu.org, monnier@IRO.UMontreal.CA, gscrivano@gnu.org
>
> > It looks like you didn't make the necessary changes in
> > lisp/Makefile.in and lisp/makefile.w32-in. They still refer to
> > cc-subword.el and cc-subword.elc.
>
> Oh, indeed. I've changed that right now.
Thanks.
There's one other problem: compiling cc-cmds.el displays this warning:
In end of data:
cc-cmds.el:4575:1:Warning: the following functions are not known to be
defined: forward-subword, backward-subword
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 7:25 ` Tassilo Horn
2009-11-20 13:43 ` Eli Zaretskii
@ 2009-11-20 14:22 ` Stefan Monnier
2009-11-20 14:37 ` Tassilo Horn
1 sibling, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2009-11-20 14:22 UTC (permalink / raw)
To: Giuseppe Scrivano; +Cc: emacs-devel
> I've grepped all code, and it seems to be only cc-mode.
That was my impression as well.
> There, I changed the code to use the new names.
Great, thanks.
>> Also, I'd prefer to rename the functions so that they all share
>> a `subword-' prefix.
> In general I agree, but in this case I think fitting to naming of the
> word movement functions is more desirable.
No, this is a separate package not part of the core, so it has to follow
the coding convention of using a distinguished prefix.
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 14:13 ` Eli Zaretskii
@ 2009-11-20 14:31 ` Tassilo Horn
0 siblings, 0 replies; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 14:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gscrivano, monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> There's one other problem: compiling cc-cmds.el displays this warning:
>
> In end of data:
> cc-cmds.el:4575:1:Warning: the following functions are not known to be
> defined: forward-subword, backward-subword
I declare-functioned them, and the byte-compiler is quiet again.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 14:22 ` Stefan Monnier
@ 2009-11-20 14:37 ` Tassilo Horn
2009-11-20 16:07 ` Stefan Monnier
0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 14:37 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Giuseppe Scrivano, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
Hi Stefan!
>>> Also, I'd prefer to rename the functions so that they all share
>>> a `subword-' prefix.
>> In general I agree, but in this case I think fitting to naming of the
>> word movement functions is more desirable.
>
> No, this is a separate package not part of the core, so it has to
> follow the coding convention of using a distinguished prefix.
Ok, chief, I'll rename them all! ;-)
What naming do you have in mind? Simply turning around?
subword-backward-kill
subword-backward
subword-capitalize
subword-downcase
subword-forward
subword-kill
subword-mark
subwords-transpose
subword-upcase
Or keep the names and only add a prefix?
subword-backward-kill-subword
subword-backward-subword
subword-capitalize-subword
subword-downcase-subword
subword-forward-subword
subword-kill-subword
subword-mark-subword
subword-transpose-subwords
subword-upcase-subword
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 19:24 ` Tassilo Horn
2009-11-19 21:31 ` Stefan Monnier
@ 2009-11-20 15:09 ` Chong Yidong
2009-11-20 15:34 ` Tassilo Horn
2009-11-20 16:10 ` Dan Nicolaescu
2 siblings, 1 reply; 20+ messages in thread
From: Chong Yidong @ 2009-11-20 15:09 UTC (permalink / raw)
To: emacs-devel; +Cc: Giuseppe Scrivano, Stefan Monnier
Tassilo Horn <tassilo@member.fsf.org> writes:
> Ok, here it is (attached to this mail). I removed all cc-mode
> dependencies (which were all about XEmacs and old emacs version
> compatibility anyway).
The file should go into progmodes/, not the main lisp/ directory.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 15:09 ` Chong Yidong
@ 2009-11-20 15:34 ` Tassilo Horn
2009-11-20 21:36 ` Chong Yidong
0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 15:34 UTC (permalink / raw)
To: Chong Yidong; +Cc: Giuseppe Scrivano, Stefan Monnier, emacs-devel
Chong Yidong <cyd@stupidchicken.com> writes:
Hi!
>> Ok, here it is (attached to this mail). I removed all cc-mode
>> dependencies (which were all about XEmacs and old emacs version
>> compatibility anyway).
>
> The file should go into progmodes/, not the main lisp/ directory.
I don't think so. CamelCase in words is common in programming
languages, but not restricted to them. I enabled global-subword-mode,
because I want this behavior also when writing mail or plain text files.
Of course, YMMV, and if you still think it should go into progmodes/,
I'll move it there.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 14:37 ` Tassilo Horn
@ 2009-11-20 16:07 ` Stefan Monnier
2009-11-20 17:19 ` Tassilo Horn
0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2009-11-20 16:07 UTC (permalink / raw)
To: Giuseppe Scrivano; +Cc: emacs-devel
> What naming do you have in mind? Simply turning around?
Ys, except for ..
> subword-backward-kill
> subword-backward
> subword-capitalize
> subword-downcase
> subword-forward
> subword-kill
> subword-mark
> subwords-transpose
^^^^^^^^
No s at the end.
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-19 19:24 ` Tassilo Horn
2009-11-19 21:31 ` Stefan Monnier
2009-11-20 15:09 ` Chong Yidong
@ 2009-11-20 16:10 ` Dan Nicolaescu
2009-11-21 0:44 ` Miles Bader
2 siblings, 1 reply; 20+ messages in thread
From: Dan Nicolaescu @ 2009-11-20 16:10 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Giuseppe Scrivano, emacs-devel
Tassilo Horn <tassilo@member.fsf.org> writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> Hi Stefan,
>
> >> I think this feature is generally useful and has nothing to do with
> >> C, so I propose to rename it (and its commands and the file) to
> >> `subword-mode' or `camelcase-mode'.
> >
> > IIRC the same suggestion to make it generic came up right around the
> > Emacs-23 freeze, which is why it didn't happen. If someone wants to
> > make this generic *right now* he'd better hurry.
>
> Ok, here it is (attached to this mail). I removed all cc-mode
> dependencies (which were all about XEmacs and old emacs version
> compatibility anyway).
BTW, I think this mode should also be listed in `mode-line-mode-menu',
glasses-mode which helps in similar ways is listed there.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 16:07 ` Stefan Monnier
@ 2009-11-20 17:19 ` Tassilo Horn
0 siblings, 0 replies; 20+ messages in thread
From: Tassilo Horn @ 2009-11-20 17:19 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Giuseppe Scrivano, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> What naming do you have in mind? Simply turning around?
>
> Ys, except for ..
>
>> subword-backward-kill
>> subword-backward
>> subword-capitalize
>> subword-downcase
>> subword-forward
>> subword-kill
>> subword-mark
>> subwords-transpose
> ^^^^^^^^
> No s at the end.
Sure, I'll do it after lunch.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 15:34 ` Tassilo Horn
@ 2009-11-20 21:36 ` Chong Yidong
0 siblings, 0 replies; 20+ messages in thread
From: Chong Yidong @ 2009-11-20 21:36 UTC (permalink / raw)
To: emacs-devel; +Cc: Giuseppe Scrivano, Stefan Monnier
Tassilo Horn <tassilo@member.fsf.org> writes:
> I don't think so. CamelCase in words is common in programming
> languages, but not restricted to them. I enabled global-subword-mode,
> because I want this behavior also when writing mail or plain text files.
The cap-words, glasses, and hideshow packages are also in progmodes/.
Being in that directory does not mean the package is *only* useful for
programming, just that it's mostly useful for it.
Subword mode should go into progmodes/.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CamelHump word movement in Emacs
2009-11-20 16:10 ` Dan Nicolaescu
@ 2009-11-21 0:44 ` Miles Bader
0 siblings, 0 replies; 20+ messages in thread
From: Miles Bader @ 2009-11-21 0:44 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel, Stefan Monnier, Giuseppe Scrivano
Hmm, how about
(defalias 'studly-caps-mode 'subword-mode)
(defalias 'sTuDLyCapS-mode 'subword-mode)
?
--
Bacchus, n. A convenient deity invented by the ancients as an excuse for
getting drunk.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2009-11-21 0:44 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-19 8:46 CamelHump word movement in Emacs Tassilo Horn
2009-11-19 8:57 ` Giuseppe Scrivano
2009-11-19 11:05 ` Tassilo Horn
2009-11-19 15:22 ` Stefan Monnier
2009-11-19 19:24 ` Tassilo Horn
2009-11-19 21:31 ` Stefan Monnier
2009-11-20 7:25 ` Tassilo Horn
2009-11-20 13:43 ` Eli Zaretskii
2009-11-20 14:05 ` Tassilo Horn
2009-11-20 14:13 ` Eli Zaretskii
2009-11-20 14:31 ` Tassilo Horn
2009-11-20 14:22 ` Stefan Monnier
2009-11-20 14:37 ` Tassilo Horn
2009-11-20 16:07 ` Stefan Monnier
2009-11-20 17:19 ` Tassilo Horn
2009-11-20 15:09 ` Chong Yidong
2009-11-20 15:34 ` Tassilo Horn
2009-11-20 21:36 ` Chong Yidong
2009-11-20 16:10 ` Dan Nicolaescu
2009-11-21 0:44 ` Miles Bader
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).