From fe32388d5089deefa42732b040ab1e92418d0546 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 1 Aug 2018 10:50:27 -0500 Subject: [PATCH] Change/Fix: (--format-element) Use marker's buffer When formatting an element outside the element's buffer (e.g. when mapping --format-element across the results of org-ql), the current buffer is not the element's source buffer, so functions like org-get-tags-at will not return the correct results, because they don't use the marker's buffer. So now we set the current buffer to the marker's buffer. As this package matures, this might become unnecessary in the future, but it's probably best to keep it for correctness. --- org-agenda-ng.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org-agenda-ng.el b/org-agenda-ng.el index f0b6dff..c572145 100644 --- a/org-agenda-ng.el +++ b/org-agenda-ng.el @@ -163,7 +163,9 @@ Its property list should be the second item in the list, as returned by `org-ele (if-let ((marker (or (org-element-property :org-hd-marker element) (org-element-property :org-marker element) (org-element-property :begin element)))) - (org-get-tags-at marker (not org-use-tag-inheritance)) + (with-current-buffer (marker-buffer marker) + ;; I wish `org-get-tags-at' used the correct buffer automatically. + (org-get-tags-at marker (not org-use-tag-inheritance))) ;; No marker found (warn "No marker found for item: %s" title) (org-element-property :tags element))