Fix: (org-ql-block-header, org-ql-search-block)
Omitted this feature when I refactored the -agenda file. Also, put back the improved docstring. Fixes #32. Thanks to Josiah Schwab (@jschwab).
This commit is contained in:
parent
1b60f8e2a7
commit
75fd46022f
1 changed files with 17 additions and 8 deletions
|
|
@ -36,6 +36,11 @@
|
||||||
(require 'org-ql)
|
(require 'org-ql)
|
||||||
(require 'org-ql-view)
|
(require 'org-ql-view)
|
||||||
|
|
||||||
|
;;;; Variables
|
||||||
|
|
||||||
|
(defvar org-ql-block-header nil
|
||||||
|
"An optional string to override the default header in `org-ql-block' agenda blocks.")
|
||||||
|
|
||||||
;;;; Commands
|
;;;; Commands
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
@ -158,12 +163,16 @@ necessary."
|
||||||
|
|
||||||
(defun org-ql-search-block (query)
|
(defun org-ql-search-block (query)
|
||||||
"Insert items for QUERY into current buffer.
|
"Insert items for QUERY into current buffer.
|
||||||
QUERY should be an `org-ql' query form. Like other agenda block
|
QUERY should be an `org-ql' query form. Intended to be used as a
|
||||||
commands, it searches files returned by function
|
user-defined function in `org-agenda-custom-commands'. QUERY
|
||||||
`org-agenda-files'. Intended to be used as a user-defined
|
corresponds to the `match' item in the custom command form.
|
||||||
function in `org-agenda-custom-commands'. QUERY corresponds to
|
|
||||||
the `match' item in the custom command form. Inserts a newline
|
Like other agenda block commands, it searches files returned by
|
||||||
after the block."
|
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))
|
(when-let* ((from (org-agenda-files nil 'ifmode))
|
||||||
(items (org-ql-select from query
|
(items (org-ql-select from query
|
||||||
:action 'element-with-markers)))
|
:action 'element-with-markers)))
|
||||||
|
|
@ -171,8 +180,8 @@ after the block."
|
||||||
(org-agenda-prepare)
|
(org-agenda-prepare)
|
||||||
;; FIXME: `org-agenda--insert-overriding-header' is from an Org version newer than
|
;; 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.
|
;; I'm using. Should probably declare it as a minimum Org version after upgrading.
|
||||||
;; (org-agenda--insert-overriding-header (org-ql-search--header-line-format from query))
|
;; (org-agenda--insert-overriding-header (or org-ql-block-header (org-ql-agenda--header-line-format from query)))
|
||||||
(insert (org-add-props (org-ql-view--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")
|
nil 'face 'org-agenda-structure) "\n")
|
||||||
;; Calling `org-agenda-finalize' should be unnecessary, because in a "series" agenda,
|
;; 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.
|
;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue