On Tue, 5 Nov 2002, Ville Skyttä wrote:
On Mon, 2002-11-04 at 23:50, Alan Mackenzie wrote: 
> XEmacs 21.4.4: 
Hmm, you might want to try this out with 21.4.10, it has some
syntax-table related changes which will AFAICT probably end up in the
next stable version of XEmacs (21.4.11?). 
Ah.  I don't actually have 21.4.10 at the moment, and I've only a modem
with which to get it.  I don't really want to delve too deeply into
XEmacs's C-code myself.  But...
Forgive me for reporting this bug without providing a recipe for
recreating it.  That I will now do.
1.  Compile the following function:
(defun bsc-bug-after-change (beg end old-len)
  "After-change function for demonstrating a buffer-syntactic-context bug.
Start off by wiping syntax-table text-properties from the line.  If there is a
matched pair of /s, give each of them s-t prop (7) (i.e. \"string\").  If there
is a _single_ /, give it (and any eol) s-t prop (15) (i.e.
\"string-fence\")."
  (save-excursion
    (save-match-data
      (let ((eol (progn (goto-char end)
                        (end-of-line)
                        (point))))
        (goto-char beg)
        (beginning-of-line)
        (put-text-property (point) eol 'syntax-table nil)
        (cond ((search-forward-regexp "\\(/\\)[^/]*\\(/\\)" eol t)
               (put-text-property (match-beginning 1) (match-end 1)
                                  'syntax-table '(7))
               (put-text-property (match-beginning 2) (match-end 2)
                                  'syntax-table '(7)))
              ((search-forward-regexp "/" eol t)
               (put-text-property (match-beginning 0) (match-end 0)
                                  'syntax-table '(15))
               (if (eq (char-after eol) ?\n)
                   (put-text-property eol (1+ eol) 'syntax-table '(15))))
              (t))))))
2:  Create an empty buffer in fundamental mode.
3:  Enable syntax-table properties:
    (make-local-variable 'lookup-syntax-properties)
    (setq lookup-syntax-properties t)
4:  Install the after-change-function for this buffer:
    (make-local-hook 'after-change-functions)
    (add-hook 'after-change-functions 'bsc-bug-after-change nil t)
5:  Type the following, character by character, into the buffer:
    /regexp/ {
    (with or without a CR at the eol).
6:  Place the cursor on the {, and do M-: (buffer-syntactic-context).
    The result is 'string; it ought to be nil.
As I said, I suspect the reason for this result is that some sort of
cacheing mechanism in b-s-c has remembered that the first / has
string-fence syntax although its updated syntax is now string.
-- 
\/ille Skyttä
scop at 
xemacs.org 
-- 
Alan Mackenzie (Munich, Germany)