From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:306:f42::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aFJ0CDIBymGQVwEAgWs5BA (envelope-from ) for ; Mon, 27 Dec 2021 19:08:50 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wDETBTIBymFqhQEAauVa8A (envelope-from ) for ; Mon, 27 Dec 2021 19:08:50 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 922911C019 for ; Mon, 27 Dec 2021 19:08:49 +0100 (CET) Received: from localhost ([::1]:60830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1uQS-00014j-IL for larch@yhetil.org; Mon, 27 Dec 2021 13:08:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1uMz-00013U-CU for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 13:05:13 -0500 Received: from mail.hostpark.net ([212.243.197.30]:33150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1uMw-0001YW-UG for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 13:05:13 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id B865B165FE; Mon, 27 Dec 2021 19:05:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-type:content-type:mime-version:message-id:date:date :references:in-reply-to:subject:subject:from:from:received :received; s=sel2011a; t=1640628307; bh=b9kpcejySZnuE4qU430Pw4a1 5aJLGEd739EBjordzOs=; b=ZoFWsfpOsMBw/JNt7nNt9Z8r9MABoTN++NxU3265 WECJdeSxMVtGzOQ1XDFLrFWJ4l5Hcu4xSKdSO0tSqb0K+WGVNKnh0vbDkoXqM9Wm MqYgvYwNnu8knp3hzUElY4KlPLD70HXCac3x3ukcpVWXpwfiZnEI0b2VXZR7YxAD /zQ= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id gQ3qeagQQhrC; Mon, 27 Dec 2021 19:05:07 +0100 (CET) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 7E48C165AF; Mon, 27 Dec 2021 19:05:07 +0100 (CET) From: Jonas Bernoulli To: Nicolas Goaziou Subject: Re: [PATCH 2/2] ox-texinfo: Define definition commands using description lists In-Reply-To: <87sfuf9gz8.fsf@nicolasgoaziou.fr> References: <87pmqhmvg1.fsf@bernoul.li> <20211218214038.9459-1-jonas@bernoul.li> <20211218214038.9459-3-jonas@bernoul.li> <87sfuf9gz8.fsf@nicolasgoaziou.fr> Date: Mon, 27 Dec 2021 19:05:07 +0100 Message-ID: <87y2457wks.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: none client-ip=212.243.197.30; envelope-from=jonas@bernoul.li; helo=mail.hostpark.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kyle@kyleam.com, emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640628529; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=aeqARw1CzDDDYxqk3TgWsOoY+DxKeODY7/IZwahmVk4=; b=l51gR+nKGNVzYGxHLSrDXIJUrKHQRkbebztDCiHE2E+SQCgTkbb6NJfyl7c+VeY3S62wnh 73Lfg5EwWgTy+yzNXRUxtGNSml38Ac9+VpneEP9L6Bw+ZvMSwOUCWM0t8lY6rSus112uvf 3jBMQQazwIhTxUzRGey4Osk+bYRxTUpOo0+OY2m7xe6BH5vldQmWDMeWPAxGKs6igHLqmg CjHWsSp9IbLlhXEQWKcc1Wo0nT+V27SLQumATbsosGyQ80jJzvA0B0lxgc3zJAPQIUURHd cTyNoVHvhunndOQ0uB0t6926SXsSGPeBnrFkZcLU39S3+tZ6e2WmqakdTGiSjw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640628529; a=rsa-sha256; cv=none; b=QVb9oOt+bUhKM5PBIAMj+YE7rXbTYI+zeUBMyDrg8ox6S5yTU/3mCWdG9UZrmaBmIroPeZ khc8C+a8DQRJ1I1R0GCwuDJhg0okCEQSWUWkhWQWVR1b72l3UVQ+Lqjt7yu2U0s71Mig7K kfKLgRpO26HJ6W3bDNT7Azs449IBrJz2rldfHZz1yA1Kn2z8hpbe/516LUKlBKk5eTtIk8 GagbiP+kHm5LeoWuOH6/7dupZAqmjQ2GdbCUU2V3dLUDDWqiU0C63oH8JuOSje93OhnBk5 X+/naagoahsoAp6YNOZg6olEUAO7Z8/FzPLZQ5hXKlI9ZpX4psDLyDBpHRLFUQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=ZoFWsfpO; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.87 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=ZoFWsfpO; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 922911C019 X-Spam-Score: -3.87 X-Migadu-Scanner: scn1.migadu.com X-TUID: 1DxRwfQSChZ6 Nicolas Goaziou writes: > There's a mismatch between the keys. Fixed. > Simply put: > > Command in parenthesis, as done above, is optional. Done. >> +Regardless of which approach you use, you must define the =kbd= macro >> +(see [[*Macro Replacement]]), which you can then use anywhere in the Org >> +file: >> + >> +#+begin_example >> +,#+macro: kbd (eval (let ((case-fold-search nil) (regexp (regexp-opt '("SPC" "RET" "LFD" "TAB" "BS" "ESC" "DELETE" "SHIFT" "Ctrl" "Meta" "Alt" "Cmd" "Super" "UP" "LEFT" "RIGHT" "DOWN") 'words))) (format "@@texinfo:@kbd{@@%s@@texinfo:}@@" (replace-regexp-in-string regexp "@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t)))) >> #+end_example > > Ouch. I don't think we should expect users to define this in order to > use the feature being implemented. IOW, it should work out of the box. Luckily that's already how it works; I just chose to not document the fallback (done that now). If the macro is not available, then @code{} is used instead. > I think the functions responsible for generating the Texinfo code should > handle this without relying on the macro. I tried but could not get it to work that way. Whatever I tried ox-texinfo insisted on breaking it by adding quotes. I didn't go as far as to try injecting export-snippet elements into the tree because without using org-macro-replace-all it seemed painful to do that. But on second thought... Would it be okay to represent e.g. "C-c SPC" as: (export-snippet (:back-end "texinfo" :value "@kbd{C-c @key{SPC}}" :post-blank 0 :parent #2)) instead of the more painful to construct: (export-snippet (:back-end "texinfo" :value "@kbd{" :begin 317 :end 334 :post-blank 0 :parent #2)) #("C-c " 0 4 (:parent #2)) (export-snippet (:back-end "texinfo" :value "@key{" :begin 338 :end 355 :post-blank 0 :parent #2)) #("SPC" 0 3 (:parent #2)) (export-snippet (:back-end "texinfo" :value "}" :begin 358 :end 371 :post-blank 0 :parent #2)) (export-snippet (:back-end "texinfo" :value "}" :begin 371 :end 384 :post-blank 0 :parent #2)) > Of course, if that part is > factored out, the macro might, in turn, make use of it. >> +(defconst org-texinfo--definition-command-regexp >> + (format "\\`%s: \\(.+\\)" >> + (regexp-opt >> + (delq nil (mapcar #'cdr org-texinfo--definition-command-alist)) >> + 1)) > > What is 1 meaning here? Do you mean t? Yes. Done. >> +(defun org-texinfo--separate-definitions (tree _backend info) >> + "Split up descriptive lists that contain Texinfo definition >> commands." > > You need to document the arguments. >> + (org-element-map tree 'plain-list >> + (lambda (plain-list) >> + (when (eq (org-element-property :type plain-list) 'descriptive) >> + (let ((contents (org-element-contents plain-list)) >> + item items) > > Nitpick: (items nil) Done. >> + (while (setq item (pop contents)) > > nitpick: Use dolist. Err, that's what I would usually do. Not sure why not here. Done. >> + (if (string-match " +(\\([^()]+\\)) *\\'" args) > > Could you use `rx' here? Done. (Not a fan personally. IMO rx is less readable than a plain old regexp, though that's probably just because I never took the time to retrain myself.) >> + (setq key (substring args 0 (match-beginning 0)) >> + cmd (match-string 1 args)) >> + (setq key args)) >> + (org-element-put-property >> + item :tag >> + (nconc (if (assoc "kbd" org-macro-templates) >> + (let ((templates org-macro-templates)) >> + (with-temp-buffer >> + (insert (format "{{{kbd(%s)}}}" key)) > > Here, there could be a function building the key chord, and you could > wrap the result into a raw string (see `org-export-raw-string'). I think that is one of the things I tried that ox-texinfo insisted on quoting anyway. I might misremember, so I will have another look. Above I suggested using an `export-snippet' element (instead of `raw'); to me that seems appropriate too. Cheers, Jonas