From adcb96cb1e2fb3a10acf0fb9a3c231d5585af30f Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 12 Jul 2019 18:53:06 +0200 Subject: [PATCH] Fix: Compatibility with org>=9.2 The API for `org-get-tags-at` and `org-timestamp--to-internal-time` changed in org-mode version 9.2. Thanks to Ataias Pereira Reis (@ataias) and Daniel Kraus (@dakra). Closes #27. Closes #31. --- README.org | 3 +++ org-ql-agenda.el | 7 +++++-- org-ql.el | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index f3675ca..698197d 100644 --- a/README.org +++ b/README.org @@ -236,6 +236,9 @@ If ~MARKERS~ is non-nil, ~org-agenda-ng--add-markers~ is used to add markers to *Changed* + ~(regexp)~ selector accepts multiple regexps to test. +*Compatibility* ++ Fixes for compatibility with Org 9.2. (Thanks to [[https://github.com/ataias][Ataias Pereira Reis]] and [[https://github.com/dakra][Daniel Kraus]].) + *Internal* + Optimizations for some query selectors, e.g. =regexp= and =todo=. These can provide a significant improvement for some queries. See benchmarks in [[file:notes.org][notes.org]]. diff --git a/org-ql-agenda.el b/org-ql-agenda.el index bd3e15e..c8d6074 100644 --- a/org-ql-agenda.el +++ b/org-ql-agenda.el @@ -50,6 +50,9 @@ (defvar org-super-agenda-mode) (declare-function org-super-agenda--group-items "org-super-agenda") +(when (version< org-version "9.2") + (defalias 'org-get-tags 'org-get-tags-at)) + ;;;; Variables (defvar org-ql-agenda-buffer-name "*Org Agenda NG*" @@ -328,8 +331,8 @@ 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)))) (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))) + ;; I wish `org-get-tags' used the correct buffer automatically. + (org-get-tags marker (not org-use-tag-inheritance))) ;; No marker found (warn "No marker found for item: %s" title) (org-element-property :tags element)) diff --git a/org-ql.el b/org-ql.el index 499ac7e..fd60870 100644 --- a/org-ql.el +++ b/org-ql.el @@ -25,6 +25,12 @@ (require 'dash) +;;;; Compatibility + +(when (version< org-version "9.2") + (defalias 'org-get-tags 'org-get-tags-at) + (defalias 'org-timestamp-to-time 'org-timestamp--to-internal-time)) + ;;;; Variables (defvar org-ql--today nil) @@ -457,8 +463,8 @@ With KEYWORDS, return non-nil if its keyword is one of KEYWORDS (a list of strin (org-ql--defpredicate tags (&rest tags) "Return non-nil if current heading has one or more of TAGS (a list of strings)." ;; TODO: Try to use `org-make-tags-matcher' to improve performance. It would be nice to not have - ;; to run `org-get-tags-at' for every heading, especially with inheritance. - (when-let ((tags-at (org-get-tags-at (point) (not org-use-tag-inheritance)))) + ;; to run `org-get-tags' for every heading, especially with inheritance. + (when-let ((tags-at (org-get-tags (point) (not org-use-tag-inheritance)))) (cl-typecase tags (null t) (otherwise (seq-intersection tags tags-at)))))