From 334aa14375e8ede5ae1893b335dd738d5f54686d Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 17 Nov 2022 22:44:20 -0600 Subject: [PATCH] If headline text is empty, allow skipping headline This commit makes the string comparison avoid failure when the title component is nil, (it's not an empty string). This occurs for example when a headline is just a TODO cookie with no later headline text. The two blocks for generating the link properly attempt to skip headlines where there is no 4th title component, so later generation correctly handles the case where an empty link generation would be attempted in the TOC. Note, empty links will not render nor attempt link behavior. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- org-make-toc.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org-make-toc.el b/org-make-toc.el index 168d044..55e0a9b 100644 --- a/org-make-toc.el +++ b/org-make-toc.el @@ -329,8 +329,8 @@ with the destination of the published file." (seq-intersection org-make-toc-exclude-tags (org-get-tags)) ;; NOTE: The "COMMENT" keyword is not returned as the to-do keyword ;; by `org-heading-components', so it can't be tested as a keyword. - (string-match-p (rx bos "COMMENT" (or blank eos)) - (nth 4 (org-heading-components)))) + (when-let ((headline-text ((nth 4 (org-heading-components))))) + (string-match-p (rx bos "COMMENT" (or blank eos)) headline-text))) (funcall org-make-toc-link-type-fn))) (entry-match (property value) (when-let* ((found-value (entry-property property)))