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