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 ms5.migadu.com with LMTPS id 8J2sCwP+dGLYUQAAbAwnHQ (envelope-from ) for ; Fri, 06 May 2022 12:52:51 +0200 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 wLDFCgP+dGIWuQAAG6o9tA (envelope-from ) for ; Fri, 06 May 2022 12:52:51 +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 A634F11701 for ; Fri, 6 May 2022 12:52:50 +0200 (CEST) Received: from localhost ([::1]:39352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmvZp-0007kw-L8 for larch@yhetil.org; Fri, 06 May 2022 06:52:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmvYi-0007kg-6t for emacs-orgmode@gnu.org; Fri, 06 May 2022 06:51:42 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]:37356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmvYg-0006UL-IE for emacs-orgmode@gnu.org; Fri, 06 May 2022 06:51:39 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-ed8a3962f8so6807244fac.4 for ; Fri, 06 May 2022 03:51:38 -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=rSMtdpBzQVKfKlLRqRXQYFhKMCj762Zs3INm7+a0z9o=; b=lhCfS0DQTsS1KSpZEK23LDO61nzmen9F5jr0i1T/0uUd3ipWukX0JZkmIz9pomjsqM MlG2YvhMIYI83cNPd3z/gpqsnMHJylF21Ty2m3qcp4fmmGef1yZvQzx6enjtaW0nsMeq c11XuT7Vo3lg0DvlnX9rSo/YG3FwGfXy/erePg+rUZhS6V5AHz9CdS5ZFNn7fplb3gmp jYJhEQXaolgItqhLkUbiLJiYd3jBzp8Q+JYNQPUvBTGRBdShTtI6Fh+R+BHJ73LOtmpB bboel4F955cq417pXcweVmAg4KjNkkS3asYGVllk53JRQTA7MOkURmDQTKyNYPW6ItQK uhtw== 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=rSMtdpBzQVKfKlLRqRXQYFhKMCj762Zs3INm7+a0z9o=; b=qEgnvPDdRtihaCP73c3Lt1YsOXMnJtHDx3+OceI+C1wbMQNk+UlaL4Dk5Lthp9hx7N xvATdOdLXsM5y/03rG1MYJoAQBDCJnForrjsKrks2wosmaMLBJcZIc5MnXUd7+SIm2K+ uKPLEGeE5RhosOannqO4G290g0zfuxILQxlat6wVTWtg4NUbP/Hu90w2ZRLKzXXJOS/j 2E8qcRPEVTiXpOZ0iuQDr5wxlhcoWuSSdBHy1PfWIXEpdp+ubchrP+Atpa/5YEkmYYGN EThUQHGk8Ima8WrSBw+J8QOaCKK/TmJ+kSRTcD7m5HLeX+2Mqo09a4ZF8k8Yamwz9ISJ rIZw== X-Gm-Message-State: AOAM531XyqIT6RITR+lx1v+jmt3GMKvXMBN5GQhixtP8MUTHsLdXppmX bYw8dn4pKi5KjQ6HrVeKcRA= X-Google-Smtp-Source: ABdhPJwO4rHw8Nywoulk7N4DkKOBtkQPOLa21dKqh5YNmtu6hVJ5wyHu0SR+L9hUEvTZpYCltmnm1A== X-Received: by 2002:a05:6870:9694:b0:ec:abf0:cc2f with SMTP id o20-20020a056870969400b000ecabf0cc2fmr4124055oaq.235.1651834296893; Fri, 06 May 2022 03:51:36 -0700 (PDT) Received: from localhost ([104.223.98.2]) by smtp.gmail.com with ESMTPSA id f13-20020a4a9d4d000000b0035eb4e5a6c6sm1742954ook.28.2022.05.06.03.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 03:51:36 -0700 (PDT) From: Ihor Radchenko To: Ignacio Casso Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] org-complex-heading-regexp should consider COMMENT keywords [9.5.2 (release_9.5.2-25-gaf6f12 @ /home/ignacio/repos/emacs/lisp/org/)] In-Reply-To: References: Date: Fri, 06 May 2022 18:52:19 +0800 Message-ID: <87fsln6iho.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=yantar92@gmail.com; helo=mail-oa1-x2b.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=1651834370; 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=rSMtdpBzQVKfKlLRqRXQYFhKMCj762Zs3INm7+a0z9o=; b=aQG5kSF0pG35XS2GdeFEAK/UIDFI06yX1xtp8qc1phQ1V5LGik+rRaCWNA4i6JPJt5zOTR NBNgGzRXtMUlqPJBv0Bv1WnKfD4KbaBgU3yL7pWq23ZKTGDbi48ojEzWDSdjNTneyN3Pu6 qX2hVAbl6ui/HBArkI4A2DuGYHRrqSKWOm9K9ureUyVyIW4luUt2X/IYqIG2mlamltZAXI wOAKb2wqEueSQeDdVYMSsrylX9i7oeYI1OMODDoRoyXOVzEGCptJwhoGLjFu26l3viOhcc 4/6aBYvojyp3gNX35djoU6w8u4WiJ/5nEpV7+6UTA3CHWw+8n8kqZhYC/OZ84w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651834370; a=rsa-sha256; cv=none; b=aQ1ZhZnnL3UTiDT40BoyGcw3mV8Lu2uIW0z9Hkkf0V3NdUV1ONsSy+bxYiUyJVCLnDuG7x e6tv1JIHsjRE134p6yyiTZT9c30EcqR57wRy420XM8RnKUyraWLIKjUCZXm/LLWueuJte1 Za/AzxzVm+is59CkOVHm1xbOroG8CClueWx5jQsMMs34yfp2nGCnMqB810KxlTR8vZTlsd SXm5GDWK+O8co/iS/hRqKx8Gt1JJoY1LdTk+n/zxAZ0jKjzk9YMppyqeY7l07Qx4WIcMEZ HNEsdRtIVxpMHaQ1yQxruSo98Vz7+JwQkq42jTmIk4+VO2YOwvjPuup0mKLzCg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lhCfS0DQ; 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: -2.00 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lhCfS0DQ; 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: A634F11701 X-Spam-Score: -2.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: KHWVBtAWe6Sx Ignacio Casso writes: >> Note that org-complex-heading-regexp-format does consider statistics >> cookies, but only at the beginning/end of the headline title. >> Unfortunately, it is impossible to provide generic printf format to >> match a headline title with arbitrary statistics cookies inserted in the >> middle of it. > > Could not something equivalent be done for COMMENT keywords and > optionally match them at the beginning of the headline in > `org-complex-heading-regexp-format'? Something like this: > > (setq org-complex-heading-regexp-format > (concat "^\\(\\*+\\)" > "\\(?: +" org-todo-regexp "\\)?" > "\\(?: +\\(\\[#.\\]\\)\\)?" > "\\(?: +" > + ;; Headline might be commented > + "\\(COMMENT \\)? > ;; Stats cookies can be stuck to body. > "\\(?:\\[[0-9%%/]+\\] *\\)*" > "\\(%s\\)" > "\\(?: *\\[[0-9%%/]+\\]\\)*" > "\\)" > "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?" > "[ \t]*$")) > > This would fix the problem I really cared about: being able to use a > headline as capture target regardless of whether it is commented or > not. Getting the headline text was never important to me, so I don't > really care that much about `org-complex-heading-regexp'. Sounds reasonable. Could you prepare a patch? COMMENT should be inside a shy group and note that there might be an arbitrary number of space after COMMENT string. >> I generally dislike the idea of the available plethora of analytic >> regexps with numbered match groups. > > Do you mean that there is no way to specify an optional string in a > regular expression without wrapping it in a parenthesized group, which > would break the match group numbering backwards compatibility? I'm not > that familiar with regular expressions, but if that's the case I > completely agree with your last statement. Not exactly. We could use shy (unnumbered) match group and not break the group numbers. However, adding an extra optional match means that we can break an old code that could be relying on the next group to contain this optional match: Old code: (when (string-match-p "COMMENT" (match-string 1)) ...) Before "\\(.+\\)" After "\\(?:COMMENT\\)?\\(.+\\)" The old code will never match COMMENT when the new regexp is used. Best, Ihor