From: Jeff Mincy <jeff(a)delphioutpost.com>
Date: Sat, 10 Nov 2012 17:19:55 -0500
From: Alan Mackenzie <acm(a)muc.de>
Date: Sat, 10 Nov 2012 20:45:06 +0000
Hi, Jeff.
I got your personal email. Thanks!
On Fri, Nov 09, 2012 at 01:24:03PM -0500, jeff-xemacs(a)delphioutpost.com wrote:
I've been having trouble with cc based modes for the past year.
After I open a .cc file then every other mode becomes infected with
c-before-change and c-after-change hooks.
c-basic-common-init does the following.
(or (memq 'add-hook-local c-emacs-features)
(make-local-hook 'before-change-functions))
...
(or (memq 'add-hook-local c-emacs-features)
(make-local-hook 'after-change-functions))
So if add-local-hook exists as a feature then we don't call it?
Shouldn't that 'or' be an 'and' or 'if'?
No. The meaning of (memq 'add-hook-local c-emacs-features) is "The LOCAL
parameter to `add-hook' works without first having to call
`make-local-hook'.".
Ah. The 'or' is correct with that definition. The problem must be
the presence of add-hook-local on c-emacs-features as you suggest
below.
...
This is the case for all modern GNU Emacsen and XEmacs 21.5, but not
XEmacs 21.4, I think. `make-local-hook' has been removed from Emacs-24,
hence the need to make calling it conditional.
The add-hook-local flag is set (in cc-defs.el) by actually testing the
effect of (add-hook 'x 'y nil t) on a test buffer.
I'm on 21.4.22, but I sort of doubt that matters.
See above.
It would seem that CC Mode has got something wrong with either the buffer
test or the use of `make-local-hook'. Does 'add-hook-local get added to
c-emacs-features in XEmacs 21.4.22? If it does, that is a bug. If it
doesn't, why isn't the call to `make-local-hook' working properly?
Yes, looks that way.
The value of c-emacs-features is:
(pps-extended-state add-hook-local gen-string-delim syntax-properties 8-bit)
Let me see what I can figure out looking at cc-defs.
-jeff
For me, on 21.4.22 this code copied from cc-defs returns t:
(let ((buf1 (generate-new-buffer " test1"))
(buf2 (generate-new-buffer " test2"))
changed)
(save-excursion ; Needed for XEmacs's byte compiler
(set-buffer buf1)
(add-hook 'after-change-functions
(lambda (beg end old-len) (setq changed t))
nil
t)
(set-buffer buf2)
(insert ?c)
(set-buffer buf1)
(remove-hook 'after-change-functions
(lambda (beg end old-len) (setq changed t))
t)
(kill-buffer buf1)
(kill-buffer buf2)
(not changed)))
t
This leads to 'add-hook-local being added to c-emacs-features By the
way, the add-hook-local value isn't documented in the documentation
string for c-emacs-features.
However, this code, where I split up the save-excursion returns nil
(let ((buf1 (generate-new-buffer " test1"))
(buf2 (generate-new-buffer " test2"))
changed)
(save-excursion ; Needed for XEmacs's byte compiler
(set-buffer buf1)
(add-hook 'after-change-functions
(lambda (beg end old-len) (setq changed t))
nil
t))
(save-excursion
(set-buffer buf2)
(insert ?c)
(set-buffer buf1)
(remove-hook 'after-change-functions
(lambda (beg end old-len) (setq changed t))
t))
(kill-buffer buf1)
(kill-buffer buf2)
(not changed))
nil
My hypothesis is that save-excursion does something that keeps the
global after-change-functions from being set until save-excursion
exits. Probably gc-pro or something. Maybe somebody else has a
better theory, and thus a better fix. I got lost in the unwind
protect and insdel C code. It's probably gcpro, since I don't
understand that voodoo.
-jeff
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta