unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* forward-word and NamesLikeThis
@ 2006-06-18 21:42 Gregory Novak
  2006-06-18 21:49 ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Gregory Novak @ 2006-06-18 21:42 UTC (permalink / raw)


For a while I've wanted to make forward-word stop at each word in
NamesLikeThis in programming modes.  That is, forward-word would stop
at the L and the T.

I finally got around to looking at syntax tables and concluded that
this isn't possible since Emacs considers each character separately,
rather than as pairs, when deciding where forward-word should move
to. 

If anyone can disprove this conclusion, I'd be grateful.   

Thanks!
Greg

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

* RE: forward-word and NamesLikeThis
  2006-06-18 21:42 Gregory Novak
@ 2006-06-18 21:49 ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2006-06-18 21:49 UTC (permalink / raw)


    For a while I've wanted to make forward-word stop at each word in
    NamesLikeThis in programming modes.  That is, forward-word would stop
    at the L and the T.

This doesn't speak to your question about syntax tables, but why not just
define your own replacement for `forward-word', for use in buffers where you
want this behavior?

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

* Re: forward-word and NamesLikeThis
       [not found] <mailman.3009.1150666977.9609.help-gnu-emacs@gnu.org>
@ 2006-06-18 23:20 ` Johan Bockgård
  2006-06-18 23:36 ` Benjamin Rutt
  1 sibling, 0 replies; 8+ messages in thread
From: Johan Bockgård @ 2006-06-18 23:20 UTC (permalink / raw)


Gregory Novak <novak@ucolick.org> writes:

> For a while I've wanted to make forward-word stop at each word in
> NamesLikeThis in programming modes. That is, forward-word would stop
> at the L and the T.

There is a "Subword Minor Mode" in CVS Emacs.

   [etc/NEWS]

    **** Subword Minor Mode makes Emacs recognize word boundaries at
    uppercase letters in StudlyCapsIdentifiers. You enable this
    feature by C-c C-w [in CC Mode]. It can also be used in non-CC
    Mode buffers. :-) Contributed by Masatake YAMATO.

-- 
Johan Bockgård

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

* Re: forward-word and NamesLikeThis
       [not found] <mailman.3009.1150666977.9609.help-gnu-emacs@gnu.org>
  2006-06-18 23:20 ` Johan Bockgård
@ 2006-06-18 23:36 ` Benjamin Rutt
  1 sibling, 0 replies; 8+ messages in thread
From: Benjamin Rutt @ 2006-06-18 23:36 UTC (permalink / raw)


Gregory Novak <novak@ucolick.org> writes:

> For a while I've wanted to make forward-word stop at each word in
> NamesLikeThis in programming modes.  That is, forward-word would stop
> at the L and the T.
>
> I finally got around to looking at syntax tables and concluded that
> this isn't possible since Emacs considers each character separately,
> rather than as pairs, when deciding where forward-word should move
> to. 
>
> If anyone can disprove this conclusion, I'd be grateful.   

look at 'c-forward-into-nomenclature and 'c-backward-into-nomenclature
for c, c++, java modes
-- 
Benjamin Rutt

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

* Re: forward-word and NamesLikeThis
       [not found] <mailman.3010.1150667368.9609.help-gnu-emacs@gnu.org>
@ 2006-06-19  0:07 ` B. T. Raven
  2006-06-19  2:12   ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: B. T. Raven @ 2006-06-19  0:07 UTC (permalink / raw)



"Drew Adams" <drew.adams@oracle.com> wrote in message
news:mailman.3010.1150667368.9609.help-gnu-emacs@gnu.org...
>     For a while I've wanted to make forward-word stop at each word in
>     NamesLikeThis in programming modes.  That is, forward-word would
stop
>     at the L and the T.
>
> This doesn't speak to your question about syntax tables, but why not
just
> define your own replacement for `forward-word', for use in buffers where
you
> want this behavior?
>
>
>

I thought that would be easy too, so I quickly typed out the following:

(defun forward-stud ()
 "Move point forward to next word or upper case character as the case may
be"
 (interactive)
 (while (not (looking-at " \|[A-Z]"))
  (forward-char))
 (forward-char)
)

This immediately moves point to the end of the buffer and dings. I know
that it dings because it tries to forward-char at the end of buffer but
why doesn't it stop at all characters following spaces and at upper case
characters. I have never used the \| before so I suppose something is
wrong with the regexp, but what?

Thanks,

Ed.

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

* RE: forward-word and NamesLikeThis
  2006-06-19  0:07 ` B. T. Raven
