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.
|
||||
+ 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]].)
|
||||
+ Respect Org Agenda restriction in =org-ql-block=. (Thanks to [[https://github.com/yantar92][Ihor Radchenko]] for reporting.)
|
||||
|
||||
*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]].)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
string for the block, otherwise a the header is formed
|
||||
automatically from the query."
|
||||
(when-let* ((from (org-agenda-files nil 'ifmode))
|
||||
(items (org-ql-select from query
|
||||
:action 'element-with-markers)))
|
||||
;; 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")))
|
||||
(let (narrow-p old-beg old-end)
|
||||
(when-let* ((from (pcase org-agenda-overriding-restriction
|
||||
('nil (org-agenda-files nil 'ifmode))
|
||||
('file (get 'org-agenda-files 'org-restrict))
|
||||
('subtree (prog1 org-agenda-restrict
|
||||
(with-current-buffer org-agenda-restrict
|
||||
;; Narrow the buffer; remember to widen it later.
|
||||
(setf old-beg (point-min) old-end (point-max)
|
||||
narrow-p t)
|
||||
(narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end))))))
|
||||
(items (org-ql-select from query
|
||||
:action 'element-with-markers
|
||||
:narrow narrow-p)))
|
||||
(when narrow-p
|
||||
;; Restore buffer's previous restrictions.
|
||||
(with-current-buffer from
|
||||
(narrow-to-region old-beg old-end)))
|
||||
;; 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
|
||||
(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.
|
||||
• Display a message when views are refreshed. (Thanks to xeijin
|
||||
(https://github.com/xeijin).)
|
||||
• Respect Org Agenda restriction in org-ql-block. (Thanks to Ihor
|
||||
Radchenko (https://github.com/yantar92) for reporting.)
|
||||
|
||||
*Fixed*
|
||||
• 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: Changelog24032
|
||||
Node: 04-pre24569
|
||||
Node: 03226689
|
||||
Node: 03127070
|
||||
Node: 0327265
|
||||
Node: 02330238
|
||||
Node: 02230464
|
||||
Node: 02130730
|
||||
Node: 0230927
|
||||
Node: 0134960
|
||||
Node: Notes35059
|
||||
Node: Comparison with Org Agenda searches35221
|
||||
Node: org-sidebar36092
|
||||
Node: License36371
|
||||
Node: 03226822
|
||||
Node: 03127203
|
||||
Node: 0327398
|
||||
Node: 02330371
|
||||
Node: 02230597
|
||||
Node: 02130863
|
||||
Node: 0231060
|
||||
Node: 0135093
|
||||
Node: Notes35192
|
||||
Node: Comparison with Org Agenda searches35354
|
||||
Node: org-sidebar36225
|
||||
Node: License36504
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue