all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* What is the difference between `current-word' and `word-at-point'?
@ 2021-03-29  4:56 Marcin Borkowski
  2021-03-29  9:00 ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2021-03-29  4:56 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi all,

it seems Emacs has two functions with a very similar purpose,
`current-word' and `word-at-point'.  I understand some obvious
differences (like that `current-word' can treat "symbol" characters as
constituting a word or not, and `word-at-point' can give the current
word with the properties), but does anyone know

(a) why Emacs has both functions, and

(b) if/when their results can actually differ (apart from the obvious
cases like I mentioned)?

TIA,

-- 
Marcin Borkowski
http://mbork.pl



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

* Re: What is the difference between `current-word' and `word-at-point'?
  2021-03-29  4:56 What is the difference between `current-word' and `word-at-point'? Marcin Borkowski
@ 2021-03-29  9:00 ` Philip Kaludercic
  2021-03-29 14:56   ` [External] : " Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2021-03-29  9:00 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list


Marcin Borkowski <mbork@mbork.pl> writes:

> Hi all,
>
> it seems Emacs has two functions with a very similar purpose,
> `current-word' and `word-at-point'.  I understand some obvious
> differences (like that `current-word' can treat "symbol" characters as
> constituting a word or not, and `word-at-point' can give the current
> word with the properties), but does anyone know
>
> (a) why Emacs has both functions, and

I suppose that word-at-point is a simple extension of the thing-at-point
mechanism, that uses forward-word instead of the syntax table.

> (b) if/when their results can actually differ (apart from the obvious
> cases like I mentioned)?

One difference I could make out is that word-at-point respects
find-word-boundary-function-table (as it is implemented via
forward-word). This means that when something like subword-mode is
active and the buffer contains

       someCam|lCaseWord

where | is the point, (word-at-point) returns "Camel" while
(current-word) gives me "someCamelCaseWord".

> TIA,

-- 
	Philip K.



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

* RE: [External] : Re: What is the difference between `current-word' and `word-at-point'?
  2021-03-29  9:00 ` Philip Kaludercic
@ 2021-03-29 14:56   ` Drew Adams
  2021-03-29 15:01     ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2021-03-29 14:56 UTC (permalink / raw)
  To: Philip Kaludercic, Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

> I suppose that word-at-point is a simple extension of the thing-at-point
> mechanism, that uses forward-word instead of the syntax table.

<nit>The doc of `word-at-point' suggests that it
respects the syntax table.</nit>



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

* Re: [External] : Re: What is the difference between `current-word' and `word-at-point'?
  2021-03-29 14:56   ` [External] : " Drew Adams
@ 2021-03-29 15:01     ` Philip Kaludercic
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2021-03-29 15:01 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help Gnu Emacs mailing list

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

>> I suppose that word-at-point is a simple extension of the thing-at-point
>> mechanism, that uses forward-word instead of the syntax table.
>
> <nit>The doc of `word-at-point' suggests that it
> respects the syntax table.</nit>

Uh, yes that was unclear. forward-word says

        The word boundaries are normally determined by the buffer’s syntax
        table and character script (according to ‘char-script-table’), but
        ‘find-word-boundary-function-table’, such as set up by ‘subword-mode’,
        can change that.

so obviously it falls back onto the syntax table.

-- 
	Philip K.



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

end of thread, other threads:[~2021-03-29 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-29  4:56 What is the difference between `current-word' and `word-at-point'? Marcin Borkowski
2021-03-29  9:00 ` Philip Kaludercic
2021-03-29 14:56   ` [External] : " Drew Adams
2021-03-29 15:01     ` Philip Kaludercic

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.