Add regexp matcher

This commit is contained in:
Adam Porter 2018-05-10 18:43:03 -05:00
parent 96dd06b144
commit 58b2cca65f
3 changed files with 23 additions and 3 deletions

View file

@ -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 ...)

View file

@ -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

View file

@ -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))))