From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MP1ZHkzB5GIo5AAAbAwnHQ (envelope-from ) for ; Sat, 30 Jul 2022 07:27:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id eDlUHUzB5GIpQAEAG6o9tA (envelope-from ) for ; Sat, 30 Jul 2022 07:27:40 +0200 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 EEC5C24AFC for ; Sat, 30 Jul 2022 07:27:39 +0200 (CEST) Received: from localhost ([::1]:58444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHf0k-0003vp-Um for larch@yhetil.org; Sat, 30 Jul 2022 01:27:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHf03-0003vb-5j for emacs-orgmode@gnu.org; Sat, 30 Jul 2022 01:26:55 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:42633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHf01-00048N-1d for emacs-orgmode@gnu.org; Sat, 30 Jul 2022 01:26:54 -0400 Received: by mail-pl1-x632.google.com with SMTP id b22so6230921plz.9 for ; Fri, 29 Jul 2022 22:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=b4xrldlrKYjActUna2VI34fBuzNFZRFwrtdlQoBk+NE=; b=caU2fcvKfDbFlvbPQUkoUfi48PN9Ml0mFKO3kA6QAzsY/oG9Cu1Bz9tUOtJUYkR3JQ BZPnSklAbFvtXwBFi+mjL22Ur9yEMDcl3ehCMTJ1OVCv/lGH9RMX8YMLO/6w0eFFDKjS eXaP/ZCoz391pHbeAVCEJInb+P6oFpOOQdWpDHnyALW834bzewSKFTLeyUZzLVcW83Ki OKwC2YvUMBN715yu9FB7tiah92SdiwGoEb7G8KebuxvvKTnFmXUefepf8wddkHLXEEDY R6gjlRr7LcX8fDCEajlGd/P/wlO81zPzdjmQrTsZY2lEiyAWBi1/IeD4xlGJwynQrdnj OiJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=b4xrldlrKYjActUna2VI34fBuzNFZRFwrtdlQoBk+NE=; b=5p46C1CVUWokCdmWFXIE1Ef4MOaj+bDC+nh/7dcWINupf3fGEF4d21ZQsPe0sX8u14 mmg/pzmESXbmG9nHxmA77fYz0RNPRQE9GPt4HWodWaSnnPadHv8j6YcUpGg/qhMAzeid 4ADLp6sMug/r5zuSMnpHaGcsPsFXXwnLGssrF8ZB/t3usfiWBMnDPWjpJT/qtAUV4GZU Rr1wrh8Lf8REL2WVnWgNkwsefA9259MHHHdfd98bqeeWeadfT/WlTlmfz8bA/7cdrD54 qhZvjTtUP4pKPJvAzaPZPIEtuHEs0OYd7Gj5CubwS16EwKa7qdMTdCYTnmSwYlgwEe1Q S8bQ== X-Gm-Message-State: ACgBeo332EkzmY23YrL725vrIr930VwhoYSKht/0ufV9f5QPUff02lYi jtDIWmU296lI9B7S5H8V1Yw= X-Google-Smtp-Source: AA6agR45Vqpuk7GNdkNdwENQZBYwgjVIvZM/MtfglpMK1oIcjlP8Swf0Rk1W8eC1Ry61WtcSM4PSRw== X-Received: by 2002:a17:903:22cf:b0:16c:4145:75c5 with SMTP id y15-20020a17090322cf00b0016c414575c5mr6907598plg.127.1659158811614; Fri, 29 Jul 2022 22:26:51 -0700 (PDT) Received: from localhost ([1.83.155.1]) by smtp.gmail.com with ESMTPSA id l8-20020a170903244800b0015e8d4eb1d3sm4725275pls.29.2022.07.29.22.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 22:26:50 -0700 (PDT) From: Ihor Radchenko To: Uwe Brauer Cc: emacs-orgmode@gnu.org Subject: [PATCH] Re: the comment environment does not work for checkboxes In-Reply-To: <87y1wc3ruw.fsf@mat.ucm.es> References: <87a68s5vv9.fsf@mat.ucm.es> <87wnbw9wqm.fsf@web.de> <87y1wc3ruw.fsf@mat.ucm.es> Date: Sat, 30 Jul 2022 13:27:47 +0800 Message-ID: <87tu6ztbjg.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=yantar92@gmail.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659158860; 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=b4xrldlrKYjActUna2VI34fBuzNFZRFwrtdlQoBk+NE=; b=K86eeXGkzQn2GAQlF2aQCJ3T2FYLGb9tm0G5vkSodO4ppn0vLGhm/TbMvYnV2A5wizk2FZ +79S1B+TnOOwmuxiPHGo4FJDJxoTlmYIO7hfi9zD69H/5rantg+cBQOFmxVs7UtnkqKFjx CfTB5VAmC4Yc3ft0r5ZAzmdVwups5CE/8HrVIogF24jTrtIYDCmM2UcQ8cglAVzn9ycCkQ MITfjGOx4tve2PZGjEhlZ8WYEEfiA3jv56XyFJrM7ACNPPLGKduG4Chf5Ds8tNbbYTzmYy oeYD2dR22xPWhGR96iHRG9Bp3CJOoFQ5HrYo4T2fXl3KT1WuAUgE33w/Ln+pMA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659158860; a=rsa-sha256; cv=none; b=UWDIRHK4/QwDEw/GDGr3oTFmNhlPEb4ll5zU0e4SBFjUDn0yNU2WyOpW3ExFQj2PoDSDI5 +koM3EilURnfryhmwMekV/PtZEOid5vQ8O5zRHEPpQp6eukN66k3wqk2FVbyWLk2KSXiZW t1O0pX6S/31Xwt0JvB74H6JJB6OTPajgUPjqe1b/EShSqod+fxdYRD+Aeh2u2wj4vyffTX Jho9KdkFeM8+vQVDcajKmRNSJnDelwEnZeiBh2OK3v5vUZ6ue8Oc6OvjgRfePVjLClGevT wnyxZpPSeD4DsF0yob+kLRHMN4Yi4qVfsz2OgZxpQc7309GepEcMahvbG0ASJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=caU2fcvK; dmarc=pass (policy=none) header.from=gmail.com; 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: -8.73 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=caU2fcvK; dmarc=pass (policy=none) header.from=gmail.com; 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: EEC5C24AFC X-Spam-Score: -8.73 X-Migadu-Scanner: scn0.migadu.com X-TUID: 5HNXPM57mHJI --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Uwe Brauer writes: > Thanks, a couple of remarks > > 1. It does not work! I Presume you mean =C2=ABC-c '=C2=BB no =C2=ABC-= c C-'=C2=BB? Well > this is bound to is edit special > ... > > Comments block are not listed and as I said it seems not to work, if > what you say is the correct syntax, then there is a bug, since > > 1. when I mark the region, > > 2. Run org-insert-structure-template, > > 3. Select comment, it should then lead to=20 Thanks for the heads-up! Comment blocks are not supposed to contain Org markup, and thus it indeed makes sense to support them in org-edit-special and in structure templates. See the attached patch. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Support-interactive-editing-of-comment-blocks.patch >From 4913df3f84b6d1d0fc5cc0f613dca42abe47821d Mon Sep 17 00:00:00 2001 Message-Id: <4913df3f84b6d1d0fc5cc0f613dca42abe47821d.1659158779.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sat, 30 Jul 2022 13:24:10 +0800 Subject: [PATCH] Support interactive editing of comment blocks * lisp/org-src.el (org-edit-comment-block): New command to edit comment block elements. The command auto-escapes Org markup inside. (org-src--contents-area): * lisp/org.el (org-insert-structure-template): (org-edit-special): Support comment blocks. * etc/ORG-NEWS (Interactive commands now support escaping text inside comment blocks): (New command ~org-edit-comment-block~ to edit comment block at point): Document the new features. See https://orgmode.org/list/87y1wc3ruw.fsf@mat.ucm.es --- etc/ORG-NEWS | 19 ++++++++++++++++++- lisp/org-src.el | 25 ++++++++++++++++++++++++- lisp/org.el | 5 ++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 478fcf95c..0bc3fa638 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -141,6 +141,14 @@ discouraged when working with Org files. ** New features +*** Interactive commands now support escaping text inside comment blocks + +~org-edit-special~ and ~org-insert-structure-template~ now handle +comment blocks. + +See [[*New command ~org-edit-comment-block~ to edit comment block at +point]]. + *** New customization option =org-property-separators= A new alist variable to control how properties are combined. @@ -253,6 +261,16 @@ instance, includes all available items in the printed bibliography. ** New functions and changes in function arguments +*** New command ~org-edit-comment-block~ to edit comment block at point + +As the contents of comments blocks is not parsed as Org markup, the +headlines and keywords inside should be escaped, similar to src +blocks, example blocks, and export blocks. This in inconvenient to do +manually and ~org-edit-special~ is usually advised to edit text in +such kind of blocks. + +Now, comment block editing is also supported via this new function. + *** New function ~org-element-cache-map~ for quick mapping across Org elements When element cache is enabled, the new function provides the best @@ -266,7 +284,6 @@ to ~org-element--cache-map-statistics~ and ~org-element--cache-map-statistics-threshold~. ~org-scan-tags~ and tag views in agenda utilise the new function. - *** New function ~org-element-at-point-no-context~ This function is like ~org-element-at-point~, but it does not try to diff --git a/lisp/org-src.el b/lisp/org-src.el index b7e0af50e..0249af60b 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -384,7 +384,7 @@ (defun org-src--contents-area (datum) (let ((beg (org-element-property :contents-begin datum)) (end (org-element-property :contents-end datum))) (list beg end (buffer-substring-no-properties beg end)))) - ((memq type '(example-block export-block src-block)) + ((memq type '(example-block export-block src-block comment-block)) (list (progn (goto-char (org-element-property :post-affiliated datum)) (line-beginning-position 2)) (progn (goto-char (org-element-property :end datum)) @@ -1161,6 +1161,29 @@ (defun org-edit-export-block () (lambda () (org-escape-code-in-region (point-min) (point-max))))) t)) +(defun org-edit-comment-block () + "Edit comment block at point. +\\ +A new buffer is created and the block is copied into it, and the +buffer is switched into Org mode. + +When done, exit with `\\[org-edit-src-exit]'. The edited text \ +will then replace the area in the Org mode buffer. + +Throw an error when not at a comment block." + (interactive) + (let ((element (org-element-at-point))) + (unless (and (eq (org-element-type element) 'comment-block) + (org-src--on-datum-p element)) + (user-error "Not in a comment block")) + (org-src--edit-element + element + (org-src--construct-edit-buffer-name (buffer-name) "org") + 'org-mode + (lambda () (org-escape-code-in-region (point-min) (point-max))) + (org-unescape-code-in-string (org-element-property :value element))) + t)) + (defun org-edit-src-code (&optional code edit-buffer-name) "Edit the source or example block at point. \\ diff --git a/lisp/org.el b/lisp/org.el index 937892ef3..d75894590 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8869,7 +8869,8 @@ (defun org-insert-structure-template (type) (region-end (and region? (copy-marker (region-end)))) (extended? (string-match-p "\\`\\(src\\|export\\)\\'" type)) (verbatim? (string-match-p - (concat "\\`" (regexp-opt '("example" "export" "src"))) + (concat "\\`" (regexp-opt '("example" "export" + "src" "comment"))) type)) (upcase? (string= (car (split-string type)) (upcase (car (split-string type)))))) @@ -16979,6 +16980,7 @@ (defun org-edit-special (&optional arg) When in a source code block, call `org-edit-src-code'. When in a fixed-width region, call `org-edit-fixed-width-region'. When in an export block, call `org-edit-export-block'. +When in a comment block, call `org-edit-comment-block'. When in a LaTeX environment, call `org-edit-latex-environment'. When at an INCLUDE, SETUPFILE or BIBLIOGRAPHY keyword, visit the included file. When at a footnote reference, call `org-edit-footnote-reference'. @@ -17025,6 +17027,7 @@ (defun org-edit-special (&optional arg) (`table-row (call-interactively 'org-table-edit-formulas)) (`example-block (org-edit-src-code)) (`export-block (org-edit-export-block)) + (`comment-block (org-edit-comment-block)) (`fixed-width (org-edit-fixed-width-region)) (`latex-environment (org-edit-latex-environment)) (`planning -- 2.35.1 --=-=-=--