From 90aa62a5af1b19aced952f73c5ce6f3cfc14c9f0 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 22 Aug 2018 14:15:28 -0500 Subject: [PATCH] Change/Fix: (org-ql--add-agenda-markers) Rename and use copy-marker org-agenda-new-marker sometimes raises "selecting deleted buffer" errors, and other times returns markers that don't point into a buffer (I don't even know how that's possible). copy-marker always works, so we'll use it, even though it might leave markers hanging around which theoretically could affect performance over time (but isn't Emacs still supposed to GC them? I'm not sure). Also, rename it to org-ql--add-markers, since we're not adding "agenda" markers anymore. --- org-ql.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/org-ql.el b/org-ql.el index 4ef998b..19251ac 100644 --- a/org-ql.el +++ b/org-ql.el @@ -52,7 +52,7 @@ buffer. In this case, ACTION should return an Org element." ;; headline element, which --add-markers works with. On the other hand, ;; maybe this should be on the agenda-ng side. (->> ,action - org-ql--add-agenda-markers))))) + org-ql--add-markers))))) `(org-ql--query ,buffers-or-files ',pred-body :action ,action @@ -78,7 +78,7 @@ point at the beginning of its heading. For example, `org-element-headline-parser' may be used to parse an entry into an Org element (note that it must be called with a limit argument, so a lambda must be used to do so). Also see -`org-ql--add-agenda-markers', which may be used to add markers +`org-ql--add-markers', which may be used to add markers compatible with Org Agenda code. If NARROW is non-nil, buffers are not widened. @@ -187,13 +187,16 @@ If NARROW is non-nil, buffer will not be widened." ;;;;; Helpers -(defun org-ql--add-agenda-markers (element) - "Return ELEMENT with Org Agenda marker text properties added. +(defun org-ql--add-markers (element) + "Return ELEMENT with Org marker text properties added. ELEMENT should be an Org element like that returned by `org-element-headline-parser'. This function should be called -from within ELEMENT's buffer. It calls `org-agenda-new-marker', -which see." - (let* ((marker (org-agenda-new-marker (org-element-property :begin element))) +from within ELEMENT's buffer." + ;; FIXME: `org-agenda-new-marker' works, until it doesn't, because...I don't know. It sometimes + ;; raises errors or returns markers that don't point into a buffer. `copy-marker' always works, + ;; of course, but maybe it will leave "dangling" markers, which could affect performance over + ;; time? I don't know, but for now, it seems that we have to use `copy-marker'. + (let* ((marker (copy-marker (org-element-property :begin element))) (properties (--> (cadr element) (plist-put it :org-marker marker) (plist-put it :org-hd-marker marker))))