From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id 5496021612 for ; Mon, 29 Jan 2024 16:35:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id B2E9C484404 for ; Mon, 29 Jan 2024 16:33:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id th31luq0YK4P for ; Mon, 29 Jan 2024 16:33:11 +0100 (CET) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id A9331484429 for ; Mon, 29 Jan 2024 16:32:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id A47CB484242 for ; Mon, 29 Jan 2024 16:31:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MvOkZObwgkPi for ; Mon, 29 Jan 2024 16:31:44 +0100 (CET) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 50C5A484241 for ; Mon, 29 Jan 2024 16:31:44 +0100 (CET) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-55efbaca48bso1555618a12.2 for ; Mon, 29 Jan 2024 07:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706542304; x=1707147104; darn=ntg.nl; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=Orh2euIyWFY4ROAIcykDYy85exZwuipBCnyIr0b+ocY=; b=Oy7zgKOukUWqSZH2DsTAfcUjGdAYHD04pRaUJFvDnfcXMNOsRM7w5MrItxEf/aJQsW 4DRHqh6xkPaqyyV4xjq9ck5H23F5JIEV4zpfniDdo7dbadbsbv+8wiAtgy+oPa2gUsU2 s0d9kC9s3oxdqAR980YgXU7MGDyUPF8U2nx3Y6/tuW83AzZYI+DRUAXYkZLUC7xFZR8K MFjbRLaLtQtG3id9k6gBp7LxIxGljJcqu9ErFYuycOEiWp9N4Hoi/MOGE7znO1KhX1xl on8q3aIVrYvs4dDY4K8H0qr2lNRRbeHoE8a4JHNDro+osN7Q40q5UBORJquV9w56l/1x r3Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706542304; x=1707147104; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Orh2euIyWFY4ROAIcykDYy85exZwuipBCnyIr0b+ocY=; b=BIGH9AAZraHN8FODPxZcpEEs+9D7mPwlV6wTB+oCW1yqlAcXKL/27dOUlBTlEYrqGW JfBdGtbTp8yt/dvi0MdYU+e8vqAA2flScrblYOyvIcDcLboWTIxPcFMUJP6tqdXhHcLZ 639Ut7rEHE+wjwxr8p48lkklEI9ZlDS+2pFKCsyy3VJD8tNm3NAYn6pMiaAV0DkGL+vh Xiit8mX9lVUffHns06yzPusCiRjY2wMWOL5utmqIFwAzkCx0yNENbWJ4dUmJIgcECgGe JhXeLnkabh43MpMWz2krCBhIPsq6l8CSSXogg7LsQt+YCvwE3nYapkfpGolGl6YbJlGW y/jg== X-Gm-Message-State: AOJu0Yy/esO/jn9va2RJYYRYA0lMKLGxO+boX+4OG8RTeLqdpOpI8dRp 9V+L5lGCnbZRyW27UpoIyaH6LJxnl7JLdUR6s4r6FtTY2ytYudrf X-Google-Smtp-Source: AGHT+IEdyhFDzzAe7lEuTz/JAn3cNIyMZj/9VlS7R92CP3CvQY9ijn8AxlLYjaXG66TvMc/zkzreGQ== X-Received: by 2002:a17:906:5fd7:b0:a30:d4f2:1603 with SMTP id k23-20020a1709065fd700b00a30d4f21603mr5516005ejv.15.1706542303573; Mon, 29 Jan 2024 07:31:43 -0800 (PST) Received: from ?IPv6:2a02:810d:a8bf:dc10::a6a1? ([2a02:810d:a8bf:dc10::a6a1]) by smtp.gmail.com with ESMTPSA id vx1-20020a170907a78100b00a358887f99esm1892920ejc.5.2024.01.29.07.31.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2024 07:31:43 -0800 (PST) To: mailing list for ConTeXt users , Gerion Entrup References: <2780043.ElGaqSPkdT@falbala> From: Wolfgang Schuster Message-ID: Date: Mon, 29 Jan 2024 16:31:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.60 MIME-Version: 1.0 In-Reply-To: <2780043.ElGaqSPkdT@falbala> Content-Language: en-US Message-ID-Hash: NICO7DD4M6IZTSENQR2VRT3BF5QSREUY X-Message-ID-Hash: NICO7DD4M6IZTSENQR2VRT3BF5QSREUY X-MailFrom: wolfgang.schuster.lists@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit Gerion Entrup schrieb am 25.01.2024 um 09:18: > Hi, > > I want to make a proper definition of a new command to be able to > process it in Lua. I found something on StackOverflow [1] but that > breaks in enumeration _and_ when interaction is enabled and I do not > understand why? Can you give me some help here? > > I want to make commands like \foo{bla} and \foo[b]{bla} possible at the > same time. Here is a minimal example (also attached): > > ``` > \startluacode > function userdata.my_command(keywords, text) > commands.writestatus("test", string.format("text: %s, config: %s", text, keywords)) > local cfg = utilities.parsers.settings_to_hash(keywords) > > if cfg['emph'] ~= nil then > context("\\emph{" .. text .. "}") > elseif cfg['bold'] ~= nil then > context("\\bold{" .. text .. "}") > else > context(text) > end > end > \stopluacode \startluacode function userdata.my_command(keywords, text) local keywords = utilities.parsers.settings_to_hash(keywords) if keywords['emph'] then context.emph(text) elseif keywords['bold'] then context.bold(text) else context(text) end end \stopluacode > % without that line there is no problem > \setupinteraction[state=start] > > \defineenumeration[enu][text=Enu] \defineenumeration[enu][text=Enu,title=yes] > \unprotect > \def\mc{\dosingleempty\do_my_command} > \def\do_my_command[#1]#2{% > \iffirstargument{% > \ctxlua{userdata.my_command('#1', [==[#2]==])}% > }\else {% > \ctxlua{userdata.my_command('', [==[#2]==])}% > }\fi > } > \protect \tolerant\protected\def\mc[#1]#2% {\ctxlua{userdata.my_command("#1","#2")}} Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________