help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: (X)Emacs abbrev mode


From: Stefan Monnier
Subject: Re: (X)Emacs abbrev mode
Date: Wed, 24 Feb 2010 16:48:31 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

>>> I was wondering if you could tell me why the following works in XEmacs and
>>> not in Emacs.
>> Because Emacs only accepts "words" as abbreviations by default.
>> If you want to support something else (i.e. abbreviations that contains
>> chars that are not marked as words in the syntax-table), then you need
>> to tweak your abbreviation table by setting its :regexp property.
> as this question comes into my mind from time to time: is there any reason
> to limit the chars usable as abbrevs at all?

Obviously, no good one since XEmacs does it.
As for the not-so-good ones:
- limiting them to word-chars means that you can just "grab the word
  before point" and then "look it up in the table".  Whereas XEmacs
  can't do that and has to loop through the table and check each and
  every abbrev to see if the text before point happens to be one
  of them.
- there is implicitly a notion of "boundary" that's important.  E.g. if
  "foo" is an abbrev, you don't want it to apply to "afoo".  OTOH you do
  want it to apply to ",foo".  The abbrev definition never makes this
  boundary specification clear.  IIUC XEmacs uses a heuristic which is
  that if the abbrev starts with a word-component then it only matches
  if the char before is not itself a word-component (i.e. this
  reproduces the convention used in Emacs) and that if the first char of
  the abbrev is not a word-component than it is its own boundary so an
  abbrev "\foo" will also be expanded when the text before point is
  "\\foo" for example.


-- Stefan


reply via email to

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