From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GH1RI0Xn5mE/KgEAgWs5BA (envelope-from ) for ; Tue, 18 Jan 2022 17:13:57 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4GCFIEXn5mEUTgEA9RJhRA (envelope-from ) for ; Tue, 18 Jan 2022 17:13:57 +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 5056A3C2B8 for ; Tue, 18 Jan 2022 17:13:57 +0100 (CET) Received: from localhost ([::1]:34142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9r7M-0003gl-7l for larch@yhetil.org; Tue, 18 Jan 2022 11:13:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9q95-0003xA-Ns for emacs-orgmode@gnu.org; Tue, 18 Jan 2022 10:11:39 -0500 Received: from mail.hostpark.net ([212.243.197.30]:35408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9q92-0007NM-BJ for emacs-orgmode@gnu.org; Tue, 18 Jan 2022 10:11:39 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 820A2165CB for ; Tue, 18 Jan 2022 16:11:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=sel2011a; t=1642518690; bh=XhaA/jjPmJPoESF d3ovn+pZ/tqEgm+K33tbiKt+DKOE=; b=hiwSUaghLlK+03WdcAXeVFV7CsL99on I5kFkIqao5e7Z77t5jKZI2vFwJb8+d1UdATdVFaXUBxP2Vvg/K+I8dAjFxE5ZlRB LZ+U1ZrkPZ3uUHDut9SXQnU0XTI1XNVJ0ur3GdKocExg60HV15/c7uhjoSwhNFp5 0ii7Qd+DONWY= 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 H4zPVYW8KLvo for ; Tue, 18 Jan 2022 16:11:30 +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 X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 4B03E16BAC for ; Tue, 18 Jan 2022 16:11:30 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v3 1/3] ox-texinfo: Add function for use by kbd macro Date: Tue, 18 Jan 2022 16:11:27 +0100 Message-Id: <20220118151129.19646-2-jonas@bernoul.li> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118151129.19646-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220118151129.19646-1-jonas@bernoul.li> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , 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=1642522437; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=+DoW0OU6WHwKaKAydPbMe+I1To1yFHcNfnm5hnM4WV8=; b=E5EiltvXFik99SY2bPwhnsr0ETFjoCLTnVc77pq26dXNgp8HTCDX4AKjO2SGOMCcoH5f77 2TLolbIVOQmI54UrkOY8hXuofp4Rqh7Z/wPhmqN78tgbeSYM9f4LjDCvVInXGIk7PvigtA 1YwCDLYNhFur2WpfrbORLDRn7kWPur6lFJQkUhrhMRsMoNhsdnb8pjMl+TaTXY6IPZnIef vDgfFuhAPjTf+Ujcpu+IC0vjw2DLDwT3TXnBI3mRHAjDiQry3Buh18jQSGeaYJ+4bi5ztV nUPue7+ny8a+gY3jmIwsOlhqL8gGGgEd6+mo7QZThK6cTWs4YjLA1+6AW5dWSw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642522437; a=rsa-sha256; cv=none; b=mB1BWCpO2gLN4TZczf2sunEKF84wv+SSFeBCT/whOQufEcOaNMjtafF9ll3D87y2T7ngS6 nTRHTup9McpBFC90wDGkMUVJCzKQzVx+zMu87u9mA/xAI41GtdQOyLqu/S035C+wv5OqzZ 3neW59kCDyG3//jkIe2oBW7l9PoY/O8tiDxThAXw7RRUyE040JzFrlj7LilR4fMOUlUWm1 txbneAxRahHwNCFmbupr5NOOnEuRObWour8zNwG6Udu4aF7sRHB6o7yw8NSccKlwDkW+lD kqw5C6l6RSSPuXy5IQIl4bHcperueBKyfFBLahyTPFqmBJFZhBTuvtF/guhgng== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=hiwSUagh; 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: -2.42 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=hiwSUagh; 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: 5056A3C2B8 X-Spam-Score: -2.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: pU5oiuUxK76V * doc/doc-setup.org: Use org-texinfo-kbd-macro for kbd macro. * doc/org-manual.org: Add new node "Key bindings in Texinfo export". * lisp/ox-texinfo.el (org-texinfo-kbd-macro): New function. --- doc/doc-setup.org | 2 +- doc/org-manual.org | 27 +++++++++++++++++++++++++++ lisp/ox-texinfo.el | 23 ++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/doc/doc-setup.org b/doc/doc-setup.org index f59660e8e..59ad0eb60 100644 --- a/doc/doc-setup.org +++ b/doc/doc-setup.org @@ -49,5 +49,5 @@ # The "kbd" macro turns KBD into @kbd{KBD}. Additionally, it # encloses case-sensitive special keys (SPC, RET...) within @key{...}. -#+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)))) +#+macro: kbd (eval (org-texinfo-kbd-macro $1)) diff --git a/doc/org-manual.org b/doc/org-manual.org index b65e2f173..a5aac7d61 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -15353,6 +15353,33 @@ your king. ,#+END_QUOTE #+end_example +*** Key bindings in Texinfo export +:PROPERTIES: +:DESCRIPTION: @@kbd Texinfo command. +:END: + +Org does not provide any markup for key bindings that corresponds to +Texinfo's ~@kbd~ and ~@key~ commands. One way to deal with this is to +fall back to code syntax. =~C-x SPC~=, for example, is transcoded to +~@code{C-x SPC}~. + +A better approach is to define and use an Org macro named ~kbd~. To +make that easier the function ~org-texinfo-kbd-macro~ is provided, +which is intended to be used like this: + +#+begin_example +#+macro: kbd (eval (org-texinfo-kbd-macro $1)) + +Type {{{kbd(C-c SPC)}}}. +#+end_example + +#+texinfo: @noindent +which becomes + +#+begin_example +Type @kbd{C-c @key{SPC}}. +#+end_example + *** Special blocks in Texinfo export :PROPERTIES: :DESCRIPTION: Special block attributes. diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index b0125894a..57cbcf6ad 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1611,7 +1611,28 @@ (defun org-texinfo-verse-block (_verse-block contents _info) (format "@display\n%s@end display" contents)) -;;; Interactive functions +;;; Public Functions + +(defun org-texinfo-kbd-macro (key &optional noquote) + "Quote KEY using @kbd{...} and if necessary $key{...}. + +This is intended to be used as an Org macro like so: + + #+macro: kbd (eval (org-texinfo-kbd-macro $1)) + Type {{{kbd(C-c SPC)}}}. + +Also see info node `(org)Key bindings in Texinfo export'. + +If optional NOQOUTE is non-nil, then do not add the quoting +that is necessary when using this in an Org macro." + (format (if noquote "@kbd{%s}" "@@texinfo:@kbd{@@%s@@texinfo:}@@") + (let ((case-fold-search nil)) + (replace-regexp-in-string + org-texinfo--quoted-keys-regexp + (if noquote "@key{\\&}" "@@texinfo:@key{@@\\&@@texinfo:}@@") + key t)))) + +;;; Interactive Functions ;;;###autoload (defun org-texinfo-export-to-texinfo -- 2.34.1