From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sD46BMqk1WHJNAEAgWs5BA (envelope-from ) for ; Wed, 05 Jan 2022 15:01:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8FWkOMmk1WEMCQEAG6o9tA (envelope-from ) for ; Wed, 05 Jan 2022 15:01:45 +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 94EB1354E7 for ; Wed, 5 Jan 2022 15:01:45 +0100 (CET) Received: from localhost ([::1]:53220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n56rH-0007X1-Fz for larch@yhetil.org; Wed, 05 Jan 2022 09:01:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n56NC-000589-Ew for emacs-orgmode@gnu.org; Wed, 05 Jan 2022 08:30:46 -0500 Received: from mail.hostpark.net ([212.243.197.30]:46980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n56N3-0001VO-HI for emacs-orgmode@gnu.org; Wed, 05 Jan 2022 08:30:34 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id A3D70163FC for ; Wed, 5 Jan 2022 14:30:27 +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=1641389425; bh=XhaA/jjPmJPoESF d3ovn+pZ/tqEgm+K33tbiKt+DKOE=; b=gUNcm7TM2OS/kz0YlElAtRHFloclIHU 4h0fihVLjLxFqCJkEcBVqLXaJAWj2vnuPwUROa2UU22up1M6KRpW0WnUQdgDaqEV fhAc6yoGlLElvoiSO5eByTDGO3NgjooGeS9zFjWFFFtvku6lDXeqBsz74YstdmTo JyxgWjh3+DWU= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id 2iq9NYvhgpPl for ; Wed, 5 Jan 2022 14:30:25 +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 695C21647F for ; Wed, 5 Jan 2022 14:30:25 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v2 1/3] ox-texinfo: Add function for use by kbd macro Date: Wed, 5 Jan 2022 14:30:23 +0100 Message-Id: <20220105133025.12624-2-jonas@bernoul.li> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220105133025.12624-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220105133025.12624-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=1641391305; 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=auGLAZpb7ENQZdtJ9K0wmvnZMq7JZ7FwrdUTPaZNuTICXBMoBcfVi6+47elmldn1DGXoXm TrM/XQVH0s8b95d/cwMPTPWa0OVw4J8LTG9GCr9sRffo60K+gxdGT94ZxHZaC8giC3PSsF y9fseI7+vJ9t8K+RF4sJAdXZHtABFGAGg/Pw/qpTfrApfPkjSxKoKmtdU6bFIcBB8l99+Y QbFQxUS+rngUZiDAsctEEngBVydkkQacqH1uYo0hERgCiI1eAU+Av2cCyyHaLIQlzzkgBc q5uFSoN+0kiTIEvla4ZFZ+gwpk6hX0LiSQ2FZpIMIZAWkw2JXpVWla3q4TTK1g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641391305; a=rsa-sha256; cv=none; b=MRtrrsLmrN0a1m3gGXODj4CylYBojCXHwVOoHKsVh39rSGPcgQvZS+KU0k9j2HAAdrunuX /1/XhLw138svxf9NWQN+zjySmh0CiBZKUTVGpPjU6/8bPwFIqXW2znGFu3kskMZ3Qbdvri OObWbl1e/fbFU+YVfvjKGXd51YG1Vx98miOZ8tkfnJK26s5fEScpN73100pikooD1u6h+e pDYHeTUj23Xv1ahu31b15VyD5c7y9FKGIJSps8vKf+SGGQu3zOeD1F/5jQrrHo/yIGbi0P KZOaaV/W1zNyoezOvw45IqKSFhudL/6MUhEw4EhxLIyqBC87Vz57/DTLvOa9Lw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=gUNcm7TM; 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.40 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=gUNcm7TM; 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: 94EB1354E7 X-Spam-Score: -2.40 X-Migadu-Scanner: scn1.migadu.com X-TUID: Vk2duvlBy6TO * 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