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.
First, I'm pretty sure make-local-hook needs to be called.
This is the definition of add-hook in 21.4.22. add-hook calls
local-variable-if-set-p to check the hook is defined locally, and if
defined locally then the local value is set, otherwise the global
value is set.
(defun add-hook (hook function &optional append local)
...
(if (or local
;; Detect the case where make-local-variable was used on a hook
;; and do what we used to do.
(and (local-variable-if-set-p hook (current-buffer)) ; XEmacs
(not (memq t (symbol-value hook)))))
;; Alter the local value only.
(...)
;; Alter the global value (which is also the only value,
;; if the hook doesn't have a local value).
...))
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
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta