From 58b2cca65f755aec6ad707b111bc3c9d3949892a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 10 May 2018 18:43:03 -0500 Subject: [PATCH] Add regexp matcher --- README.org | 6 +++--- notes.org | 10 ++++++++++ org-agenda-ng.el | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 50ab9ea..a1384fd 100644 --- a/README.org +++ b/README.org @@ -50,11 +50,11 @@ Another way to look at it is like a "query language" for Org buffers. For examp (tags "Emacs") (priority >= "B"))) ;; => ((headline (:raw-value "org-board" :begin 1220270 :end 1220403 ...)) ...) - ;; Find non-done TODO items which are tagged "Emacs" and have priority "B" or higher, and return a - ;; list of heading positions: + ;; Find non-done items which contain the term "Emacs" and have priority "B" or higher, and + ;; return a list of heading positions: (org-ql org-agenda-files (and (not (done)) - (tags "Emacs") + (regexp "Emacs") (priority >= "B")) :action-fn (lambda (element) (org-element-property :begin element))) ;; => (44154 46469 56008 63965 100008 ...) diff --git a/notes.org b/notes.org index c3979bd..5cfefb4 100644 --- a/notes.org +++ b/notes.org @@ -176,6 +176,16 @@ Doesn't seem to make any difference. (done))) #+END_SRC +** Regexp matching + +#+BEGIN_SRC elisp + (org-ql "~/src/emacs/org-super-agenda/test/test.org" + (regexp "over")) + + (org-agenda-ng "~/src/emacs/org-super-agenda/test/test.org" + (regexp "over")) +#+END_SRC + ** Screenshot code #+BEGIN_SRC elisp diff --git a/org-agenda-ng.el b/org-agenda-ng.el index e321801..54ec866 100644 --- a/org-agenda-ng.el +++ b/org-agenda-ng.el @@ -128,6 +128,7 @@ NONE-PREDS." (todo #'org-agenda-ng--todo-p) (done #'org-agenda-ng--done-p) (tags #'org-agenda-ng--tags-p) + (regexp #'org-ql--regexp-p) (org-back-to-heading #'outline-back-to-heading)) (org-with-wide-buffer (goto-char (point-min)) @@ -464,3 +465,12 @@ comparator, PRIORITY should be a priority string." (defun org-agenda-ng--habit-p () (org-is-habit-p)) + +(defun org-ql--regexp-p (regexp) + "Return non-nil if current entry matches REGEXP." + (let ((end (or (save-excursion + (outline-next-heading)) + (point-max)))) + (save-excursion + (goto-char (line-beginning-position)) + (re-search-forward regexp end t))))