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 yNcRGoR1+GFXrgAAgWs5BA (envelope-from ) for ; Tue, 01 Feb 2022 00:49:24 +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 GJPjEYR1+GFnmwAAG6o9tA (envelope-from ) for ; Tue, 01 Feb 2022 00:49:24 +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 BD1AB36095 for ; Tue, 1 Feb 2022 00:49:23 +0100 (CET) Received: from localhost ([::1]:33596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEgQE-0003Pv-M7 for larch@yhetil.org; Mon, 31 Jan 2022 18:49:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEgMo-0003Ml-Nj for emacs-orgmode@gnu.org; Mon, 31 Jan 2022 18:45:54 -0500 Received: from mail.hostpark.net ([212.243.197.30]:45132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEgMl-0001yn-7B for emacs-orgmode@gnu.org; Mon, 31 Jan 2022 18:45:50 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 9C55C164A8 for ; Tue, 1 Feb 2022 00:45:42 +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=1643672740; bh=V/2GQhsec5cAx3k PFH9wOuDrXDvVaF07FFpJst/bHWo=; b=LU+t8vXZYyGEfP66UQFVQbr8QeoNjDo kqkamP/N2p7k+QQLVSDTpMfs5S71wsoIKXoPP1Ejk6gPEoJjOS6wjo7dLEh+cUSP oYh53AmBhkd02S7oMR0l7I4LL7IaZx/Nput5Ig3ZaFzPO3dWCcG88nRgNuoJCvZK 8BOojOvBHZaA= 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 GQluLPJOYDhO for ; Tue, 1 Feb 2022 00:45:40 +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 61D58164BA for ; Tue, 1 Feb 2022 00:45:40 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v5 1/4] ox-texinfo: Add function for use by kbd macro Date: Tue, 1 Feb 2022 00:45:37 +0100 Message-Id: <20220131234540.762181-2-jonas@bernoul.li> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131234540.762181-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220131234540.762181-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, T_SCC_BODY_TEXT_LINE=-0.01 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=1643672963; 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=qnD4SizSKruHSG0v5gO7YvIK+RnyJQZ7Tvz9JDr937E=; b=CI/aFyJgFtYQXG7cPDIZ5Xj0dyA2dNmOHLVguHTqz1a5R8HC9ygLpRt7R8Q6829C+gcsNz 6u4KU2wpSY/hi9k1ZZIMwcWC0LzLTtlPfl5r0hIKlTMyfA19pha8IeJpDFFa6lV339KcSl Rrf2bISNJB50Qe8K+IUxl/rl8D/JnVR2KxdummzW7N6D8RxTilKfFcEoa7QJjSaYv/FbVj BwdRc1cv3zAyHfitcLNxMqL0ldsq/Jn43qPvi3EC7g4iQb874TYerRMBaQUhzjn+g0id1O +Kvo14bcsdLFIIYSPdhB7+FyPXTk+JqxV1jvZwCeDHGuKGn3xh3IHiZUyElfDA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643672963; a=rsa-sha256; cv=none; b=d0OG/EXEJhT0JdJdseN6571n034kKxROkZhXqWmjRUu1I5zInZF9mmmKXCjlwAyc20/tlc 9JBzIzF2j+++5wtHjje9LlNAiWb+GrZdxj8C4bmYK4nw10Xsag+AgWj2PrWfXRI2N3PgoB 0M4jNfhmKpzODuEtl88xJ4H5I3SPtR76jDk6Sy2sYphmWByL/c295G+10kJpm4N9tsBk7x DlW2PTxH3x1nZK/l4g3OMOLei4kA5OyEycdbKmaiqrCTqIk3b3xuQWlVZd77uCXEB1EZPx nsaaGzLDKPMe3XVSzHdBlo+et0kzRalffZQkMn2dJapZyPYwvLmfgQ6H+FMNbg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=LU+t8vXZ; 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: -7.33 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=LU+t8vXZ; 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: BD1AB36095 X-Spam-Score: -7.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9jMCYK95q2yI * 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--quoted-keys-regexp): New variable. * lisp/ox-texinfo.el (org-texinfo-kbd-macro): New function. --- doc/doc-setup.org | 2 +- doc/org-manual.org | 27 +++++++++++++++++++++++++++ lisp/ox-texinfo.el | 30 +++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/doc/doc-setup.org b/doc/doc-setup.org index 9d15505e2..786a0cb14 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 2c54fde87..bd11e05f6 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 46806ccca..ddd405d05 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -407,6 +407,13 @@ (defconst org-texinfo-inline-image-rules (regexp-opt '("eps" "pdf" "png" "jpg" "jpeg" "gif" "svg")))) "Rules characterizing image files that can be inlined.") +(defvar org-texinfo--quoted-keys-regexp + (regexp-opt '("BS" "TAB" "RET" "ESC" "SPC" "DEL" + "LFD" "DELETE" "SHIFT" "Ctrl" "Meta" "Alt" + "Cmd" "Super" "UP" "LEFT" "RIGHT" "DOWN") + 'words) + "Regexp matching keys that have to be quoted using @key{KEY}.") + ;;; Internal Functions @@ -1611,7 +1618,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.35.1