[ Adding Org mailing list back to CC ] No Wayman <iarchivedmywholel...@gmail.com> 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?
>From e5d5ab915eb4309082a4a274170fddc60a75c28b Mon Sep 17 00:00:00 2001 Message-ID: <e5d5ab915eb4309082a4a274170fddc60a75c28b.1701114969.git.yanta...@posteo.net> From: Ihor Radchenko <yanta...@posteo.net> 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 <iarchivedmywholel...@gmail.com> Link: https://orgmode.org/list/87il5n9owq....@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
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>