This package provides a query language for Org files. It offers two syntax styles: Lisp-like sexps and search engine-like keywords.
It includes three libraries: The org-ql
library is flexible and may be used as a backend for other tools. The libraries org-ql-search
and helm-org-ql
(a separate package) provide interactive search commands and saved views.
The package org-ql
may be installed directly from MELPA or with other tools like Quelpa.
After installation, you can use the commands without additional configuration. To use the functions and macros in your own Elisp code, use libraries org-ql
and org-ql-view
.
Installing with Quelpa is easy:
(use-package org-ql :quelpa (org-ql :fetcher github :repo "alphapapa/org-ql" :files (:defaults (:exclude "helm-org-ql.el"))))
The command helm-org-ql
is available in the package helm-org-ql
. It may be installed from MELPA, or with Quelpa, like so:
(use-package helm-org-ql :quelpa (helm-org-ql :fetcher github :repo "alphapapa/org-ql" :files ("helm-org-ql.el")))
Feedback on these APIs is welcome. Eventually, after being tested and polished, they will be considered stable.
Lisp code examples are in examples.org.
Note: These commands use non-sexp queries.
These commands jump to a heading selected using Emacs’s built-in completion facilities with an Org QL query:
org-ql-find
searches in the current buffer.org-ql-find-path
searches outline paths in the current buffer.org-ql-find-in-agenda
searches in (org-agenda-files)
.org-ql-find-in-org-directory
searches in org-directory
.Note that these commands are compatible with Embark: the embark-act
command can be called on a completion candidate (i.e. a search result) to act on it immediately, without having to visit the entry in its source Org buffer, and embark-export
may be called to show the results in an org-ql-view
buffer.
This command finds links in entries matching the input query and offers them for selection; the selected link is then opened with org-open-at-point
.
The input is matched using the default predicate, which means it searches both entry content and outline paths. This is helpful when a collection of links are kept in Org files: rather than having to first visit the entry containing the desired link, then locate it within the entry, and then open it, the user can simply select the link and open it directly. For example, if an entry with the heading Emacs
contained a link named mailing list
, one could search for Emacs list
and open the link to the mailing list directly.
This command refiles the current Org entry to one selected by searching with Org QL completion. It searches files listed in org-refile-targets
as well as the current buffer.
Note: This command supports both sexp queries and non-sexp queries.
Read QUERY
and search with org-ql
. Interactively, prompt for these variables:
BUFFERS-FILES
: A
list of buffers and/or files to search. Interactively, may also be:
buffer
: search the current bufferall
: search all Org buffersagenda
: search buffers returned by the function org-agenda-files
GROUPS
: An org-super-agenda
group set. See variable org-super-agenda-groups
.
NARROW
: When non-nil, don’t widen buffers before searching. Interactively, with prefix, leave narrowed.
SORT
: One or a list of org-ql
sorting functions, like date
or priority
.
Bindings: Keys bound in results buffer.
r
: Refresh results. With prefix, prompt to adjust search parameters.v
: Show transient
view dispatcher (like Magit’s popups).C-x C-s
: Save query to variable org-ql-views
(accessible with command org-ql-view
).Note: The view buffer is currently put in org-agenda-mode
, which means that some Org Agenda commands work, such as jumping to entries and changing item priorities (without necessarily updating the view). This feature is experimental and not guaranteed to work correctly with all commands. (It works to the extent it does because the appropriate text properties are placed on each item, imitating an Agenda buffer.)
Note: Also, this buffer is compatible with Embark: the embark-act
command can be called on an entry to act on it immediately, without having to visit the entry in its source Org buffer.
Note: This command uses non-sexp queries. It is available separately in the package =helm-org-ql=.
This command displays matches with Helm.
C-x C-s
in the Helm session to save the results to an org-ql-search
buffer.Choose and display a view stored in org-ql-views
.
Bindings: Keys bound in view buffer.
g
, r
: Refresh results. With prefix, prompt to adjust search parameters.v
: Show transient
view dispatcher (like Magit’s popups).C-x C-s
: Save query to variable org-ql-views
(accessible with command org-ql-view
).Show a sidebar window listing views stored in org-ql-views
for easy access. In the sidebar, press RET
or mouse-1
to show the view at point, and press c
to customize the view at point.
Show items in FILES
from last DAYS
days with timestamps of TYPE
. TYPE
may be ts
, ts-active
, ts-inactive
, clocked
, closed
, deadline
, planning
, or scheduled
. FILES
defaults to those returned by the function org-agenda-files
.
Arguments: (query &key keep-previous (buffer (current-buffer)))
Show a sparse tree for QUERY
in BUFFER
and return number of results. The tree will show the lines where the query matches, and any other context defined in org-show-context-detail
, which see.
QUERY
is an org-ql
query sexp (quoted, since this is a function). BUFFER
defaults to the current buffer. When KEEP-PREVIOUS
is non-nil (interactively, with prefix), the outline is not reset to the overview state before finding matches, which allows stacking calls to this command. Runs org-occur-hook
after making the sparse tree.
An org-ql
query is a Lisp expression which may contain arbitrary expressions, as well as calling certain built-in predicates. It is byte-compiled into a predicate function which is tested with point on each heading in an Org buffer; when it returns non-nil, the heading matches the query. When possible, certain built-in predicates are optimized away to whole-buffer regular expression searches, which are much faster to search for than testing the predicate on each heading.
Notes:
"string"
are automatically converted to (regexp "string")
predicates.<
, <=
, >
, >=
, =
) need not be quoted when passed as an argument to predicates which accept them. The resemblance to infix notation is coincidental.The command org-ql-search
also accepts, and the command helm-org-ql
only accepts, an alternative, non-sexp query syntax. The syntax is simple, and a few examples of queries in both syntaxes should suffice. By default, when multiple predicates are used, they are combined with boolean and
.
(todo)
todo:
(todo "SOMEDAY")
todo:SOMEDAY
(todo "SOMEDAY" "WAITING")
todo:SOMEDAY,WAITING
(ts :on today)
ts:on=today
(ts-active :from "2017-01-01" :to "2018-01-01")
ts-active:from=2017-01-01,to=2018-01-01
(clocked :on -1)
clocked:on=-1
(heading "quoted phrase" "word")
heading:"quoted phrase",word
(and (tags "book" "books") (priority "A"))
tags:book,books priority:A
(src :lang "elisp" :regexps ("defun"))
src:defun,lang=elisp
or src:lang=elisp,defun
(and (tags "space") (not (regexp "moon")))
tags:space !moon
(priority >= B)
priority:A,B
Note that the effort
, level
, and priority
predicates do not support comparators in the non-sexp syntax, so multiple arguments should be passed instead, as seen in the last example.
Arguments are listed next to predicate names, where applicable.
blocked
org-entry-blocked-p
, which see.
category (&rest categories)
CATEGORIES
(a list of strings).
done
TODO
keyword is in org-done-keywords
.
effort (&optional effort-or-comparator effort)
(effort DURATION)
: Matches if effort is DURATION
. (effort DURATION DURATION)
: Matches if effort is between DURATIONs, inclusive. (effort COMPARATOR DURATION)
: Matches if effort compares to DURATION
with COMPARATOR
. COMPARATOR
may be <
, <=
, >
, or >=
. DURATION
should be an Org effort string, like 5
or 0:05
.
habit
heading (&rest strings)
STRINGS
. Matching is done case-insensitively.
h
.heading-regexp (&rest regexps)
REGEXPS
(regexp strings). Matching is done case-insensitively.
h*
.level (level-or-comparator &optional level)
(level NUMBER)
: Matches if heading level is NUMBER
. (level NUMBER NUMBER)
: Matches if heading level is equal to or between NUMBERs. (level COMPARATOR NUMBER)
: Matches if heading level compares to NUMBER
with COMPARATOR
. COMPARATOR
may be <
, <=
, >
, or >=
.
link (&optional description-or-target &key description target regexp-p)
DESCRIPTION-OR-TARGET
is matched against the link’s description and target. Alternatively, one or both of DESCRIPTION
and TARGET
may be matched separately. Without arguments, return non-nil if any link is found.
outline-path (&rest strings)
STRINGS
. Each string may appear as a substring in any part of the node’s outline path. For example, the path Food/Fruits/Grapes
would match (olp "Fruit" "Grape")
.
olp
.outline-path-segment (&rest strings)
STRINGS
. Matches STRINGS
as a contiguous segment of the outline path. Each string is compared as a substring. For example the path Food/Fruits/Grapes
would match (olps "Fruit" "Grape")
but not (olps "Food" "Grape")
.
olps
.path (&rest regexps)
REGEXPS
(regexp strings). Without arguments, return non-nil if buffer is file-backed.
priority (&rest args)
ARGS
may be either a list of one or more priority letters as strings, or a comparator function symbol followed by a priority letter string. For example: (priority "A") (priority "A" "B") (priority '>= "B")
Note that items without a priority cookie never match this predicate (while Org itself considers items without a cookie to have the default priority, which, by default, is equal to priority B
).
property (property &optional value &key inherit)
PROPERTY
(a string), and optionally VALUE
(a string). If INHERIT
is nil, only match entries with PROPERTY
set on the entry; if t, also match entries with inheritance. If INHERIT
is not specified, use the value of org-use-property-inheritance
, which see.
regexp (&rest regexps)
REGEXPS
(regexp strings). Matches against entire entry, from beginning of its heading to the next heading.
r
.rifle (&rest strings)
org-rifle
. This is probably the most useful, intuitive, general-purpose predicate.
smart
.org-ql-default-predicate
.src (&key lang regexps)
LANG
is non-nil, match blocks of that language. If REGEXPS
is non-nil, require that block’s contents match all regexps. Matching is done case-insensitively.
tags (&rest tags)
TAGS
(a list of strings). Tests both inherited and local tags.
tags-inherited (&rest tags)
TAGS
(a list of strings). If TAGS
is nil, return non-nil if heading has any inherited tags.
inherited-tags
, tags-i
, itags
.tags-local (&rest tags)
TAGS
(a list of strings). If TAGS
is nil, return non-nil if heading has any local tags.
local-tags
, tags-l
, ltags
.tags-all (&rest tags)
TAGS
. Tests both inherited and local tags.
tags&
.tags-regexp (&rest regexps)
REGEXPS
. Tests both inherited and local tags.
tags*
.todo (&rest keywords)
TODO
item. With KEYWORDS
, return non-nil if its keyword is one of KEYWORDS
(a list of strings). When called without arguments, only matches non-done tasks (i.e. does not match keywords in org-done-keywords
).
ancestors (&optional query)
QUERY
, return non-nil if an ancestor heading matches it. This selector may be nested.
children (&optional query)
QUERY
, return non-nil if a child heading matches it. This selector may be nested, e.g. to match grandchild headings.
descendants (&optional query)
QUERY
, return non-nil if a descendant heading matches it. This selector may be nested (if you can grok the nesting!).
parent (&optional query)
QUERY
, return non-nil if the parent heading matches it. This selector may be nested, e.g. to match grandparent headings.
These predicates take optional keyword arguments:
:from
: Match entries whose timestamp is on or after timestamp :from
.:to
: Match entries whose timestamp is on or before timestamp :to
.:on
: Match entries whose timestamp is on date :on
.:with-time
: If unspecified, match timestamps with or without times (i.e. HH:MM). If nil, match timestamps without times. If t, match timestamps with times.Timestamp/date arguments should be either a number of days (positive to look forward, or negative to look backward), a string parseable by parse-time-string
(the string may omit the time value), the symbol today
, or a ts
struct.
ts
ts-active
, ts-a
ts
, but only matches active timestamps.
ts-inactive
, ts-i
ts
, but only matches inactive timestamps.
The following predicates, in addition to the keyword arguments, can also take a single argument, a number, which looks backward or forward a number of days. The number can be negative to invert the direction.
These two predicates interpret a single number argument as if it were passed to the :from
keyword argument, which eases the common case of searching for items clocked or closed in the past few days:
clocked
closed
These predicates interpret a single number argument as if it were passed to the :to
keyword argument, which eases the common case of searching for items planned in the next few days:
deadline
auto
, return non-nil if entry has deadline within org-deadline-warning-days
. Without arguments, return non-nil if entry has any deadline.
planning
scheduled
For use as a custom agenda block type in org-agenda-custom-commands
. For example, you could define a custom series command like this, which would list all priority A items tagged Emacs
with to-do keyword SOMEDAY
, followed by the standard agenda view, in a single buffer:
(setq org-agenda-custom-commands '(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items" ((org-ql-block '(and (todo "SOMEDAY") (tags "Emacs") (priority "A")) ((org-ql-block-header "SOMEDAY :Emacs: High-priority"))) (agenda)))))
Which would be equivalent to a tags-todo
search like this:
(setq org-agenda-custom-commands '(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items" ((tags-todo "PRIORITY=\"A\"+Emacs/!SOMEDAY") (agenda)))))
However, the org-ql-block
version runs in about 1/5th the time.
The variable org-ql-block-header
may be bound to a string to use as the block header, otherwise the header is formed automatically.
Org QL uses a per-buffer cache to speed up subsequent searches. It’s keyed on query expressions and match actions, which means that, for the same query and same match action in the same buffer, if the buffer has not been modified since the last time the query was run, the cached match-action result will be returned, and the query will not be evaluated in that buffer again.
Therefore, since neither query expressions nor match actions are guaranteed to be evaluated when the following functions are called, they should be free of side effects. Or, if a side effect is required, the cache should be invalidated (e.g. by incrementing the buffer’s modified tick, or by using a query expression or match action that has yet to be cached). Note: Future improvements will allow the cache to be more easily disabled or cleared.
Arguments: (buffers-or-files query &key action narrow sort)
Return items matching QUERY
in BUFFERS-OR-FILES
.
BUFFERS-OR-FILES
is a one or a list of files and/or buffers.
QUERY
is an org-ql
query sexp (quoted, since this is a function).
ACTION
is a function which is called on each matching entry with point at the beginning of its heading. It may be:
element
or nil: Equivalent to org-element-headline-parser
.element-with-markers
: Equivalent to calling org-element-headline-parser
, with markers added using org-ql--add-markers
. Suitable for formatting with org-ql-agenda--format-element
, allowing insertion into an Org Agenda-like buffer.If NARROW
is non-nil, buffers are not widened (the default is to widen and search the entire buffer).
SORT
is either nil, in which case items are not sorted; or one or a list of defined org-ql
sorting methods (date
, deadline
, scheduled
, closed
, todo
, priority
, or random
); or a user-defined comparator function that accepts two items as arguments and returns nil or non-nil.
Examples:
;; Return list of to-do headings in inbox file with tags and to-do keywords: (org-ql-select "~/org/inbox.org" '(todo) :action #'org-get-heading) ;; => ("TODO Practice leaping tall buildings in a single bound :personal:" ...) ;; Without tags and to-do keywords: (org-ql-select "~/org/inbox.org" '(todo) :action '(org-get-heading t t)) ;; => ("Practice leaping tall buildings in a single bound" ...) ;; Return WAITING heading elements in agenda files: (org-ql-select (org-agenda-files) '(todo "WAITING") :action 'element) ;; => ((headline (:raw-value "Visit the moon" ...) ...) ...) ;; Since `element' is the default for ACTION, it may be omitted: (org-ql-select (org-agenda-files) '(todo "WAITING")) ;; => ((headline (:raw-value "Visit the moon" ...) ...) ...)
Arguments: (&key (select 'element-with-markers) from where order-by narrow)
Like org-ql-select
, but arguments are named more like a SQL
query.
SELECT
corresponds to the org-ql-select
argument ACTION
.FROM
corresponds to the org-ql-select
argument BUFFERS-OR-FILES
.WHERE
corresponds to the org-ql-select
argument QUERY
.ORDER-BY
corresponds to the org-ql-select
argument SORT
, which see.NARROW
corresponds to the org-ql-select
argument NARROW
.Examples:
;; Return list of to-do headings in inbox file with tags and to-do keywords: (org-ql-query :select #'org-get-heading :from "~/org/inbox.org" :where '(todo)) ;; => ("TODO Practice leaping tall buildings in a single bound :personal:" ...) ;; Without tags and to-do keywords: (org-ql-query :select '(org-get-heading t t) :from "~/org/inbox.org" :where '(todo)) ;; => ("Practice leaping tall buildings in a single bound" ...) ;; Return WAITING heading elements in agenda files: (org-ql-query :select 'element :from (org-agenda-files) :where '(todo "WAITING")) ;; => ((headline (:raw-value "Visit the moon" ...) ...) ...) ;; Since `element' is the default for SELECT, it may be omitted: (org-ql-query :from (org-agenda-files) :where '(todo "WAITING")) ;; => ((headline (:raw-value "Visit the moon" ...) ...) ...)Macro:
org-ql
(deprecated)
Arguments: (buffers-or-files query &key sort narrow markers action)
Expands into a call to org-ql-select
with the same arguments. For convenience, arguments should be unquoted.
Note: This macro is deprecated and will be removed in v0.7.
Arguments: (name args docstring &key body preambles normalizers)
Define an org-ql
selector predicate named org-ql--predicate-NAME
. NAME
may be a symbol or a list of symbols: if a list, the first is used as NAME
and the rest are aliases. A
function is only created for NAME
, not for aliases, so a normalizer should be used to replace aliases with NAME
in queries (keep reading).
ARGS
is a cl-defun
-style argument list. DOCSTRING
is the function’s docstring.
BODY
is the body of the predicate. It will be evaluated with point on the beginning of an Org heading and should return non-nil if the heading’s entry is a match.
PREAMBLES
and NORMALIZERS
are lists of pcase
forms matched against Org QL
query sexps. They are spliced into pcase
forms in the definitions of the functions org-ql--query-preamble
and org-ql--normalize-query
, which see. Those functions are redefined when this macro is expanded, unless variable org-ql-defpred-defer
is non-nil, in which case those functions should be redefined manually after defining predicates by calling org-ql--define-query-preamble-fn
and org-ql--define-normalize-query-fn
.
NORMALIZERS
are used to normalize query expressions to standard forms. For example, when the predicate has aliases, the aliases should be replaced with predicate names using a normalizer. Also, predicate arguments may be put into a more optimal form so that the predicate has less work to do at query time. NOTE: Normalizers are applied to a query repeatedly until the query is fully normalized, so normalizers should be carefully written to avoid infinite loops.
PREAMBLES
refer to regular expressions which may be used to search through a buffer directly to a potential match rather than testing the predicate body on each heading. (Naming things is hard.) In each pcase
form in PREAMBLES
, the pcase
expression (not the pattern) should be a plist with the following keys, each value of which should be an expression which may refer to variables bound in the pattern:
:regexp
Regular expression which searches directly to a potential match.
:case-fold
Bound to case-fold-search
around the regexp search.
:query
Expression which should replace the query expression, or query
if it should not be changed (e.g. if the regexp is insufficient to determine whether a heading matches, in which case the predicate’s body needs to be tested on the heading). If the regexp guarantees a match, this may be simply t
, leaving the query expression with no work to do, which improves performance.
For convenience, within the pcase
patterns, the symbol predicate-names
is a special form which is replaced with a pattern matching any of the predicate’s name and aliases. For example, if NAME
were:
(heading h)
Then if NORMALIZERS
were:
((`(,predicate-names . ,args) `(heading ,@args)))
It would be expanded to:
((`(,(or 'heading 'h) . ,args) `(heading ,@args)))
Org QL provides a dynamic block that lists entries in the current document matching a query. In the header, these parameters are supported:
:query
: An Org QL query expression in either sexp or non-sexp form.:columns
A list of columns, including heading
, todo
, property
, priority
, deadline
, scheduled
, closed
.
(priority "P")
.property
, arguments may be passed by specifying the column type itself as a list. For example, to display a column showing the values of a property
named milestone
, with the header being abbreviated to M
: ((property "milestone") "M")
.:sort
One or a list of Org QL sorting methods (see org-ql-select
).:take
Optionally take a number of results from the front (a positive number) or the end (a negative number) of the results.:ts-format
Optional format string used to format timestamp-based columns.The heading column is formatted as a link to the heading (not shown in the following example).
For example, this dynamic block shows the first seven headings that are to-do items with priority A or B, sorted by deadline then priority, with certain columns (including the value of the agenda-group
property with a custom header) and timestamp format:
#+BEGIN: org-ql :query "todo: priority:A,B" :columns (todo (priority "P") ((property "agenda-group") "Group") deadline heading) :sort (deadline priority) :take 7 :ts-format "%Y-%m-%d %H:%M" | Todo | P | Group | Deadline | Heading | |------+---+-------+------------------+---------------------------------------| | TODO | A | | 2017-07-07 00:00 | Take over the world | | TODO | B | | 2017-07-10 00:00 | Renew membership in supervillain club | | TODO | A | plans | 2017-07-15 00:00 | Take over the universe | | TODO | B | | 2017-07-21 00:00 | Internet | | TODO | A | bills | 2017-08-01 00:00 | Spaceship lease | | TODO | A | | | Skype with president of Antarctica | | TODO | B | | | Take over Mars | #+END:
Org QL View searches may be accessed by opening org-ql-search:
links in an Org file.
In an Org QL View buffer, the command org-store-link
(i.e. C-c l
) stores a link to the current search, and it may be inserted into an Org buffer with the command org-insert-link
(C-c C-l
). The stored link records all of the view settings, like title, sorting, and grouping.
Simple links may also be written manually in either sexp or non-sexp form, like:
[[org-ql-search:todo:NEXT priority:A]] [[org-ql-search:(and (todo "NEXT") (priority "A"))]]
C-x r m
. This also integrates with org-sidebar and Burly.Note: Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases.
Additions
org-ql-view-query
, applied to view queries in header line.org-ql-view-title
, applied to view titles in header line.org-ql-view-relative-deadline-prefix
.Changes
org-ql-find
respects narrowing of the current buffer by default, allowing searching within the narrowed region. (Using one C-u
argument widens the current buffer, and using two C-u
arguments prompts for the buffers to search.)org-ql-completing-read
accepts a new NARROWP
argument, which is passed to org-ql-select
.Fixes
org-ql-view-due-date
.org-ql-view
buffers.Tagged v0.6.2, fixing a compilation warning.
Fixes
org-ql-refile
uses the base buffer when refiling to an indirect buffer. (#466.)link
could signal an error when searching text that is mistakenly recognized as an Org link (e.g. Bash double-bracket constructs in a source block). (Thanks to John Wiegley for reporting.)Fixes
property
when called with argument form (property "PROPERTY-NAME" :inherit t)
. (#460. Thanks to Stewmath for reporting.)level
’s preamble optimizer allows expressions in place of the numeric argument. (See #460. Thanks to Stewmath for reporting.)Compatibility
Fixes
org-ql-view
buffer. (Such text properties could cause them to, e.g. display with extra leading spaces, depending on which other modes might be enabled in the source Org buffer.)completion-styles-alist
in org-ql-completing-read
. (This fixes compatibility with Helm’s helm
completion style, as well as default Emacs completion in recursive minibuffers. #337. Thanks to Nicholas Vollmer, viz, and Karthik Chikmagalur for reporting and suggesting fixes.)org-ql-completing-read
. (#419. Thanks to tpeacock19 for reporting.)Fixes
<2024-06-26 10:00-11:00>
) are matched for simple queries. (This support is not yet comprehensive, e.g. a query that depends on the specific inner time range may not behave as expected. Previously such timestamps were not matched at all. See #237 and #371. Thanks to Ihor Radchenko.)org-ql-search
did not narrow properly when called interactively.Compatibility
Fixes
org-ql-view
buffers when the buffers-files
argument is a symbol (like org-agenda-files
).Fixes
heading
incorrectly matched strings as regular expressions, sometimes returning incorrect results. (See discussion. Thanks to Alex Popescu for reporting.)ancestor
and parent
did not normalize their sub-queries, sometimes returning incorrect results. (#365. Thanks to Gabriele Mongiano for reporting.)Fixes
org-ql-find
goes to the selected entry in the base buffer (rather than potentially an indirect buffer, whose narrowing could leave the selected entry hidden. The nuances around going to entries in buffers that may be indirect and/or narrowed are surprisingly complicated. Hopefully this is the last fix).Fixes
org-ql-find
incorrectly moved point. (See #380. Thanks to Omar Antolín Camarena for reporting.)Fixes
org-ql-find
incorrectly restored the buffer after jumping when not using indirect buffers. (See #380. Thanks to Bram Schoenmakers for reporting.)Fixes
org-ql-find
widens the buffer before going to the selected entry.org-ql-view
buffers, links in headings remain clickable links. (Fixes #282. Thanks to Jacob Boxerman for reporting.)Additions
org-ql-completing-read
, used by command org-ql-find
, now specifies the completion category as org-heading
, providing compatibility with Embark. (This is a powerful feature, as it means any org-ql-find
result can be acted on from inside the search results with Embark, which provides common actions from Org Agenda and Org speed keys bindings.) (#299. Thanks to Omar Antolín Camarena, Daniel Mendler, and Akira Komamura.)
org-ql-completing-read-export
, bound to C-c C-e
or embark-export
while in an org-ql-completing-read
session, exits and shows an org-ql-view
buffer for the current search.org-ql-find
may be called in an org-agenda
or org-ql-view
buffer to search the buffers which contributed to the agenda/view buffer.org-ql-find-path
, which searches outline paths in the current buffer.org-ql-open-link
, which finds links in entries matching the given query, and opens the selected one with org-open-at-point
. (This is helpful when a collection of links are kept in Org files: rather than having to first visit the entry containing the desired link, then locate it within the entry, and then open it, the user can simply select the link and open it directly.)org-ql-view
buffers now include the org-category
text property, like Org Agenda buffers, which allows grouping with org-super-agenda
’s category-related selectors. (#363. Thanks to Gabriele Mongiano for reporting.)Fixes
property
correctly uses the value of org-use-property-inheritance
when not specified. (#346, #356. Thanks to Bram Schoenmakers.)Compatibility
org-element
API changes required some adjustments. (#364. Thanks to several users for reporting, and to Ihor Radchenko for his feedback.)Fixes
Fixes
case-fold-search
when collecting headings in outline paths. (Headings that started with a word that is also a to-do keyword but with different capitalization would be matched incorrectly.)org-ql-view
views. (#378. Thanks to Pentaquark1 for reporting.)org-ql-find
didn’t move point to the selected entry. (#380. Thanks to Omar Antolín Camarena for reporting.)Fixes
org-ql-find
).org-ql-find
).org-ql-find
with :query-prefix
argument prevented selection of results. (#351. Thanks to Daniel Fleischer for reporting.)org-ql-find
.org-ql-completing-read
(the Org format allows a heading line to have no text, but it’s useless for this purpose, and usually indicates unnoticed corruption).Fixes
org-ql-completing-read
is more compatible with default Emacs completion. (See #338. Thanks to arozbiz for reporting.)org-ql-completing-read
would sometimes stop updating with changes in input. (See #350. Thanks to Ankit Raj Pandey for reporting and fixing, and to Daniel Mendler for advising.)org-ql-completing-read
, format links for display, and use org-entry-get
internally rather than org-get-heading
.Added
org-ql-find
, which jumps to entries selected using Emacs’s built-in completion facilities and Org QL queries (like helm-org-ql
, but doesn’t require Helm.).org-ql-refile
, which refiles the entry at point to one selected using Org QL completion.rifle
, which matches an entry if each of the given arguments is found in either the entry’s contents or its outline path. This provides very intuitive results, mimicing the behavior of =org-rifle=. In fact, the results are so useful that it’s now the default predicate for plain-string query tokens. (It is also aliased to smart
, since it’s so “smart,” and not all users have used org-rifle
.)org-ql-default-predicate
, applied to plain-string query tokens (before, the regexp
predicate was always used, but now it may be customized).c
for predicate category
.property
now accepts the argument :inherit
to match entries with property inheritance, and when unspecified, the option org-use-property-inheritance
controls whether inheritance is used.blocked
. (Thanks to Akira Komamura.)Changed
src
now matches case-insensitively.org-ql-sparse-tree
accepts both string and sexp queries. (Thanks to Akira Komamura.)Fixed
link
matches links whose descriptions contain escaped brackets (changed in Org 9.3). (Thanks to Daniel Borchmann for reporting.)src
’s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to Akira Komamura for reporting.)src
’s behavior with various arguments.Internal
and
sub-expression, are optimized to a single call.buffer-chars-modified-tick
instead of buffer-modified-tick
. (Thanks to Ihor Radchenko.)src
predicate.Credits
Fixed
peg
package. (Fixes #314, #316. Thanks to Akira Komamura and Joon Ro for reporting.)org-duration
(apparently necessary in newer Org versions).Fixed
link
predicate when used in an or
‘ed query. (#279. Thanks to Marc Fargas for reporting.)Fixed
Updated
Added
org-ql-defpred
, used to define search predicates. (See tutorial.)effort
.heading-regexp
, which matches regular expressions against heading text (alias: h*
).:with-time
argument, which allows matching timestamps with or without times (i.e. HH:MM).reverse
closed
(Thanks to Ryan Ye.)closed
. (Thanks to Ryan Ye.)Changed
:sort '(todo priority date)
now does what :sort '(date priority todo)
did in earlier versions. (This change is made to enable the new reverse
sorting method.) Users who have customized org-ql-views
will need to update the stored views’ sorting methods to preserve the desired sort order.helm-org-ql
) has been moved to a separate package, helm-org-ql
.heading
now matches plain strings instead of regular expressions.dash
dependency, and remove dependency on obsolete dash-functional
. (Fixes #179, #209. Thanks to Mark Hudnall, Akira Komamura, Nathanael kinfe, Pablo Stafforini, Jason May, and Basil L. Contovounesios.)Removed
org-ql
(obsolete since 0.5, replaced by functions org-ql-select
and org-ql-query
).Fixed
Internal
org-ql-defpred
) that consolidates functionality related to each predicate. This will also allow users to more easily define custom predicates.peg
is now required.Fixed
link
’s :target
and :regexp-p
arguments. (#220. Thanks to Akira Komamura.)Fixed
org-ql-search
buffer. (#186, #187. Thanks to Nathanael kinfe.)Added
transient.el
(like Magit), bound to v
in search/view buffers.link
, which matches descriptions and targets in Org links.tags-regexp
(alias: tags*
), which matches regexps against entry tags (e.g, helpful when a tag might end in “s”).C-x r m
and shown with, e.g. C-x r b
. (This also enables view restoration with Burly.)Changed
r
.Internal
Deprecated
org-ql
is marked obsolete. It will be removed in v0.7. Functions org-ql-select
and org-ql-query
should be used instead. (The macro serves only to confuse with regard to quoting arguments.)Acknowledgments
Fixed
org-ql-block
. (Fixes #84. Thanks to Ihor Radchenko.)Fixed
Fixed
org-ql-search-directories-files
is called without a directories argument and org-directory
doesn’t exist. (Fixes #139. Thanks to Matt Huszagh for reporting.)Fixed
peg
library, which removed a macro used by this package. (Fixes #75. Thanks to Karl Voit and @karlicoss for reporting.)Fixed
(todo)
unnecessarily disabled case-folding for other predicates. (Issue #114. Thanks to @bitclick for reporting.)Fixed
Fixed
org-ql-view-refresh
is called, ensure the buffer is an Org QL View buffer.Fixed
Fixed
level
predicate used with arguments in plain queries. (Thanks to Akira Komamura for reporting.)Note: The next release, 0.5, may include changes which will require minor updates to written queries (e.g. a few predicates may be renamed). Users who wish to avoid those changes happening unexpectedly in their configs should avoid upgrading org-ql
beyond 0.4 automatically, as they will be pushed to the master
branch when ready.
Added
helm-org-ql-views
, which shows one of org-ql-views
selected with Helm.org-ql-search
can search files in org-directory
; customization options are available in the org-ql-search
group.org-ql-view-refresh
can be called with a prefix argument to adjust search parameters.!
. For example, tags:space !moon
to exclude entries which contain moon
.outline-path
(alias olp
) and outline-path-segment
(alias olps
).src
, which matches Org Babel source blocks.parent
and ancestors
. (Thanks to Josh Moller-Mara.)h
for heading
predicate.r
for regexp
predicate. (Thanks to Feng Shu.)helm-org-ql-source
, which returns a Helm source that searches given buffers/files with helm-org-ql
. It can be used for custom Helm commands that search certain files.org-ql-block
. (Thanks to Ihor Radchenko for reporting.)org-ql-view-sidebar-sort-views
.help-echo
text for org-ql-views
default view names.org-ql-views
. (Users who have modified org-ql-views
from the default will not see the new view unless they copy it into their config.)Changed
org-ql-view
views (users who have modified org-ql-views
from the default will not see the new views unless they copy them into their config):
descendants
instead of children
, which is more useful.Fixed
org-tag-inheritance
is enabled. (Fixes #55. Thanks to Mikhail Skorzhinskiy.)helm-make-source
directly instead of using helm-build-sync-source
macro. (Fixes #60. Thanks to Matt Huszagh for reporting.)end-of-buffer
.org-ql-view
buffers. (Thanks to Yiming Chen.)org-ql-block
agenda block. (Fixes #53. Thanks to reports from Gus Cantieni, Karl Voit, rieje, and Jake | Junxuan.)Internal
Fixed
org-ql-search
, accept symbol as :super-groups
argument.This week
and Next week
default org-ql-views
views, set timestamps for beginning-of-week to 00:00:00 and end-of-week to 23:59:59.Fixed
Added
org-ql-search
and helm-org-ql
. See documentation.helm-org-ql
.org-ql-sparse-tree
, like org-sparse-tree
for org-ql
queries. (Thanks to Akira Komamura.)org-ql-view-sidebar
.tags-inherited
, inherited-tags
, tags-i
, itags
.tags-local
, local-tags
, tags-l
, ltags
.tags-all
, tags&
: Matches all given tags using boolean AND
(rather than boolean OR
, which the tags
predicate uses).org-ql-block-header
, which overrides the default header in org-ql-block
agenda blocks.(path)
.org-ql-views
may now be customized in a guided, structured way with the customization UI (e.g. M-x customize-option RET org-ql-views RET
, or press c
in the org-ql-view-sidebar
buffer).org-ql-view
buffers (e.g. setting deadlines and scheduling). (Fixes #35. Thanks to Milan Zamazal and Mikhail Skorzhinskii.)org-ql-select
’s buffers-files
argument can be a function which returns a list of buffers and/or files.Changed
heading
now accepts multiple regexps, which are matched with boolean AND
.regexp
now matches its regexp arguments with boolean AND
.org-super-agenda
is now a dependency. This removes the need for awkward code to handle the case where it’s not installed, and makes grouping features always available. Of course, the global minor mode org-super-agenda-mode
is not activated by org-ql
, so no behavior is changed in Org Agenda or org-ql
; it only means that commands like org-ql-search
will always provide grouping when called with the appropriate arguments.Removed
org-ql-agenda
. Instead, use function org-ql-search
. See also command org-ql-view
, etc.Fixed
heading
now matches only against heading text, i.e. not including tags at the end of the line, to-do keyword, etc.todo
now matches case-sensitively, avoiding non-todo-keyword matches (e.g. a heading which begins Waiting on
will no longer match for a todo keyword WAITING
).org-ql-search
.Internal
org-ql-agenda.el
into files org-ql-search.el
and org-ql-view.el
. Function and variable names have been changed accordingly.Fixed
TO-READ
.Fixed
(deadline auto)
selector matched entries whose deadlines had a warning period that had not yet been entered (org-deadline-warning-days
too soon).Fixed
(descendants)
selector matched against parent heading instead of only descendants.Added
org-ql-query
, like org-ql-select
but with arguments named more like a SQL query."string"
can be used in queries, which are converted to (regexp "string")
automatically.(regexp)
accepts multiple regexps to test.org-ql
and functions org-ql-query
and org-ql-select
now also accept a comparator function in their :sort
argument.org-ql-block
, which works as an Org Agenda series/composite/block command, usable in custom agenda commands defined in variable org-agenda-custom-commands
. (Inspired by Benson Chu’s config.)org-ql-agenda--agenda
optionally takes a list of entries as an argument.ts-a
and ts-i
, aliases for ts-active
and ts-inactive
.ts
now accepts a :type
argument.org-ql-agenda-due-date
.(children)
and (descendants)
.org-ql-search
and macro org-ql-agenda
accept a :title
argument, which is displayed in the header.org-ql-search
offers global org-super-agenda-groups
in completion.org-ql
.org-ql-view
, which displays views saved to variable org-ql-views
, which can be saved from org-ql-search
buffers with command org-ql-search-save
, which is bound to C-x C-s
in view buffers.org-ql-view-map
, active in view buffers displayed by org-ql-search
, org-ql-agenda
, and org-ql-view
.random
sort method.Changed
org-ql-query
renamed to org-ql-select
. org-ql-query
now refers to a new function.org-ql
no longer accepts a :markers
argument. Instead, use argument :action element-with-markers
. See function org-ql-select
, which org-ql
calls.(todo)
no longer matches “done” keywords when used without arguments (i.e. the ones in variable org-done-keywords
).Removed
(date)
, replaced by (ts)
.Fixed
org-agenda-mode-map
.org-ql-select
, etc. (Fixes #37. Thanks to Milan Zamazal.)Compatibility
Internal
regexp
and todo
. These can provide a significant improvement for some queries. See benchmarks in notes.org.First tagged release.
Bug reports, feature requests, and suggestions are welcome. For patches, see below.
While Org QL is currently distributed in MELPA, it’s intended to merge Org QL into Org mode. When that happens, it will become a part of Emacs and Org, and therefore cumulative contributions of more than 15 lines of code will require that the author assign copyright of such contributions to the FSF. Authors who are interested in doing so may contact assign@gnu.org to request the appropriate form.
Comparison with Org Agenda searchesOf course, queries like these can already be written with Org Agenda searches, but the syntax can be complex. For example, this query would be difficult to write in a standard Org Agenda search, because it matches against a to-do keyword and a plain-text search. As described in the advanced searching tutorial, it would require using org-search-view
with a query with specific regular expression syntax, like this:
+lisp +{^\*+\s-+TO-READ\s-}
But with org-ql-search
, you would write a query like lisp todo:TO-READ
, or in Lisp syntax, (and "lisp" (todo "TO-READ"))
.
This package is used by org-sidebar, which presents a customizable agenda-like view in a sidebar window.
GPLv3
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4