From ffa06f0ee38f46524fca65ccad8c8d9454bc5056 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Tue, 31 Jul 2018 16:02:46 +0200 Subject: [PATCH] [Timeline] Use org-modes parser to parse headlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The headline will now also have a property called ’marker, pointing to the corresponding headline in the org-mode file --- site-lisp/timeline-tools.el | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index 6b36271..5ca57dd 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -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)))