Subject: bug#5805: 23.3 abbrev-insert needs a limited save-excursion

From: Stefan Monnier <[email-masked]>
Date: Thu, 07 Jul 2011 21:03:03 -0400

> Here are two patches that do what I explained above. I am new to elisp
> so be kind :-) Note that these apply against the trunk (sorry to be
> switching back of forth).

I still haven't thought about the save-excursion issue, but for the
other, I think the fix should be complete in viper without changing
expand-abbrev.
The way it work in "normal Emacs" is the self-insert-command only calls
expand-abbrev if (as its docstring explains) the char inserted doesn't
have word syntax and the previous one does.  The corresponding code
(it's in C):

  if (!NILP (BVAR (current_buffer, abbrev_mode))
      && synt != Sword
      && NILP (BVAR (current_buffer, read_only))
      && PT > BEGV
      && (SYNTAX (!NILP (BVAR (current_buffer, enable_multibyte_characters))
		  ? XFASTINT (Fprevious_char ())
		  : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ())))
	  == Sword))
    {

-- Stefan