emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subword-mode


From: Tassilo Horn
Subject: Re: subword-mode
Date: Wed, 25 Nov 2009 08:58:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Miles Bader <address@hidden> writes:

> Stefan Monnier <address@hidden> writes:
>> I just bumped into find-word-boundary-function-table, which lead me to
>> its only user: cap-words.el.
>>
>> It seems both subword.el and cap-words.el provide the same feature (tho
>> cap-words.el is obviously not good at advertising itself, ahem).
>
> Given that it's only about 3 lines long, and apparently works by
> taking advantage of some existing low-level mechanism, cap-words.el
> seems by far the more elegant implementation...
>
> However.... it doesn't seem to actually work correctly in many cases;
> perhaps the low-level feature has bit-rotted?
>
> E.g.: given the example word in the file "capitalizedWorDD", and turning
> on `capitalized-words-mode', moving _backwards_ from the end of the
> string with M-b stops at the first "D", then the "W', then the beginning
> "c" -- that's correct except that it should have stopped at the second
> "D" first.  However moving _forwards_ from the beginning with M-f, it
> only stops at the second "D".

It looks to me that those differences come from the regexps used.
cap-words uses those simple ones

  "\\=.\\w*[[:upper:]]" (forward)
  "[[:upper:]]\\w*\\="  (backward)

and subword uses those more elaborated ones

  "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" (forward)
  "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)"
  (backward)

Maybe just putting the subword regexps in cap-words.el achieves the
desired behavior.  If that's the case, then I agree with Miles that the
cap-words approach is more elegant.

If so, we should rename cap-words.el to subword.el.  Additionally, the
docs of cap-words need to be polished, because there it seems to be
intended to stop at each capital letter, but in general that's not
desired.  

With (the current) subword.el, the stop points are

    fooBarBAZ
    ^  ^  ^  ^

which seems correct to me and matches the behavior of Eclipse or
IntelliJ.

Ah, and of course, I'd volunteer to test and do that changes, although I
probably won't do it before the weekend.

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]