@ 2006-06-19  2:12   ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2006-06-19  2:12 UTC (permalink / raw)


    (defun forward-stud ()
     (interactive)
     (while (not (looking-at " \|[A-Z]")) (forward-char))
     (forward-char))
    why doesn't it stop at all characters following spaces and at upper case
    characters. I have never used the \| before so I suppose something is
    wrong with the regexp, but what?

Use two backslashes to insert a backslash in a Lisp string: \\|.

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

* Re: forward-word and NamesLikeThis
       [not found] <mailman.3013.1150683192.9609.help-gnu-emacs@gnu.org>
@ 2006-06-19  4:14 ` B. T. Raven
  2006-06-19  5:05 ` Johan Bockgård
  1 sibling, 0 replies; 8+ messages in thread
From: B. T. Raven @ 2006-06-19  4:14 UTC (permalink / raw)



"Drew Adams" <drew.adams@oracle.com> wrote in message
news:mailman.3013.1150683192.9609.help-gnu-emacs@gnu.org...
>     (defun forward-stud ()
>      (interactive)
>      (while (not (looking-at " \|[A-Z]")) (forward-char))
>      (forward-char))
>     why doesn't it stop at all characters following spaces and at upper
case
>     characters. I have never used the \| before so I suppose something
is
>     wrong with the regexp, but what?
>
> Use two backslashes to insert a backslash in a Lisp string: \\|.


Of course. Thanks. Now that it sort of works I can see that the approach
is hopelessly naive. If I needed such a thing I would use the
SubWordMinorMode suggested by Johan.  The latest cut, such as it is:

(defun forward-stud ()
 "Move point forward to next word or upper case character as the case may
be"
 (interactive)
 (forward-char)
 (while (not (looking-at " \\|[A-Z]"))
   (forward-char))
 (while (looking-at " ") (forward-char))
 (while (looking-at ";") (foward-line))
 (while (eolp) (forward-char))
)

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

* Re: forward-word and NamesLikeThis
       [not found] <mailman.3013.1150683192.9609.help-gnu-emacs@gnu.org>
  2006-06-19  4:14 ` forward-word and NamesLikeThis B. T. Raven
@ 2006-06-19  5:05 ` Johan Bockgård
  1 sibling, 0 replies; 8+ messages in thread
From: Johan Bockgård @ 2006-06-19  5:05 UTC (permalink / raw)



"Drew Adams" <drew.adams@oracle.com> writes:

> "B. T. Raven" <ecinmn@alcisp.com> writes:
>
>>      (while (not (looking-at " \|[A-Z]")) (forward-char))
[...]
> Use two backslashes to insert a backslash in a Lisp string: \\|.

Or simply use "[ A-Z]"...

-- 
Johan Bockgård

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

end of thread, other threads:[~2006-06-19  5:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3013.1150683192.9609.help-gnu-emacs@gnu.org>
2006-06-19  4:14 ` forward-word and NamesLikeThis B. T. Raven
2006-06-19  5:05 ` Johan Bockgård
     [not found] <mailman.3010.1150667368.9609.help-gnu-emacs@gnu.org>
2006-06-19  0:07 ` B. T. Raven
2006-06-19  2:12   ` Drew Adams
     [not found] <mailman.3009.1150666977.9609.help-gnu-emacs@gnu.org>
2006-06-18 23:20 ` Johan Bockgård
2006-06-18 23:36 ` Benjamin Rutt
2006-06-18 21:42 Gregory Novak
2006-06-18 21:49 ` Drew Adams

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