[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] (Updated) Run hook when variable is set
From: |
Kelly Dean |
Subject: |
Re: [PATCH] (Updated) Run hook when variable is set |
Date: |
Wed, 18 Feb 2015 05:15:20 +0000 |
I wrote:
> it now spends half the time doing garbage collection.
I figured out how to solve the voidness problem without consing or specbinding
every time a hooked variable is set, and without usurping a keyword to
represent void. Simply use an uninterned symbol to represent void. Specifically:
DEFSYM (Qvoid_sentinel, "void-sentinel");
DEFVAR_LISP ("void-sentinel", Vvoid_sentinel,
doc: /* Representation of voidness for hooked variables.
The value of this constant is an uninterned Lisp symbol that represents void
when passed to or returned from `symbol-setter-function'.
When a variable is hooked, Emacs can't distinguish between setting it to this
value and making it unbound. Therefore, to prevent a difference of behavior
for hooked and unhooked variables, don't set any variable to this value. */);
Vvoid_sentinel = Fmake_symbol (build_string ("::void::"));
XSYMBOL (Qvoid_sentinel)->declared_special = true;
XSYMBOL (Qvoid_sentinel)->vetted = SYM_CONST;
Then at the end of run_varhook:
oldval = EQ (oldval, Qunbound) ? Vvoid_sentinel : oldval;
newval = EQ (newval, Qunbound) ? Vvoid_sentinel : newval;
newval = call4 (Vsymbol_setter_function, symbol, env, oldval, newval);
return EQ (newval, Vvoid_sentinel) ? Qunbound : newval;
Semantically, that's worse than consing or specbinding, but not as bad as
usurping a keyword. Is it ok to do it that way?
- Re: The purpose of makunbound, (continued)
- Re: The purpose of makunbound, Stephen J. Turnbull, 2015/02/19
- Re: The purpose of makunbound, Richard Stallman, 2015/02/19
- Re: The purpose of makunbound, Kelly Dean, 2015/02/20
- Re: The purpose of makunbound, Richard Stallman, 2015/02/20
- Re: The purpose of makunbound, Stephen J. Turnbull, 2015/02/21
- Re: The purpose of makunbound, Kelly Dean, 2015/02/21
- Re: The purpose of makunbound, Andreas Schwab, 2015/02/22
- Re: [PATCH] (Updated) Run hook when variable is set,
Kelly Dean <=
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/18
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/18
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/19
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/19
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/20
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/20
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/21
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/21
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/21
- Re: [PATCH] (Updated) Run hook when variable is set, Stephen J. Turnbull, 2015/02/22