summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-07 18:05:45 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-17 16:59:56 +0200
commitf173f5c12fe3f8741451ae643ab56320c112fc52 (patch)
tree2759b7306d549e4d40075b6fe2582fd9ef116d90
parent3260c403de194f3001e1ffac32ab32c7bc79d481 (diff)
downloadluatexbase-f173f5c12fe3f8741451ae643ab56320c112fc52.tar.gz
make user whatsit generators accept an optional argument of type node
-rw-r--r--luatexbase-attr.dtx18
1 files changed, 16 insertions, 2 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 499677d..3e01827 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -529,10 +529,24 @@ local new_user_whatsit = function (name, package)
local whatsit = newnode(whatsit_t, user_defined_t)
whatsit.user_id = id
--- unit -> node_t
- return function ( ) return copynode(whatsit) end, id
+ local generator = function (proto)
+ local res
+ if proto then
+ local proto_id = proto.user_id
+ if proto_id ~= id then --- mismatch
+ warning("overriding user_id %d of whatsit prototype (now: %d)",
+ proto.user_id, id)
+ end
+ res = copynode(proto)
+ res.user_id = id
+ else
+ res = copynode(whatsit)
+ end
+ return res
+ end
+ return generator, id
end
luatexbase.new_user_whatsit = new_user_whatsit
-luatexbase.new_user_whatsit_factory = new_user_whatsit --- for Stephan
% \end{macrocode}
%
% If one knows the name of a user whatsit, its corresponding id