Subject: bug#4854: 23.1.50; before-string overlay and show-paren-mode

From: Stephen Berman <[email-masked]>
Date: Thu, 05 Nov 2009 00:08:00 +0100

Here's a slightly simpler test, which has partly different behavior from
the one I previously posted.

1. emacs -Q
2. eval this:
    (defun my-test ()
      (interactive)
      (unless (let ((ovlist (overlays-in (1- (point)) (1+ (point)))))
    	        (when ovlist (overlay-get (car ovlist) 'before-string)))
        (let ((ov (make-overlay (point) (point) nil)))
          (overlay-put ov 'before-string "* "))))
3. eval this:
    (global-set-key "\C-cy" 'my-test)
4. Insert the string "(test)" into a buffer, put the cursor on `('.
5. Type `C-c y' and/or `M-x my-test' any number of times: the overlay is
   added once only due to `unless', i.e. this is displayed:
   * (test)
6. Enable show-paren-mode
7. With the cursor still on `(', type `C-c y' repeatedly
=> each repetition adds an overlay, e.g. after three repetitions this is
   displayed (starting from the preceding display):
   * * * * (test)
8. With the cursor still on `(' and show-paren-mode still enabled, type
   `M-x my-test' repeatedly 
=> no overlays are added, i.e. the display remains unchanged

These two things seem very strange: (i) enabling show-paren-mode and
getting the show-paren overlay somehow nullifies the unless test; (ii)
this effect only happens when the command is invoked via a key sequence.

The result after step 7 seems to be a reproducible heisenbug, in that
stepping through my-test (called by typing `C-c y') with edebug does not
result in more than one overlay being added.  Also, unlike in my OP with
narrowing, with the above my-test, typing and deleting a self-inserting
character does not prevent repetitions of `C-c y' from adding more
overlays.

If anyone has any idea what's going on here, or how to debug it, I'd be
grateful.

Steve Berman