[Timeline] Use org-modes parser to parse headlines

The headline will now also have a property called ’marker, pointing to the
corresponding headline in the org-mode file
This commit is contained in:
Daniel - 2018-07-31 16:02:46 +02:00
parent 1acc866b76
commit ffa06f0ee3
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 7 additions and 11 deletions

View File

@ -95,18 +95,14 @@ Return whatever is found first."
(org-entry-get marker "CATEGORY"))))
(defun timeline-tools-entry-headlines (entry)
"Return list of all headlines associated with ENTRY."
"Return list of all headlines associated with ENTRY.
The headline will be a string, propertized with a property called
`marker and a corresponding marker pointing to the headline."
(mapcar (lambda (marker)
(save-match-data
(let* ((heading (save-mark-and-excursion
(with-current-buffer (marker-buffer marker)
(goto-char (marker-position marker))
(thing-at-point 'line t)))))
(string-match (format "^\\(\\*+\\)\\(?: +%s\\)?\\(?: %s\\)? +\\(.*?\\)[ \t]*\\(?::\\(?:[A-Za-z_]+:\\)+\\)?$"
(regexp-opt org-todo-keywords-1)
org-priority-regexp)
heading)
(match-string 4 heading))))
(let ((heading (org-with-point-at marker
(org-element-headline-parser (point-max)))))
(propertize (plist-get (cadr heading) :raw-value)
'marker marker)))
(timeline-tools-entry-markers entry)))