From 9bd8a99a6ecb5df3f7e880f46975f356282c7baa Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 23 Sep 2022 23:31:57 +0800 Subject: [PATCH] org-agenda-get-sexps: Avoid excessive calls to `org-agenda-skip' * lisp/org-agenda.el (org-agenda-get-sexps): Only check if entry should be skipped on matching sexps, when `org-diary-sexp-entry' returns non-nil. --- lisp/org-agenda.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 4c3889d120..b608bdd290 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5913,7 +5913,11 @@ displayed in agenda view." (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip - (org-agenda-skip (org-element-at-point)) + ;; We do not run `org-agenda-skip' righ away because every single sexp + ;; in the buffer is matched here, unlike day-specific search + ;; in ordinary timestamps. Most of the sexps will not match + ;; the agenda day and it is quicker to run `org-agenda-skip' only for + ;; matching sexps later on. (setq beg (match-beginning 0)) (goto-char (1- (match-end 0))) (setq b (point)) @@ -5929,6 +5933,8 @@ displayed in agenda view." "")) (setq result (org-diary-sexp-entry sexp sexp-entry date)) (when result + ;; Only check if entry should be skipped on matching sexps. + (org-agenda-skip (org-element-at-point)) (setq marker (org-agenda-new-marker beg) level (make-string (org-reduced-level (org-outline-level)) ? ) category (org-get-category beg)