Skip to content

Commit

Permalink
Merge: Update for Org 9.7 org-element API changes
Browse files Browse the repository at this point in the history
See #364.
  • Loading branch information
alphapapa committed Sep 27, 2023
2 parents 0a02912 + 5c9d4cd commit 8250349
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 98 deletions.
3 changes: 2 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like:

** 0.8-pre

Nothing new yet.
*Compatibility*
+ Org v9.7's ~org-element~ API changes required some adjustments. ([[https://github.com/alphapapa/org-ql/issues/364][#364]]. Thanks to several users for reporting, and to [[https://github.com/yantar92][Ihor Radchenko]] for his feedback.)

** 0.7.2

Expand Down
18 changes: 17 additions & 1 deletion org-ql-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,20 @@ When opened, the link searches the buffer it's opened from."

;;;; Faces/properties

(defalias 'org-ql-view--resolve-element-properties
;; It would be preferable to define this as an inline function, but
;; that would mean that users would have to recompile org-ql when
;; upgrading to Org 9.7 or else get weird errors.
;; TODO(someday): Define `org-ql-view--resolve-element-properties' as inline.
(if (version<= "9.7" org-version)
(lambda (node)
"Resolve NODE's properties using `org-element-properties-resolve'."
;; Silence warnings about `org-element-properties-resolve'
;; being unresolved on earlier Org versions.
(with-no-warnings
(org-element-properties-resolve node 'force-undefer)))
#'identity))

(defun org-ql-view--format-element (element)
;; This essentially needs to do what `org-agenda-format-item' does,
;; which is a lot. We are a long way from that, but it's a start.
Expand All @@ -827,6 +841,7 @@ returned by `org-element-parse-buffer'. If ELEMENT is nil,
return an empty string."
(if (not element)
""
(setf element (org-ql-view--resolve-element-properties element))
(let* ((properties (cadr element))
;; Remove the :parent property, which so bloats the size of
;; the properties list that it makes it essentially
Expand Down Expand Up @@ -877,7 +892,8 @@ return an empty string."
(char-to-string)
(format "[#%s]")
(org-ql-view--add-priority-face)))
(habit-property (org-with-point-at (org-element-property :begin element)
(habit-property (org-with-point-at (or (org-element-property :org-hd-marker element)
(org-element-property :org-marker element))
(when (org-is-habit-p)
(org-habit-parse-todo))))
(due-string (pcase (org-element-property :relative-due-date element)
Expand Down
Loading

0 comments on commit 8250349

Please sign in to comment.