emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Fontification: Heading following a comment
@ 2020-03-20 11:59 Sebastian Miele
  2020-09-04  8:44 ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Miele @ 2020-03-20 11:59 UTC (permalink / raw)
  To: emacs-orgmode

Current master branch Org. Create an Org file with just the following
two lines

#
* A

Save, kill the buffer, find the file again. Then "* A" is in
org-meta-line face.

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

* Re: Bug: Fontification: Heading following a comment
  2020-03-20 11:59 Bug: Fontification: Heading following a comment Sebastian Miele
@ 2020-09-04  8:44 ` Bastien
  2020-09-15  6:26   ` [PATCH] " Sebastien Miquel
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2020-09-04  8:44 UTC (permalink / raw)
  To: Sebastian Miele; +Cc: emacs-orgmode

Hi Sebastian,

Sebastian Miele <sebastian.miele@gmail.com> writes:

> Current master branch Org. Create an Org file with just the following
> two lines
>
> #
> * A
>
> Save, kill the buffer, find the file again. Then "* A" is in
> org-meta-line face.

For the record, the bug is still here in master.

I'm adding it to https://updates.orgmode.org if someone wants to try 
fixing this.

-- 
 Bastien


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

* Re: [PATCH] Bug: Fontification: Heading following a comment
  2020-09-04  8:44 ` Bastien
@ 2020-09-15  6:26   ` Sebastien Miquel
  2020-09-15 12:05     ` Nicolas Goaziou
  2020-09-23  8:02     ` Bastien
  0 siblings, 2 replies; 7+ messages in thread
From: Sebastien Miquel @ 2020-09-15  6:26 UTC (permalink / raw)
  To: bzg; +Cc: sebastian.miele, emacs-orgmode

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

Hi,

The simple patch attached should fix this bug.


