emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Empty headline titles unsupported: Bug?


From: Ihor Radchenko
Subject: Re: Empty headline titles unsupported: Bug?
Date: Sun, 23 May 2021 12:45:02 +0800

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Empty headline titles are supported, and "org-syntax.org" makes it
> clear. 
>
> However, empty headline + tags is ambiguous. The right solution is to
> disambiguate it by inserting "something" as the headline you want to
> tag, like a non-breaking space.

Yet, why not simply alter the headline parser a little bit to support
empty titles + tag? Such headlines are used in some of the tests. See
the attached patch.

Best,
Ihor

>From a65e39125b732f6e091dbabdd63bb46c2463cc99 Mon Sep 17 00:00:00 2001
Message-Id: 
<a65e39125b732f6e091dbabdd63bb46c2463cc99.1621744991.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 23 May 2021 12:41:35 +0800
Subject: [PATCH] Parse titeless headlines with a tag correctly

* lisp/org-element.el (org-element-headline-parser): Do not treat tag
as headline title in headlines like "* :tag:".
---
 lisp/org-element.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index ba4f0ead6..36b8f5847 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1001,7 +1001,10 @@ (defun org-element-headline-parser (limit &optional 
raw-secondary-p)
           (commentedp
            (and (let (case-fold-search) (looking-at org-comment-string))
                 (goto-char (match-end 0))))
-          (title-start (point))
+          (title-start (prog1 (point)
+                          (unless (or todo priority commentedp)
+                            ;; Headline like "* :tag:"
+                            (skip-syntax-backward " \t"))))
           (tags (when (re-search-forward
                        "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
                        (line-end-position)
-- 
2.26.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]