From 317df58d98349bacb23547d625d026eb00df3717 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 12 Apr 2020 13:40:09 +0800 Subject: [PATCH] Honor restriction when it is set from inside agenda dispatcher --- org-ql-search.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index f84dfed..a906741 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -195,15 +195,14 @@ 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." (let (narrow-p old-beg old-end) - (when-let* ((from (pcase org-agenda-overriding-restriction + (when-let* ((from (pcase org-agenda-restrict ('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)))))) + (_ (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)))