all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: Miles Bader <miles@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: subword-mode
Date: Wed, 25 Nov 2009 08:58:13 +0100	[thread overview]
Message-ID: <87638zkpd6.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: <buo3a4318mk.fsf@dhlpc061.dev.necel.com> (Miles Bader's message of "Wed, 25 Nov 2009 14:22:27 +0900")

Miles Bader <miles@gnu.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> 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	other threads:[~2009-11-25  7:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25  4:26 subword-mode Stefan Monnier
2009-11-25  5:22 ` subword-mode Miles Bader
2009-11-25  7:58   ` Tassilo Horn [this message]
2009-11-25  9:31     ` subword-mode Miles Bader
2009-11-25 14:19   ` subword-mode Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2014-10-25 11:47 subword-mode Sam Halliday

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

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

  git send-email \
    --in-reply-to=87638zkpd6.fsf@thinkpad.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.