[comp.emacs] abbrev-mode vs

jthomas@nmsu.CSNET (09/02/87)

(My apologies, but ...)
A month or so ago I posed the following question.  I have since been off the
list for a while during a move.  If there was an answer, I missed it.  Sorry.

The language modes use forms like:
  (insert "if " (read-string "<boolean-expression>: "))
to build skeleton constructs.  I use abbrev-mode for variable names, but
lose with the above forms because only the last word typed in gets expanded.
For example, I have abbrevs "ss"="StringSize" and "sl"="StringLength", if
I type "ss" for the above read-string, the result is "if StringSize", but
if I type "ss < sl", the result is "if ss < StringLength".

The string added by insert is treated as a single entity by abbrev-mode,
so only the last "word" is examined for expansion.

Am I missing something?  Or how can this be fixed (or is it that there's
no reasonable way)?

Jim Thomas		jthomas@nmsu.CSNET  (formerly JNTCS@UNO.BITNET)

jthomas@nmsu.CSNET (09/04/87)

Re: my message Message-Id: <8709031458.AA24875@tesuque>

> From: John Robinson <jr%lf-server-2.bbn.com>

> Something like this will do it, I think:

> (defun foo ()
>   (progn
>     (let ((beg (point)))
>       (insert "if " (read-string "<boolean-expression>: "))
>       (expand-region-abbrevs beg (point) 1))
>     ))

> /jr

Thank you, but...  I had considered using expand-region-abbrevs , but
the language mode really shouldn't have to know anything at all about
whether abbrev-mode is on or not.  Shouldn't abbrev-mode have to know
that insert (and presumably some other things) have to be redefined?
Or is that just as gross?

Jim Thomas	jthomas@nmsu.CSNET	formerly JNTCS@UNO.BITNET