Org-mode mailing list
 help / color / mirror / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Axel Svensson <mail@axelsvensson.com>,
	emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)]
Date: Fri, 28 May 2021 20:05:50 +0000
Message-ID: <b81c7020-c295-79b6-c2e8-f006264eaab7@posteo.eu> (raw)
In-Reply-To: <CAJ40yaxSf+sHNHjv_gs-HCRuNMUbYDssDTRQt2jKUniih9JF7g@mail.gmail.com>

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

Hi,

Axel Svensson writes:
> Steps to reproduce:
> 1) In an empty org-mode buffer, type a * SPC a C-b C-b C-b <RET>.
> 2) The buffer now has two lines, the first one "a" and the second "* a".
>
> Expected:
> 3) The second line is formatted as a first-level heading.
>
> Actual:
> 3) The second line is formatted as normal text.

Thanks for the report, I can confirm this bug with latest org.

Here's a patch that fixes this.

Regards,

-- 
Sébastien Miquel


[-- Attachment #2: 0001-org.el-org-fontify-extend-region-Fix-headline-fontif.patch --]
[-- Type: text/x-patch, Size: 2012 bytes --]

From c598f705bf1d8003514751fffc07fd64620a7e42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Fri, 28 May 2021 21:14:22 +0200
Subject: [PATCH] org.el (org-fontify-extend-region): Fix headline
 fontification in edge case

* lisp/org.el (org-fontify-extend-region): Fix fontification of
headline or meta line created by inserting a newline.

Unrelated to the fix: `org-fontify-extend-region' is added to
`font-lock-extend-after-change-region-function' and doesn't need to
use `save-excursion'.
---
 lisp/org.el | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 1bd9e02eb..b7b1416bd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5427,7 +5427,9 @@ by a #."
 	  t)))))

 (defun org-fontify-extend-region (beg end _old-len)
-  (let ((begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
+  (let ((end (if (progn (goto-char end) (looking-at-p "^[*#]"))
+                 (1+ end) end))
+        (begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
 	(end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
 	(extend
          (lambda (r1 r2 dir)
@@ -5437,15 +5439,14 @@ by a #."
                        "[][]" r2
 		       (match-string-no-properties 0)))))
 	     (re-search-forward (regexp-quote re) nil t dir)))))
+    (goto-char beg)
+    (back-to-indentation)
     (save-match-data
-      (save-excursion
-	(goto-char beg)
-	(back-to-indentation)
-	(cond ((looking-at end-re)
-	       (cons (or (funcall extend "begin" "[" -1) beg) end))
-	      ((looking-at begin-re)
-	       (cons beg (or (funcall extend "end" "]" 1) end)))
-	      (t (cons beg end)))))))
+      (cond ((looking-at end-re)
+	     (cons (or (funcall extend "begin" "[" -1) beg) end))
+	    ((looking-at begin-re)
+	     (cons beg (or (funcall extend "end" "]" 1) end)))
+	    (t (cons beg end))))))

 (defun org-activate-footnote-links (limit)
   "Add text properties for footnotes."
-- 
2.31.1

      reply	other threads:[~2021-05-28 20:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 10:47 Axel Svensson
2021-05-28 20:05 ` Sébastien Miquel [this message]

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://orgmode.org

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

  git send-email \
    --in-reply-to=b81c7020-c295-79b6-c2e8-f006264eaab7@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@axelsvensson.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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git