From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id AJS9DRsyTmMDRgEAbAwnHQ (envelope-from ) for ; Tue, 18 Oct 2022 06:56:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ABKpDRsyTmPeEgEAauVa8A (envelope-from ) for ; Tue, 18 Oct 2022 06:56:59 +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 E804BB03B for ; Tue, 18 Oct 2022 06:56:58 +0200 (CEST) Received: from localhost ([::1]:59616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okeev-0004Ka-Ob for larch@yhetil.org; Tue, 18 Oct 2022 00:56:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okedi-0004KE-HN for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 00:55:42 -0400 Received: from mout01.posteo.de ([185.67.36.65]:40811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okedc-00047i-RW for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 00:55:42 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CF719240026 for ; Tue, 18 Oct 2022 06:55:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666068933; bh=kUqPiuzW9xGQfh83n2PWwgAGO5XGZkiwX/uVOOT52/A=; h=From:To:Cc:Subject:Date:From; b=PGqs/QmZreHzTKfulE+XnYQAwCCwk+PXR0yaJGmbnbLz7nnsz1wzIg3/yh84UcTcB mItMLvcM/bg/n3UtZJNOF8cSW7F4ALRH8AxqExwBzLgNyiSD2U3xDsoYAk2Rppr5XS a8FQBTrsvJWnIS6WjTnlmGWmAVdW/4yrYZ35Hzbk3eMClscCN/k9pjJzOJBXIsSxjy VrO4bWUBQWuxqSFgqanwle6qjAhHIEx6hiS1nTfZIVUXVWDYAn7vSPKlWvQQ7L15L8 vjE+nEv4t5ExmuNToTLFc5PiG4mMght7soJ3jnk97ZjbjfS0CqnWgwKwzI+YbBtry9 hkG98iem16/Qw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ms1l74lKGz6tn5; Tue, 18 Oct 2022 06:55:31 +0200 (CEST) From: Ihor Radchenko To: Bruno Barbier Cc: Damien Cassou , emacs-orgmode@gnu.org Subject: Re: PATCH: Re: Reading the parameters of a special-block In-Reply-To: References: <87zgdu26dd.fsf@cassou.me> Date: Tue, 18 Oct 2022 04:56:18 +0000 Message-ID: <871qr5hgr1.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=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=1666069019; 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=dtnWpKXt1NERg0V7cRUcPgiKp5l5p68lSvKMi/0t8J4=; b=LuSOiy0Merw5RMlTky3BDia4egEDpm85PP2CpMAecEc5qi71kCxoeXBPgxCHDVzVNlpWpI E4YdkZgLmSel2AAvP7Iyhj8Ah0xlUX0tAd4ct78CDffcy5TnOCAUB25y8Mbz8DmNPpck7U jo64C29UynKLsSwqAwHYZaWsZomDd3pOn9DGzXw8AZ8CX42Omtcly6LBnd5uNXkW8gYx/H 8DVZUnX4kseq7y7PwZcYVGgk4KP2hPfs/fgK6zPenJf6uwVmbDClx4gMXqBN5URAqfpfHm iebZkcpwPFwq7GYRm3HFfmJhXWy2AYxIToVD/9AIc6eHvdmW5wCvFsNo1JobQQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666069019; a=rsa-sha256; cv=none; b=JC4EjXkkKthVOXVMpGPSw0btPTbrVu9tBOP1pF1rdnwQIUVltbZD3/ojHGVPWPi8Oztd+d CWAO90NKfr98yyNADqRxrVLzyC+nsJbabKGSIOZfxgEPW6/C/hiLh+uxUSAqPOQsduRH44 6GVfyIBCghU465zSAQd1vKVPZvZ8bSFrWF55fMf47nNH39PEzG6NbbwlxjuqNDIoAKd6WW NXofs92L9wVJGjCKcL3dvGYLVS8/7ifzCEkR4FpiCmvlIDTbiluuG6KtU+7qHNNK9PUj/k itXiuDSIJMqJ+ftu9Xj0t8BCiTylbCfvTeo2lvz205edtGWQKz26Opahy1iIaA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="PGqs/QmZ"; dmarc=pass (policy=none) header.from=posteo.net; 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: -3.62 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="PGqs/QmZ"; dmarc=pass (policy=none) header.from=posteo.net; 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: E804BB03B X-Spam-Score: -3.62 X-Migadu-Scanner: scn1.migadu.com X-TUID: jGkP0eBrCy8Q Bruno Barbier writes: > My understanding is that the parameters line is just ignored for special > blocks. > > I wrote and used a patch a while ago to fix this; it was on my todo list > to clean it up and submit it to org. Now looks like a good time. > > My patch adds a `:parameters-line' property to org elements that are > special blocks, storing the PARAMETERS line as a string. See attached > patch. > > Could this be added to org ? I am in favour of it. The property name could be simply :parameters. Just like in src blocks (see org-element-src-block-parser). > - (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)") > - (match-string-no-properties 1)))) > + (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)[ \t]*\\(.*\\)[ \t]*$") > + (match-string-no-properties 1))) > + (parameters-line (match-string-no-properties 2)) > + ) > (if (not (save-excursion > (re-search-forward > (format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type)) > @@ -1898,6 +1901,7 @@ (defun org-element-special-block-parser (limit affiliated) > (list 'special-block > (nconc > (list :type type > + :parameters-line parameters-line We probably want something like :parameters (and (org-string-nw-p parameters) (org-trim parameters)) Just as in org-element-src-block-parser. > - (let ((block-type (org-element-property :type special-block))) > - (format "#+begin_%s\n%s#+end_%s" block-type contents block-type))) > + (let ((block-type (org-element-property :type special-block)) > + (block-parameters-line (org-element-property :parameters-line special-block)) > + ) No dangling ")" please. > + (format "#+begin_%s%s%s\n%s#+end_%s" block-type > + (if (string= "" block-parameters-line) "" " ") block-parameters-line > + contents block-type))) We will not need to test against ="" with my above comment incorporated. > @@ -2425,7 +2425,13 @@ (ert-deftest test-org-element/special-block-parser () > ;; Handle non-empty blank line at the end of buffer. > (should > (org-test-with-temp-text "#+BEGIN_SPECIAL\nC\n#+END_SPECIAL\n " > - (= (org-element-property :end (org-element-at-point)) (point-max))))) > + (= (org-element-property :end (org-element-at-point)) (point-max)))) > + ;; Parse the parameter line if any > + (should > + (org-test-with-temp-text "#+BEGIN_SPECIAL* s p :w 3\nC\n#+END_SPECIAL*" > + (equal "s p :w 3" > + (org-element-property :parameters-line (org-element-at-point)))))) May also test against empty parameters and space-only parameters. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at