[-- Attachment #2: 0001-org.el-org-fontify-meta-lines-and-blocks-1-Fix-meta-.patch --]
[-- Type: text/x-patch, Size: 873 bytes --]

From 27dd7e7cbde6650932342d302000914d72179327 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Tue, 15 Sep 2020 08:08:14 +0200
Subject: [PATCH] org.el (org-fontify-meta-lines-and-blocks-1): Fix meta lines
 regexp

* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Fix meta lines
regexp

TINYCHANGE
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 020cfc873..038b4a7e0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5221,7 +5221,7 @@ by a #."
     (when (re-search-forward
 	   (rx bol (group (zero-or-more blank) "#"
 			  (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
-					    space
+					    blank
 					    eol))
 				 (optional (group "_" (group (one-or-more (any "a-zA-Z"))))))
 			  (zero-or-more blank)
-- 
2.28.0


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

* Re: [PATCH] Bug: Fontification: Heading following a comment
  2020-09-15  6:26   ` [PATCH] " Sebastien Miquel
@ 2020-09-15 12:05     ` Nicolas Goaziou
  2020-09-16  6:30       ` Sébastien Miquel
  2020-09-23  8:02     ` Bastien
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2020-09-15 12:05 UTC (permalink / raw)
  To: Sebastien Miquel; +Cc: bzg, emacs-orgmode, sebastian.miele

Hello,

Sebastien Miquel <sebastien.miquel91@orange.fr> writes:

>  	   (rx bol (group (zero-or-more blank) "#"
>  			  (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
> -					    space
> +					    blank

This looks wrong, but so does the current regexp. It should not be
`space' nor `blank', but [ \t] per Org syntax.

Regards,

-- 
Nicolas Goaziou


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

* Re: [PATCH] Bug: Fontification: Heading following a comment
  2020-09-15 12:05     ` Nicolas Goaziou
@ 2020-09-16  6:30       ` Sébastien Miquel
  2020-09-16 19:44         ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Miquel @ 2020-09-16  6:30 UTC (permalink / raw)
  To: mail; +Cc: bzg, emacs-orgmode, sebastian.miele

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

Hi,

Thanks for taking a look.
Afaict, the only difference between blank and [ \t] are some weird 
unicode characters.
It isn't clear to me which one should be preferable and in what 
situation. I couldn't find any reference to this in any documentation of 
Org syntax.

I've replaced all instances of blank with (any " \t") in this function 
(that's the only instances in org.el).
The attached patch fixes the original issue.

Regards,
Sébastien Miquel

Nicolas Goaziou wrote:

> Hello,
>
> Sebastien Miquel <sebastien.miquel91@orange.fr> writes:
>
>>   	   (rx bol (group (zero-or-more blank) "#"
>>   			  (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
>> -					    space
>> +					    blank
> This looks wrong, but so does the current regexp. It should not be
> `space' nor `blank', but [ \t] per Org syntax.
>
> Regards,
>

[-- Attachment #2: 0001-org.el-org-fontify-meta-lines-and-blocks-1-Fix-meta-.patch --]
[-- Type: text/x-patch, Size: 2206 bytes --]

From 2bb847473f2199e1dfd03ddcafdd3563ed46ab78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Wed, 16 Sep 2020 07:49:34 +0200
Subject: [PATCH] org.el (org-fontify-meta-lines-and-blocks-1): Fix meta lines
 regexp

* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Fix meta lines
regexp to work correctly for lines with only a #.

Replace blank in regexp by (any " \t").

TINYCHANGE
---
 lisp/org.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d09d6c8d2..053635c85 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5219,14 +5219,14 @@ by a #."
   "Fontify #+ lines and blocks."
   (let ((case-fold-search t))
     (when (re-search-forward
-	   (rx bol (group (zero-or-more blank) "#"
+	   (rx bol (group (zero-or-more (any " \t")) "#"
 			  (group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
-					    space
+					    (any " \t")
 					    eol))
 				 (optional (group "_" (group (one-or-more (any "a-zA-Z"))))))
-			  (zero-or-more blank)
+			  (zero-or-more (any " \t"))
 			  (group (group (zero-or-more (not (any " \t\n"))))
-				 (zero-or-more blank)
+				 (zero-or-more (any " \t"))
 				 (group (zero-or-more any)))))
 	   limit t)
       (let ((beg (match-beginning 0))
@@ -5249,7 +5249,7 @@ by a #."
 		quoting (member block-type org-protecting-blocks))
 	  (when (re-search-forward
 		 (rx-to-string `(group bol (or (seq (one-or-more "*") space)
-					       (seq (zero-or-more blank)
+					       (seq (zero-or-more (any " \t"))
 						    "#+end"
 						    ,(match-string 4)
 						    word-end
@@ -5323,11 +5323,11 @@ by a #."
 	  ;; Handle short captions
 	  (save-excursion
 	    (beginning-of-line)
-	    (looking-at (rx (group (zero-or-more blank)
+	    (looking-at (rx (group (zero-or-more (any " \t"))
 				   "#+caption"
 				   (optional "[" (zero-or-more any) "]")
 				   ":")
-			    (zero-or-more blank))))
+			    (zero-or-more (any " \t")))))
 	  (add-text-properties (line-beginning-position) (match-end 1)
 			       '(font-lock-fontified t face org-meta-line))
 	  (add-text-properties (match-end 0) (line-end-position)
-- 
2.28.0

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

* Re: [PATCH] Bug: Fontification: Heading following a comment
  2020-09-16  6:30       ` Sébastien Miquel
@ 2020-09-16 19:44         ` Nicolas Goaziou
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2020-09-16 19:44 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: bzg, emacs-orgmode, sebastian.miele

Hello,

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

> It isn't clear to me which one should be preferable and in what
> situation.

It is [ \t] almost everywhere, as shown in the code base. The only
exception I know about is when we need to escape with zero-width space,
e.g., in `org-emphasis-regexp-components'.

> I couldn't find any reference to this in any documentation
> of Org syntax.

It should be in the document describing the syntax. If it is not there,
it should be added.

> I've replaced all instances of blank with (any " \t") in this function
> (that's the only instances in org.el).
> The attached patch fixes the original issue.

Thank you. I applied your patch.

Regards,
-- 
Nicolas Goaziou


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

* Re: [PATCH] Bug: Fontification: Heading following a comment
  2020-09-15  6:26   ` [PATCH] " Sebastien Miquel
  2020-09-15 12:05     ` Nicolas Goaziou
@ 2020-09-23  8:02     ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Bastien @ 2020-09-23  8:02 UTC (permalink / raw)
  To: Sebastien Miquel; +Cc: emacs-orgmode, sebastian.miele

FWIW, I'm marking this bug as fixed in 38fbd161e4.

Thanks,

-- 
 Bastien


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

end of thread, other threads:[~2020-09-23  8:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 11:59 Bug: Fontification: Heading following a comment Sebastian Miele
2020-09-04  8:44 ` Bastien
2020-09-15  6:26   ` [PATCH] " Sebastien Miquel
2020-09-15 12:05     ` Nicolas Goaziou
2020-09-16  6:30       ` Sébastien Miquel
2020-09-16 19:44         ` Nicolas Goaziou
2020-09-23  8:02     ` 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).