emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)]
@ 2021-05-28 10:47 Axel Svensson
  2021-05-28 20:05 ` [PATCH] " Sébastien Miquel
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Svensson @ 2021-05-28 10:47 UTC (permalink / raw)
  To: emacs-orgmode

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

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.


Emacs  : GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5)
 of 2021-01-31, modified by Debian
Package: Org mode version 9.3.6 (release_9.4.6-544-gc5573b @
/home/user/.emacs.d/straight/build/org/)

[-- Attachment #2: Type: text/html, Size: 672 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)]
  2021-05-28 10:47 Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)] Axel Svensson
@ 2021-05-28 20:05 ` Sébastien Miquel
  2021-09-26 11:23   ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Sébastien Miquel @ 2021-05-28 20:05 UTC (permalink / raw)
  To: Axel Svensson, emacs-orgmode

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)]
  2021-05-28 20:05 ` [PATCH] " Sébastien Miquel
@ 2021-09-26 11:23   ` Bastien
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2021-09-26 11:23 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: emacs-orgmode, Axel Svensson

Hi Sébastien,

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> Thanks for the report, I can confirm this bug with latest org.
>
> Here's a patch that fixes this.

Applied, thanks.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-26 11:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 10:47 Bug: No highlighting after <RET> [9.4.6 (release_9.4.6-544-gc5573b @ /home/user/.emacs.d/straight/build/org/)] Axel Svensson
2021-05-28 20:05 ` [PATCH] " Sébastien Miquel
2021-09-26 11:23   ` Bastien

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