Subject: bug#45944: 28.0.50; Mailabbrev sometimes hangs

From: Katsumi Yamaoka <[email-masked]>
Date: Tue, 19 Jan 2021 08:39:00 +0900

On Mon, 18 Jan 2021 09:10:31 +0900, Katsumi Yamaoka wrote:
> When expanding a mail abbrev in the message header of a message-
> mode buffer, it sometime hangs like it goes into an infinite loop.
[...]
> Though I haven't found out the cause of the problem so far,...

I found it.  `(forward-word 1)' in the `abbrev--before-point'
function takes a very long time for a certain mail body contents
(`hang' I wrote first was my misregarding).
Here is a recipe to reproduce the problem in `emacs -Q':

1. Create the ~/.mailrc file, if it is absent.
   The file needs to contain at least a line like this:

--8<---------------cut here---------------start------------->8---
foo [email-masked]
--8<---------------cut here---------------end--------------->8---

2. Eval this form in the *scratch* buffer.

--8<---------------cut here---------------start------------->8---
(with-current-buffer (get-buffer-create "*testing*")
  (erase-buffer)
  (insert "To: \n--text follows this line--\n\
________________________________________________________________\n")
  (message-mode)
  (mail-abbrevs-setup)
  (goto-char (point-min))
  (end-of-line)
  (pop-to-buffer (current-buffer)))
--8<---------------cut here---------------end--------------->8---

3. In To: header, enter "foo" or something another and type ",".

As far as I can observe, the more "____" line is long, the more
it takes a long time.

Thanks.