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 vtMdBP+67WHwHAEAgWs5BA (envelope-from ) for ; Sun, 23 Jan 2022 21:30:55 +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 aNTTOv667WGj7AAA9RJhRA (envelope-from ) for ; Sun, 23 Jan 2022 21:30:54 +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 A835C22B98 for ; Sun, 23 Jan 2022 21:30:54 +0100 (CET) Received: from localhost ([::1]:41296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBjVl-00018U-Iz for larch@yhetil.org; Sun, 23 Jan 2022 15:30:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBjSo-00017u-BB for emacs-orgmode@gnu.org; Sun, 23 Jan 2022 15:27:50 -0500 Received: from mail.hostpark.net ([212.243.197.30]:33718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBjSl-0003ot-TL for emacs-orgmode@gnu.org; Sun, 23 Jan 2022 15:27:49 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 726D5163CB for ; Sun, 23 Jan 2022 21:27:43 +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=1642969661; bh=hy4iwBHYI5Oy498 HAncNMFpy0g1NynVSEgl4Ne9d3CI=; b=GBS0PboXhHBmHLIa3l1mTlDajem6N1h 2+RQX4qAXMUnsBzbGT1TXFy7RlfZFctim2jBTsaoNmnZhF6q6mqtV2lHwJ3waBSw oVTIVKremHgln6FU1LBeBjhOdeoQLOxE890Y2QJ/zpqNjAVCUOfE5/x8SMRJpcjV uBwXyGDxjQUA= 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 poSxvVlkuw2r for ; Sun, 23 Jan 2022 21:27:41 +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 3099B1647F for ; Sun, 23 Jan 2022 21:27:41 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v4 1/3] ox-texinfo: Add function for use by kbd macro Date: Sun, 23 Jan 2022 21:27:38 +0100 Message-Id: <20220123202740.512619-2-jonas@bernoul.li> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220123202740.512619-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220123202740.512619-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.01, RCVD_IN_MSPIKE_WL=-0.01, 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=1642969854; 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=/OZbN5D/0KVuxzl2spvZY/xHNe7nP1Kx7bHk9byNLjw=; b=WqkDz6eUWz8Esdr6ZFkmI9epViq5y1mRwTKUSgFn4HFHEW135E0EWFzDa2IaQ+iKQh1ycs p96d5hVLxj7LIzEnDvxnanwzpZSQd6yNoAKur4x9o+MdwpBMWq6fTHtxIUhBCDOrzox/Tx 7wq+8HIML643mamMojsakbJW3g+50flUlwr8R3Jo4lGzr/FRmL7+vgy46CAnSAABB+r/yH Oyrkoc81uw+9zhPHImFY3rgkEclqKKDgDSeGgFBrcYE7b64SEGjfpx3RmvFEi0SPrmJhaO m3sMnptnS3oU6CDVNKddBszXe500/BAWWkM3Z2goXujdNyn+O1DlWl4xEWblvQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642969854; a=rsa-sha256; cv=none; b=pYTq1biT2xQ5w5inERc/5NewaA/EMVGZI65x9PNgZAqIT7M8CbTgRQz+2RzIoofIpBpfDV KE4DRfUAB9RTlD0id4UDEExCUGw9KDfL+o8p9AFyLExq96gGgBBXzO1Za/96bfdHEchPHD B/67cl+zHoqDipOdZo07vwy9Pp2v4iFX8BJEUwMOALU0GnBVfIIZDGl9AoVE5wsC865QHa T/U3Ku+f0GaeJy5mbS/yTXWa49qG2KbgoBJffK1DQ1HR5fnP562YzGSZ7DJpDFA15M3PAJ 6p4sqOLCaow21xSmRLczgqqXPBz3yyag+cSwY4FNuQdSuBRjC7M/ktx9556O6w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=GBS0PboX; 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.43 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=GBS0PboX; 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: A835C22B98 X-Spam-Score: -2.43 X-Migadu-Scanner: scn1.migadu.com X-TUID: Ge3tyzBagzs8 * 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 b4c20f252..e88cf1ed9 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.34.1