From 55694f17fce4dc566f533b0b5f8cd60c4dad9670 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 9 Sep 2019 09:04:07 -0500 Subject: [PATCH] Fix: (descendants) matched against parent heading It matched against parent headings instead of only descendants, which caused some queries to return incorrect results. Released as 0.2.1. --- README.org | 5 +++++ org-ql.el | 3 ++- tests/test-org-ql.el | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index c95c81a..af8774b 100644 --- a/README.org +++ b/README.org @@ -441,6 +441,11 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience /Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases. +** 0.2.1 + +*Fixed* ++ =(descendants)= selector matched against parent heading instead of only descendants. + ** 0.2 :PROPERTIES: :ID: 67be09f9-e959-4333-9be2-93ad8f458fbe diff --git a/org-ql.el b/org-ql.el index 09272db..f2eb234 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2,7 +2,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.2 +;; Version: 0.2.1 ;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.0") (s "1.12.0") (ts "0.2")) ;; Keywords: hypermedia, outlines, Org, agenda @@ -683,6 +683,7 @@ Or, when possible, fix the problem." (save-restriction (org-narrow-to-subtree) (when (org-goto-first-child) + (narrow-to-region (point) (point-max)) (catch 'found (org-ql-select (current-buffer) query diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index cb73fea..01ef3c5 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -251,7 +251,13 @@ RESULTS should be a list of strings as returned by '("Test data" "Recurring"))) (org-ql-it "with granddescendants query" (org-ql-expect ((descendants (descendants "moon"))) - '("Test data" "Take over the universe" "Take over the moon" "Code")))) + '("Test data" "Take over the universe"))) + (org-ql-it "with query that should not match parent" + ;; This test would fail if the `descendants' predicate did not properly exclude + ;; the parent heading by narrowing the buffer to begin at the first child. + (org-ql-expect ((and (descendants (todo "WAITING")) + (not (descendants (todo "TODO" "NEXT"))))) + '("Take over the moon")))) (describe "(clocked)"