emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: No Wayman <iarchivedmywholelife@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Bug] org-in-src-block-p returns t when not in source block
Date: Mon, 27 Nov 2023 19:59:41 +0000	[thread overview]
Message-ID: <877cm3ufv6.fsf@localhost> (raw)
In-Reply-To: <87cyvv9nag.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

[ Adding Org mailing list back to CC ]

No Wayman <iarchivedmywholelife@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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org.el-org-in-src-block-p-Improve-docstring.patch --]
[-- Type: text/x-patch, Size: 1374 bytes --]

From e5d5ab915eb4309082a4a274170fddc60a75c28b Mon Sep 17 00:00:00 2001
Message-ID: <e5d5ab915eb4309082a4a274170fddc60a75c28b.1701114969.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@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 <iarchivedmywholelife@gmail.com>
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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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>

  parent reply	other threads:[~2023-11-27 19:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 15:49 [Bug] org-in-src-block-p returns t when not in source block No Wayman
2023-11-27 15:55 ` Ihor Radchenko
     [not found]   ` <87cyvv9nag.fsf@gmail.com>
2023-11-27 19:59     ` Ihor Radchenko [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-11-27 20:14 No Wayman
2023-11-27 20:30 ` Ihor Radchenko
2023-11-27 20:39   ` No Wayman
2023-11-28 20:32   ` Jens Schmidt
2023-11-29 10:07     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cm3ufv6.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=iarchivedmywholelife@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).