diff --git a/README.org b/README.org index b4db8a6..e16f59c 100644 --- a/README.org +++ b/README.org @@ -392,6 +392,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience + Function ~helm-org-ql-source~, which returns a Helm source that searches given buffers/files with ~helm-org-ql~. It can be used for custom Helm commands that search certain files. *Fixed* ++ Inherit file tags when =org-tag-inheritance= is enabled. (Fixes [[https://github.com/alphapapa/org-ql/issues/55][#55]]. Thanks to [[https://github.com/mskorzhinskiy][Mikhail Skorzhinskiy]].) + Call =helm-make-source= directly instead of using =helm-build-sync-source= macro. (Fixes [[https://github.com/alphapapa/org-ql/issues/60][#60]]. Thanks to [[https://github.com/matthuszagh][Matt Huszagh]] for reporting.) + Search/view buffers now always end with a newline, which prevents side-scrolling of the window when calling =end-of-buffer=. + Face for done to-do keywords in =org-ql-view= buffers. (Thanks to [[https://github.com/dsdshcym][Yiming Chen]].) diff --git a/org-ql.el b/org-ql.el index 9f7d939..77de804 100644 --- a/org-ql.el +++ b/org-ql.el @@ -392,22 +392,25 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)." 'org-ql-nil)) (inherited-tags (or (when org-use-tag-inheritance (save-excursion - (when (org-up-heading-safe) - (-let* (((inherited local) (org-ql--tags-at (point))) - (tags (when (or inherited local) - (cond ((and (listp inherited) - (listp local)) - (->> (append inherited local) - -non-nil -uniq)) - ((listp inherited) inherited) - ((listp local) local))))) - (cl-typecase org-use-tag-inheritance - (list (setf tags (-intersection tags org-use-tag-inheritance))) - (string (setf tags (--select (string-match org-use-tag-inheritance it) - tags)))) - (pcase org-tags-exclude-from-inheritance - ('nil tags) - (_ (-difference tags org-tags-exclude-from-inheritance))))))) + (if (org-up-heading-safe) + ;; Return parent heading's tags. + (-let* (((inherited local) (org-ql--tags-at (point))) + (tags (when (or inherited local) + (cond ((and (listp inherited) + (listp local)) + (->> (append inherited local) + -non-nil -uniq)) + ((listp inherited) inherited) + ((listp local) local))))) + (cl-typecase org-use-tag-inheritance + (list (setf tags (-intersection tags org-use-tag-inheritance))) + (string (setf tags (--select (string-match org-use-tag-inheritance it) + tags)))) + (pcase org-tags-exclude-from-inheritance + ('nil tags) + (_ (-difference tags org-tags-exclude-from-inheritance)))) + ;; Top-level heading: use file tags. + org-file-tags))) 'org-ql-nil)) (all-tags (list inherited-tags local-tags))) ;; Check caches again, because they may have been set now. diff --git a/org-ql.info b/org-ql.info index c11519c..67b883b 100644 --- a/org-ql.info +++ b/org-ql.info @@ -723,6 +723,9 @@ File: README.info, Node: 04-pre, Next: 032, Up: Changelog for custom Helm commands that search certain files. *Fixed* + • Inherit file tags when org-tag-inheritance is enabled. (Fixes #55 + (https://github.com/alphapapa/org-ql/issues/55). Thanks to Mikhail + Skorzhinskiy (https://github.com/mskorzhinskiy).) • Call helm-make-source directly instead of using helm-build-sync-source macro. (Fixes #60 (https://github.com/alphapapa/org-ql/issues/60). Thanks to Matt @@ -1023,18 +1026,18 @@ Node: Agenda-like views18276 Node: Listing / acting-on results19681 Node: Changelog24283 Node: 04-pre24820 -Node: 03226633 -Node: 03127014 -Node: 0327209 -Node: 02330182 -Node: 02230408 -Node: 02130674 -Node: 0230871 -Node: 0134904 -Node: Notes35003 -Node: Comparison with Org Agenda searches35165 -Node: org-sidebar36036 -Node: License36315 +Node: 03226835 +Node: 03127216 +Node: 0327411 +Node: 02330384 +Node: 02230610 +Node: 02130876 +Node: 0231073 +Node: 0135106 +Node: Notes35205 +Node: Comparison with Org Agenda searches35367 +Node: org-sidebar36238 +Node: License36517  End Tag Table diff --git a/tests/data2.org b/tests/data2.org new file mode 100644 index 0000000..673cf7f --- /dev/null +++ b/tests/data2.org @@ -0,0 +1,16 @@ +# This file is currently used to test org-file-tags. + +#+FILETAGS: :food: + +* Fruit :fruit: + +** Blueberry + +** Strawberry + +* Vegetable :vegetable: + +** Broccoli + +** Potato + diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index ca20066..babdb87 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -760,7 +760,15 @@ RESULTS should be a list of strings as returned by (org-ql-expect ((tags "Emacs" "space")) '("Visit Mars" "Visit the moon" "/r/emacs" "Rewrite Emacs in Common Lisp")) (org-ql-expect ((not (tags "Emacs" "space"))) - '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony")))) + '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags "food")) + '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags "fruit")) + '("Fruit" "Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) (describe "(tags-inherited)" @@ -783,7 +791,15 @@ RESULTS should be a list of strings as returned by '("Skype with president of Antarctica")) (org-ql-expect ((not (tags-inherited "personal" "world"))) ;; Note that this correctly includes the task "Practice leaping...", which has the LOCAL tag "personal". - '("Take over the universe" "Take over the world" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony")))) + '("Take over the universe" "Take over the world" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-inherited "food")) + '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags-inherited "fruit")) + '("Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) (describe "(tags-local)" @@ -805,7 +821,15 @@ RESULTS should be a list of strings as returned by (org-ql-expect ((ltags "personal" "world")) '("Take over the world" "Skype with president of Antarctica" "Practice leaping tall buildings in a single bound" "Get haircut")) (org-ql-expect ((not (tags-local "personal" "world"))) - '("Take over the universe" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony")))) + '("Take over the universe" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-local "food")) + nil + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags-local "fruit")) + '("Fruit") + :buffer (org-ql-test-data-buffer "data2.org")))) (describe "(tags-all), (tags&)" @@ -813,7 +837,12 @@ RESULTS should be a list of strings as returned by (org-ql-expect ((tags-all "universe" "personal")) '("Practice leaping tall buildings in a single bound")) (org-ql-expect ((tags& "ambition" "space")) - '("Visit Mars" "Visit the moon")))) + '("Visit Mars" "Visit the moon"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-all "food" "fruit")) + '("Fruit" "Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) (describe "(ts)"