Fix: Inherit org-file-tags
Fixes #55. Closes #57. Thanks to Mikhail Skorzhinskiy (@mskorzhinskiy).
This commit is contained in:
parent
dadbbe4a87
commit
9f5bbeb3f2
5 changed files with 84 additions and 32 deletions
|
|
@ -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.
|
+ 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*
|
*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.)
|
+ 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=.
|
+ 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]].)
|
+ Face for done to-do keywords in =org-ql-view= buffers. (Thanks to [[https://github.com/dsdshcym][Yiming Chen]].)
|
||||||
|
|
|
||||||
35
org-ql.el
35
org-ql.el
|
|
@ -392,22 +392,25 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
|
||||||
'org-ql-nil))
|
'org-ql-nil))
|
||||||
(inherited-tags (or (when org-use-tag-inheritance
|
(inherited-tags (or (when org-use-tag-inheritance
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when (org-up-heading-safe)
|
(if (org-up-heading-safe)
|
||||||
(-let* (((inherited local) (org-ql--tags-at (point)))
|
;; Return parent heading's tags.
|
||||||
(tags (when (or inherited local)
|
(-let* (((inherited local) (org-ql--tags-at (point)))
|
||||||
(cond ((and (listp inherited)
|
(tags (when (or inherited local)
|
||||||
(listp local))
|
(cond ((and (listp inherited)
|
||||||
(->> (append inherited local)
|
(listp local))
|
||||||
-non-nil -uniq))
|
(->> (append inherited local)
|
||||||
((listp inherited) inherited)
|
-non-nil -uniq))
|
||||||
((listp local) local)))))
|
((listp inherited) inherited)
|
||||||
(cl-typecase org-use-tag-inheritance
|
((listp local) local)))))
|
||||||
(list (setf tags (-intersection tags org-use-tag-inheritance)))
|
(cl-typecase org-use-tag-inheritance
|
||||||
(string (setf tags (--select (string-match org-use-tag-inheritance it)
|
(list (setf tags (-intersection tags org-use-tag-inheritance)))
|
||||||
tags))))
|
(string (setf tags (--select (string-match org-use-tag-inheritance it)
|
||||||
(pcase org-tags-exclude-from-inheritance
|
tags))))
|
||||||
('nil tags)
|
(pcase org-tags-exclude-from-inheritance
|
||||||
(_ (-difference tags 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))
|
'org-ql-nil))
|
||||||
(all-tags (list inherited-tags local-tags)))
|
(all-tags (list inherited-tags local-tags)))
|
||||||
;; Check caches again, because they may have been set now.
|
;; Check caches again, because they may have been set now.
|
||||||
|
|
|
||||||
27
org-ql.info
27
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.
|
for custom Helm commands that search certain files.
|
||||||
|
|
||||||
*Fixed*
|
*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
|
• Call helm-make-source directly instead of using
|
||||||
helm-build-sync-source macro. (Fixes #60
|
helm-build-sync-source macro. (Fixes #60
|
||||||
(https://github.com/alphapapa/org-ql/issues/60). Thanks to Matt
|
(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: Listing / acting-on results19681
|
||||||
Node: Changelog24283
|
Node: Changelog24283
|
||||||
Node: 04-pre24820
|
Node: 04-pre24820
|
||||||
Node: 03226633
|
Node: 03226835
|
||||||
Node: 03127014
|
Node: 03127216
|
||||||
Node: 0327209
|
Node: 0327411
|
||||||
Node: 02330182
|
Node: 02330384
|
||||||
Node: 02230408
|
Node: 02230610
|
||||||
Node: 02130674
|
Node: 02130876
|
||||||
Node: 0230871
|
Node: 0231073
|
||||||
Node: 0134904
|
Node: 0135106
|
||||||
Node: Notes35003
|
Node: Notes35205
|
||||||
Node: Comparison with Org Agenda searches35165
|
Node: Comparison with Org Agenda searches35367
|
||||||
Node: org-sidebar36036
|
Node: org-sidebar36238
|
||||||
Node: License36315
|
Node: License36517
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|
||||||
|
|
|
||||||
16
tests/data2.org
Normal file
16
tests/data2.org
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# This file is currently used to test org-file-tags.
|
||||||
|
|
||||||
|
#+FILETAGS: :food:
|
||||||
|
|
||||||
|
* Fruit :fruit:
|
||||||
|
|
||||||
|
** Blueberry
|
||||||
|
|
||||||
|
** Strawberry
|
||||||
|
|
||||||
|
* Vegetable :vegetable:
|
||||||
|
|
||||||
|
** Broccoli
|
||||||
|
|
||||||
|
** Potato
|
||||||
|
|
||||||
|
|
@ -760,7 +760,15 @@ RESULTS should be a list of strings as returned by
|
||||||
(org-ql-expect ((tags "Emacs" "space"))
|
(org-ql-expect ((tags "Emacs" "space"))
|
||||||
'("Visit Mars" "Visit the moon" "/r/emacs" "Rewrite Emacs in Common Lisp"))
|
'("Visit Mars" "Visit the moon" "/r/emacs" "Rewrite Emacs in Common Lisp"))
|
||||||
(org-ql-expect ((not (tags "Emacs" "space")))
|
(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)"
|
(describe "(tags-inherited)"
|
||||||
|
|
||||||
|
|
@ -783,7 +791,15 @@ RESULTS should be a list of strings as returned by
|
||||||
'("Skype with president of Antarctica"))
|
'("Skype with president of Antarctica"))
|
||||||
(org-ql-expect ((not (tags-inherited "personal" "world")))
|
(org-ql-expect ((not (tags-inherited "personal" "world")))
|
||||||
;; Note that this correctly includes the task "Practice leaping...", which has the LOCAL tag "personal".
|
;; 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)"
|
(describe "(tags-local)"
|
||||||
|
|
||||||
|
|
@ -805,7 +821,15 @@ RESULTS should be a list of strings as returned by
|
||||||
(org-ql-expect ((ltags "personal" "world"))
|
(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"))
|
'("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")))
|
(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&)"
|
(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"))
|
(org-ql-expect ((tags-all "universe" "personal"))
|
||||||
'("Practice leaping tall buildings in a single bound"))
|
'("Practice leaping tall buildings in a single bound"))
|
||||||
(org-ql-expect ((tags& "ambition" "space"))
|
(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)"
|
(describe "(ts)"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue