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.
This commit is contained in:
Adam Porter 2018-08-01 10:50:27 -05:00
parent 056c93bcd6
commit fe32388d50

View file

@ -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) (if-let ((marker (or (org-element-property :org-hd-marker element)
(org-element-property :org-marker element) (org-element-property :org-marker element)
(org-element-property :begin 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 ;; No marker found
(warn "No marker found for item: %s" title) (warn "No marker found for item: %s" title)
(org-element-property :tags element)) (org-element-property :tags element))