emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Robert Nikander <robert.nikander@icloud.com>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] org-element--current-element: Fix #+BEGIN$ parsed as special block
Date: Sun, 26 Dec 2021 22:50:47 +0800	[thread overview]
Message-ID: <87bl13s9mg.fsf@localhost> (raw)
In-Reply-To: <E6D12380-E2DB-48BB-BB40-DBBCF73DE8F0@icloud.com>

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

Robert Nikander <robert.nikander@icloud.com> writes:

> Hitting TAB on the BEGIN line does nothing. But if I add a blank line before it, then hitting TAB hides and shows the block. Is that a bug? Or am I doing it wrong? Seems like it should work without the blank line.
>
> * Test
> Some text
>
> #+BEGIN 
> Hide this
> #+END
>
> M-x org-version => 9.5.1.

This last case is actually a bug. As Tomas pointed, Org blocks have
slightly different syntax: either #+begin_something or #+begin:
typeofblock. The fact that you can fold the #+BEGIN..#+END in your
second case should not happen.

The fix is attached.

Nicolas,
Let me know if I miss something about special block parsing.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element-current-element-Fix-BEGIN-parsed-as-spec.patch --]
[-- Type: text/x-diff, Size: 1192 bytes --]

From 289afdb9672eadaea119ebb2b0deecff4db3aa89 Mon Sep 17 00:00:00 2001
Message-Id: <289afdb9672eadaea119ebb2b0deecff4db3aa89.1640530104.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 26 Dec 2021 22:45:36 +0800
Subject: [PATCH] org-element--current-element: Fix #+BEGIN$ parsed as special
 block

* lisp/org-element.el (org-element--current-element): Use
`org-element-dynamic-block-open-re' to match blocks.

Reported in https://list.orgmode.org/Ycay4s3iAdEGSwgt@tuxteam.de/T/#t
---
 lisp/org-element.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index eac39d429..ce251da38 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4266,7 +4266,7 @@ (defun org-element--current-element (limit &optional granularity mode structure
 	            ((looking-at "CALL:")
 		     (beginning-of-line)
 		     (org-element-babel-call-parser limit affiliated))
-	            ((looking-at "BEGIN:? ")
+	            ((looking-at org-element-dynamic-block-open-re)
 		     (beginning-of-line)
 		     (org-element-dynamic-block-parser limit affiliated))
 	            ((looking-at "\\S-+:")
-- 
2.32.0


  parent reply	other threads:[~2021-12-26 14:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-24 21:21 block folding - should this work? Robert Nikander
2021-12-25  5:57 ` tomas
2021-12-26 14:50 ` Ihor Radchenko [this message]
2021-12-26 19:24   ` [PATCH] org-element--current-element: Fix #+BEGIN$ parsed as special block Nicolas Goaziou
2022-05-14  5:55     ` Ihor Radchenko
2021-12-29 21:37 ` block folding - should this work? Tim Cross

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=87bl13s9mg.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=robert.nikander@icloud.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).