From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id UPWMCsr0ZGVSTgEAauVa8A:P1 (envelope-from ) for ; Mon, 27 Nov 2023 20:58:02 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id UPWMCsr0ZGVSTgEAauVa8A (envelope-from ) for ; Mon, 27 Nov 2023 20:58:02 +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 00A195FC56 for ; Mon, 27 Nov 2023 20:58:02 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=kUdc0v3J; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701115082; 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=wlO2rl261B8auAijChlKhCRd5r3Zt1Gh+8Pes8u7vyw=; b=eAQq1KF93VAZaZfODIrgKoxPLZjBpvn9WV7FfOEEsnX3Vog9YtpjmQInDPo81JdeF+8lHR T2J12T568ONw4CxXQ1XdfZwFj7Qr1JUfD5L6H5Z1bfLJaZ0+YwgiUHte6WCYlHoEfMoLAx 2CF+dSBfL6NExQMcRXDsMOxnshf9vVdh3u7L9ikGU4Rp9wpJ8MR1GH7BdriJuGPBRl4tGj w3VMJXEzy1xP96t5ydC3AwW6VgRSukUJaZ3kJob8Zo8HVn7jb0l4uiodkbRUEQFt9QFxeu LqWRuxk4hayrDGB6E24dl0ackk71aRV9WHpGIizo5PKX/Cb6cDm3eonrLPmSLg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=kUdc0v3J; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701115082; a=rsa-sha256; cv=none; b=rroO5GeTHu8HT6PBIVUA+1S+aZqkco7ztVKqHhFWnMqVHxur+zQOtb0HmwNXDFJgWIqxWb cv9YwmQyDgolI5uCFXeQF99/wmsWc1/TjmsIGrpoM5CtcMM3ZoAz+hdfiSjFUgiS27jmMf YVwfa+BMv3ysUjYl3GDrtqUPEVxuTvrkTBcOHqkMKGjXKIMoqH/Yh3XRFD/JUHx77uvSP6 d/IIlr1E+BsjVYB7R5AxvYdCcWS0UZ/XPx6NF+r4soRrsQcp4F9V3BXHd09W4ULcTX+LQJ 6wbgcIbJj+hf/FU5e1Lj4PdNKRWcdyETJ7RfbMxQXd0r5isc/ebtYfxbUWVVVA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7hjJ-0003w5-T1; Mon, 27 Nov 2023 14:57:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7hjI-0003vh-Dt for emacs-orgmode@gnu.org; Mon, 27 Nov 2023 14:57:16 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7hj4-000536-33 for emacs-orgmode@gnu.org; Mon, 27 Nov 2023 14:57:16 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id F3FB5240103 for ; Mon, 27 Nov 2023 20:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1701115019; bh=v7HWb+Khg02hwnErPyNwpVR2CSL6SUWMvuR++JTXcaE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=kUdc0v3JjIvT49Tk7fFpUwL8dKGsRCD7VAMLiNYqa0Qt79hqH1MEcDtBAlpZZQfom 7suOlnBKSzDY2XT3hj5Xzn6Guwm7b6TylUyfHVlfLOkmStfMWXINz2uo1BSDj+/Ady 3kLvw9Pj3dD8E2zcu5nYTn4GozuuRrQ7h1miAUkVT80yRy3PdXxj/GMc8wNP0Uau/W ZYdAnoxfRmyJoDG6mg3g/4gRbQQxtsIZXsY4uhxJkspWCuIVwOU11L9rpvW4VKBfCc Y3Gl3IpPbVzHtpTxWZeJS3hksqS0pSpmyS+O7jwnngMn5aZFOXsSstiW8qSTtrebzJ Xz8NY6/zUg5xQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SfGZL2jyNz9rxM; Mon, 27 Nov 2023 20:56:58 +0100 (CET) From: Ihor Radchenko To: No Wayman Cc: emacs-orgmode@gnu.org Subject: Re: [Bug] org-in-src-block-p returns t when not in source block In-Reply-To: <87cyvv9nag.fsf@gmail.com> References: <87il5n9owq.fsf@gmail.com> <87cyvvur5m.fsf@localhost> <87cyvv9nag.fsf@gmail.com> Date: Mon, 27 Nov 2023 19:59:41 +0000 Message-ID: <877cm3ufv6.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.34 X-Spam-Score: -9.34 X-Migadu-Queue-Id: 00A195FC56 X-Migadu-Scanner: mx12.migadu.com X-TUID: RTanULmA4jNS --=-=-= Content-Type: text/plain [ Adding Org mailing list back to CC ] No Wayman writes: >> This is not a bug - Org considers blank lines after element as a >> part of >> it. This includes source blocks. > > I would've reversed the semantics of the INSIDE argument. > e.g. > > (defun org-in-src-block-p (&optional lax element) > ... > That's less confusing and mirrors other functions, such as > org-at-timestamp-p. This is very different from LAX argument in `org-at-timestamp-p' - timestamp-like text may not be proper syntactically correct Org markup element, but is still considered by agenda for historical and practical reasons. > However, that's a breaking change, and I feel like adding another, > similarly named function will cause more confusion than it > prevents. This too. > ... With that in mind, the docstring could be improved. > ... What about the attached patch? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-org.el-org-in-src-block-p-Improve-docstring.patch >From e5d5ab915eb4309082a4a274170fddc60a75c28b Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Mon, 27 Nov 2023 20:54:42 +0100 Subject: [PATCH] lisp/org.el (org-in-src-block-p): Improve docstring * lisp/org.el (org-in-src-block-p): Reported-by: No Wayman Link: https://orgmode.org/list/87il5n9owq.fsf@gmail.com --- lisp/org.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d2cd0b9b7..19887ff1e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18786,9 +18786,13 @@ (defun org-quote-vert (s) s) (defun org-in-src-block-p (&optional inside element) - "Whether point is in a code source block. -When INSIDE is non-nil, don't consider we are within a source -block when point is at #+BEGIN_SRC or #+END_SRC. + "Return t when point is at a source block element. +When INSIDE is non-nil, return t only when point is between #+BEGIN_SRC +and #+END_SRC lines. + +Note that affiliated keywords and blank lines after are considered a +part of a source block. + When ELEMENT is provided, it is considered to be element at point." (save-match-data (setq element (or element (org-element-at-point)))) (when (org-element-type-p element 'src-block) -- 2.42.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--