Add: (org-ql-block) Respect Org Agenda restrictions
Fixes #84. Thanks to Ihor Radchenko (@yantar92) for reporting.
This commit is contained in:
parent
0a7e4f349f
commit
b3601cf0ae
3 changed files with 47 additions and 30 deletions
|
|
@ -398,6 +398,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
|
||||||
+ Info manual.
|
+ Info manual.
|
||||||
+ 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.
|
||||||
+ Display a message when views are refreshed. (Thanks to [[https://github.com/xeijin][xeijin]].)
|
+ Display a message when views are refreshed. (Thanks to [[https://github.com/xeijin][xeijin]].)
|
||||||
|
+ Respect Org Agenda restriction in =org-ql-block=. (Thanks to [[https://github.com/yantar92][Ihor Radchenko]] for reporting.)
|
||||||
|
|
||||||
*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]].)
|
+ 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]].)
|
||||||
|
|
|
||||||
|
|
@ -231,24 +231,38 @@ function `org-agenda-files'. Inserts a newline after the block.
|
||||||
If `org-ql-block-header' is non-nil, it is used as the header
|
If `org-ql-block-header' is non-nil, it is used as the header
|
||||||
string for the block, otherwise a the header is formed
|
string for the block, otherwise a the header is formed
|
||||||
automatically from the query."
|
automatically from the query."
|
||||||
(when-let* ((from (org-agenda-files nil 'ifmode))
|
(let (narrow-p old-beg old-end)
|
||||||
(items (org-ql-select from query
|
(when-let* ((from (pcase org-agenda-overriding-restriction
|
||||||
:action 'element-with-markers)))
|
('nil (org-agenda-files nil 'ifmode))
|
||||||
;; Not sure if calling the prepare function is necessary, but let's follow the pattern.
|
('file (get 'org-agenda-files 'org-restrict))
|
||||||
(org-agenda-prepare)
|
('subtree (prog1 org-agenda-restrict
|
||||||
;; FIXME: `org-agenda--insert-overriding-header' is from an Org version newer than
|
(with-current-buffer org-agenda-restrict
|
||||||
;; I'm using. Should probably declare it as a minimum Org version after upgrading.
|
;; Narrow the buffer; remember to widen it later.
|
||||||
;; (org-agenda--insert-overriding-header (or org-ql-block-header (org-ql-agenda--header-line-format from query)))
|
(setf old-beg (point-min) old-end (point-max)
|
||||||
(insert (org-add-props (or org-ql-block-header (org-ql-view--header-line-format from query))
|
narrow-p t)
|
||||||
nil 'face 'org-agenda-structure) "\n")
|
(narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end))))))
|
||||||
;; Calling `org-agenda-finalize' should be unnecessary, because in a "series" agenda,
|
(items (org-ql-select from query
|
||||||
;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing.
|
:action 'element-with-markers
|
||||||
;; But we do call `org-agenda-finalize-entries', which allows `org-super-agenda' to work.
|
:narrow narrow-p)))
|
||||||
(->> items
|
(when narrow-p
|
||||||
(-map #'org-ql-view--format-element)
|
;; Restore buffer's previous restrictions.
|
||||||
org-agenda-finalize-entries
|
(with-current-buffer from
|
||||||
insert)
|
(narrow-to-region old-beg old-end)))
|
||||||
(insert "\n")))
|
;; Not sure if calling the prepare function is necessary, but let's follow the pattern.
|
||||||
|
(org-agenda-prepare)
|
||||||
|
;; FIXME: `org-agenda--insert-overriding-header' is from an Org version newer than
|
||||||
|
;; I'm using. Should probably declare it as a minimum Org version after upgrading.
|
||||||
|
;; (org-agenda--insert-overriding-header (or org-ql-block-header (org-ql-agenda--header-line-format from query)))
|
||||||
|
(insert (org-add-props (or org-ql-block-header (org-ql-view--header-line-format from query))
|
||||||
|
nil 'face 'org-agenda-structure) "\n")
|
||||||
|
;; Calling `org-agenda-finalize' should be unnecessary, because in a "series" agenda,
|
||||||
|
;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing.
|
||||||
|
;; But we do call `org-agenda-finalize-entries', which allows `org-super-agenda' to work.
|
||||||
|
(->> items
|
||||||
|
(-map #'org-ql-view--format-element)
|
||||||
|
org-agenda-finalize-entries
|
||||||
|
insert)
|
||||||
|
(insert "\n"))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defalias 'org-ql-block 'org-ql-search-block)
|
(defalias 'org-ql-block 'org-ql-search-block)
|
||||||
|
|
|
||||||
26
org-ql.info
26
org-ql.info
|
|
@ -723,6 +723,8 @@ 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.
|
||||||
• Display a message when views are refreshed. (Thanks to xeijin
|
• Display a message when views are refreshed. (Thanks to xeijin
|
||||||
(https://github.com/xeijin).)
|
(https://github.com/xeijin).)
|
||||||
|
• Respect Org Agenda restriction in org-ql-block. (Thanks to Ihor
|
||||||
|
Radchenko (https://github.com/yantar92) for reporting.)
|
||||||
|
|
||||||
*Fixed*
|
*Fixed*
|
||||||
• Inherit file tags when org-tag-inheritance is enabled. (Fixes #55
|
• Inherit file tags when org-tag-inheritance is enabled. (Fixes #55
|
||||||
|
|
@ -1028,18 +1030,18 @@ Node: Agenda-like views18025
|
||||||
Node: Listing / acting-on results19430
|
Node: Listing / acting-on results19430
|
||||||
Node: Changelog24032
|
Node: Changelog24032
|
||||||
Node: 04-pre24569
|
Node: 04-pre24569
|
||||||
Node: 03226689
|
Node: 03226822
|
||||||
Node: 03127070
|
Node: 03127203
|
||||||
Node: 0327265
|
Node: 0327398
|
||||||
Node: 02330238
|
Node: 02330371
|
||||||
Node: 02230464
|
Node: 02230597
|
||||||
Node: 02130730
|
Node: 02130863
|
||||||
Node: 0230927
|
Node: 0231060
|
||||||
Node: 0134960
|
Node: 0135093
|
||||||
Node: Notes35059
|
Node: Notes35192
|
||||||
Node: Comparison with Org Agenda searches35221
|
Node: Comparison with Org Agenda searches35354
|
||||||
Node: org-sidebar36092
|
Node: org-sidebar36225
|
||||||
Node: License36371
|
Node: License36504
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue