Merge remote-tracking branch 'gh/master' into fixmerge

This commit is contained in:
Salih Muhammed 2024-01-25 21:42:20 +02:00
commit 500cb3ea77
13 changed files with 967 additions and 547 deletions

78
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -0,0 +1,78 @@
name: Bug Report
description: File a bug report
# labels: ["bug"]
# assignees:
# - alphapapa
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: os-platform
attributes:
label: OS/platform
description: What operating system or platform are you running Emacs on?
validations:
required: true
- type: textarea
id: emacs-provenance
attributes:
label: Emacs version and provenance
description: What version of Emacs are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: input
id: emacs-command
attributes:
label: Emacs command
description: By what method did you run Emacs? (i.e. what command did you run?)
validations:
required: true
- type: textarea
id: org-provenance
attributes:
label: Org version and provenance
description: What version of Org are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: input
id: package-provenance
attributes:
label: org-ql package version and provenance
description: What version of org-ql are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: textarea
id: actions
attributes:
label: Actions taken
description: What actions did you take, step-by-step, in order, before the problem was noticed?
validations:
required: true
- type: textarea
id: results
attributes:
label: Observed results
description: What behavior did you observe that seemed wrong?
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected results
description: What behavior did you expect to observe?
validations:
required: true
- type: textarea
id: backtrace
attributes:
label: Backtrace
description: If an error was signaled, please use `M-x toggle-debug-on-error RET` and cause the error to happen again, then paste the contents of the `*Backtrace*` buffer here.
render: elisp
- type: textarea
id: etc
attributes:
label: Etc.
description: Any other information that seems relevant

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Support questions
url: https://github.com/alphapapa/org-ql/discussions
about: Please ask and answer support questions here.

View file

@ -0,0 +1,45 @@
name: Feature Request
description: File a feature request
labels: ["enhancement"]
body:
- type: input
id: os-platform
attributes:
label: OS/platform
description: What operating system or platform are you running Emacs on?
validations:
required: true
- type: textarea
id: emacs-provenance
attributes:
label: Emacs version and provenance
description: What version of Emacs are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: textarea
id: org-provenance
attributes:
label: Org version and provenance
description: What version of Org are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: input
id: package-provenance
attributes:
label: org-ql package version and provenance
description: What version of org-ql are you using, where did you acquire it, and how did you install it?
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: Describe your request.
validations:
required: true
- type: textarea
id: etc
attributes:
label: Etc.
description: Any other information that seems relevant

View file

@ -41,7 +41,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
emacs_version: emacs_version:
- 26.3
- 27.1 - 27.1
- 27.2 - 27.2
- 28.1 - 28.1

View file

@ -115,7 +115,7 @@ These commands jump to a heading selected using Emacs's built-in completion faci
- ~org-ql-find-in-agenda~ searches in ~(org-agenda-files)~. - ~org-ql-find-in-agenda~ searches in ~(org-agenda-files)~.
- ~org-ql-find-in-org-directory~ searches in ~org-directory~. - ~org-ql-find-in-org-directory~ searches in ~org-directory~.
Note that these commands are compatible with [[https://github.com/oantolin/embark][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. Note that these commands are compatible with [[https://github.com/oantolin/embark][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.
[[images/org-ql-find.png]] [[images/org-ql-find.png]]
@ -248,7 +248,7 @@ Arguments are listed next to predicate names, where applicable.
- Aliases: ~olps~. - Aliases: ~olps~.
+ =path (&rest regexps)= :: Return non-nil if current heading's buffer's filename path matches any of ~REGEXPS~ (regexp strings). Without arguments, return non-nil if buffer is file-backed. + =path (&rest regexps)= :: Return non-nil if current heading's buffer's filename path matches any of ~REGEXPS~ (regexp strings). Without arguments, return non-nil if buffer is file-backed.
+ =priority (&rest args)= :: Return non-nil if current heading has a certain priority. ~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~). + =priority (&rest args)= :: Return non-nil if current heading has a certain priority. ~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)= :: Return non-nil if current entry has ~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 Boolean value of ~org-use-property-inheritance~, which see (i.e. it is only interpreted as nil or non-nil). + =property (property &optional value &key inherit)= :: Return non-nil if current entry has ~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)= :: Return non-nil if current entry matches all of ~REGEXPS~ (regexp strings). Matches against entire entry, from beginning of its heading to the next heading. + =regexp (&rest regexps)= :: Return non-nil if current entry matches all of ~REGEXPS~ (regexp strings). Matches against entire entry, from beginning of its heading to the next heading.
- Aliases: =r=. - Aliases: =r=.
+ =rifle (&rest strings)= :: Return non-nil if each string is found in either the entry or its outline path. Works like =org-rifle=. This is probably the most useful, intuitive, general-purpose predicate. + =rifle (&rest strings)= :: Return non-nil if each string is found in either the entry or its outline path. Works like =org-rifle=. This is probably the most useful, intuitive, general-purpose predicate.
@ -553,19 +553,60 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
/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. /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.
** 0.8-pre ** 0.9-pre
Nothing new yet.
** 0.8.4
*Fixes*
+ Command ~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).
** 0.8.3
*Fixes*
+ Command ~org-ql-find~ incorrectly moved point. (See [[https://github.com/alphapapa/org-ql/issues/380#issuecomment-1881913025][#380]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]] for reporting.)
** 0.8.2
*Fixes*
+ Command ~org-ql-find~ incorrectly restored the buffer after jumping when not using indirect buffers. (See [[https://github.com/alphapapa/org-ql/issues/380#issuecomment-1881913025][#380]]. Thanks to [[https://github.com/bram85][Bram Schoenmakers]] for reporting.)
** 0.8.1
*Fixes*
+ Command ~org-ql-find~ widens the buffer before going to the selected entry.
+ In ~org-ql-view~ buffers, links in headings remain clickable links. (Fixes [[https://github.com/alphapapa/org-ql/issues/282][#282]]. Thanks to [[https://github.com/jakebox][Jacob Boxerman]] for reporting.)
** 0.8
*Additions* *Additions*
+ Function ~org-ql-completing-read~, used by command ~org-ql-find~, now specifies the completion category as ~org-heading~, providing compatibility with [[https://github.com/oantolin/embark][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.) ([[https://github.com/alphapapa/org-ql/issues/299][#299]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]], [[https://github.com/minad][Daniel Mendler]], and [[https://github.com/akirak][Akira Komamura]].) + Function ~org-ql-completing-read~, used by command ~org-ql-find~, now specifies the completion category as ~org-heading~, providing compatibility with [[https://github.com/oantolin/embark][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.) ([[https://github.com/alphapapa/org-ql/issues/299][#299]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]], [[https://github.com/minad][Daniel Mendler]], and [[https://github.com/akirak][Akira Komamura]].)
- Command ~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.
+ Command ~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. + Command ~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.
+ Command ~org-ql-find-path~, which searches outline paths in the current buffer. + Command ~org-ql-find-path~, which searches outline paths in the current buffer.
+ Command ~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.) + Command ~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.)
+ Items in ~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. ([[https://github.com/alphapapa/org-ql/issues/363][#363]]. Thanks to [[https://github.com/kofm][Gabriele Mongiano]] for reporting.)
*Fixes*
+ Predicate ~property~ correctly uses the value of ~org-use-property-inheritance~ when not specified. ([[https://github.com/alphapapa/org-ql/pull/346][#346]], [[https://github.com/alphapapa/org-ql/issues/356][#356]]. Thanks to [[https://github.com/bram85][Bram Schoenmakers]].)
*Compatibility* *Compatibility*
+ Emacs 27.1 or later is now required.
+ Org v9.7's ~org-element~ API changes required some adjustments. ([[https://github.com/alphapapa/org-ql/issues/364][#364]]. Thanks to several users for reporting, and to [[https://github.com/yantar92][Ihor Radchenko]] for his feedback.) + Org v9.7's ~org-element~ API changes required some adjustments. ([[https://github.com/alphapapa/org-ql/issues/364][#364]]. Thanks to several users for reporting, and to [[https://github.com/yantar92][Ihor Radchenko]] for his feedback.)
** 0.7.4
*Fixes*
+ Ignore empty quoted strings in plain-string queries ([[https://github.com/alphapapa/org-ql/issues/383][#383]]).
** 0.7.3 ** 0.7.3
*Fixes* *Fixes*
@ -592,7 +633,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
** 0.7 ** 0.7
*Added* *Added*
+ Commands ~org-ql-find~, ~org-ql-find-heading~, and ~org-ql-find-path~, which jump to entries selected using Emacs's built-in completion facilities and Org QL queries (like ~helm-org-ql~, but doesn't require Helm.). + Command ~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.).
+ Command ~org-ql-refile~, which refiles the entry at point to one selected using Org QL completion. + Command ~org-ql-refile~, which refiles the entry at point to one selected using Org QL completion.
+ Predicate ~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 [[https://github.com/alphapapa/org-rifle][=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=.) + Predicate ~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 [[https://github.com/alphapapa/org-rifle][=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=.)
+ Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized). + Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized).

View file

@ -3,7 +3,7 @@
# * makem.sh --- Script to aid building and testing Emacs Lisp packages # * makem.sh --- Script to aid building and testing Emacs Lisp packages
# URL: https://github.com/alphapapa/makem.sh # URL: https://github.com/alphapapa/makem.sh
# Version: 0.6-pre # Version: 0.7
# * Commentary: # * Commentary:
@ -112,6 +112,12 @@ Source files are automatically discovered from git, or may be
specified with options. Package dependencies are discovered from specified with options. Package dependencies are discovered from
"Package-Requires" headers in source files, from -pkg.el files, and "Package-Requires" headers in source files, from -pkg.el files, and
from a Cask file. from a Cask file.
Checkdoc's spell checker may not recognize some words, causing the
`lint-checkdoc' rule to fail. Custom words can be added in file-local
or directory-local variables using the variable
`ispell-buffer-session-localwords', which should be set to a list of
strings.
EOF EOF
} }
@ -177,6 +183,7 @@ function elisp-checkdoc-file {
(setq makem-checkdoc-errors-p t) (setq makem-checkdoc-errors-p t)
;; Return nil because we *are* generating a buffered list of errors. ;; Return nil because we *are* generating a buffered list of errors.
nil)))) nil))))
(put 'ispell-buffer-session-localwords 'safe-local-variable #'list-of-strings-p)
(mapcar #'checkdoc-file files) (mapcar #'checkdoc-file files)
(when makem-checkdoc-errors-p (when makem-checkdoc-errors-p
(kill-emacs 1)))) (kill-emacs 1))))
@ -379,6 +386,36 @@ function byte-compile-file {
# ** Files # ** Files
function submodules {
# Echo a list of submodules's paths relative to the repo root.
# TODO: Parse with bash regexp instead of cut.
git submodule status | awk '{print $2}'
}
function project-root {
# Echo the root of the project (or superproject, if running from
# within a submodule).
root_dir=$(git rev-parse --show-superproject-working-tree)
[[ $root_dir ]] || root_dir=$(git rev-parse --show-toplevel)
[[ $root_dir ]] || error "Can't find repo root."
echo "$root_dir"
}
function files-project {
# Echo a list of files in project; or with $1, files in it
# matching that pattern with "git ls-files". Excludes submodules.
[[ $1 ]] && pattern="/$1" || pattern="."
local excludes
for submodule in $(submodules)
do
excludes+=(":!:$submodule")
done
git ls-files -- "$pattern" "${excludes[@]}"
}
function dirs-project { function dirs-project {
# Echo list of directories to be used in load path. # Echo list of directories to be used in load path.
files-project-feature | dirnames files-project-feature | dirnames
@ -387,7 +424,7 @@ function dirs-project {
function files-project-elisp { function files-project-elisp {
# Echo list of Elisp files in project. # Echo list of Elisp files in project.
git ls-files 2>/dev/null \ files-project 2>/dev/null \
| egrep "\.el$" \ | egrep "\.el$" \
| filter-files-exclude-default \ | filter-files-exclude-default \
| filter-files-exclude-args | filter-files-exclude-args
@ -396,13 +433,13 @@ function files-project-elisp {
function files-project-feature { function files-project-feature {
# Echo list of Elisp files that are not tests and provide a feature. # Echo list of Elisp files that are not tests and provide a feature.
files-project-elisp \ files-project-elisp \
| egrep -v "$test_files_regexp" \ | grep -E -v "$test_files_regexp" \
| filter-files-feature | filter-files-feature
} }
function files-project-test { function files-project-test {
# Echo list of Elisp test files. # Echo list of Elisp test files.
files-project-elisp | egrep "$test_files_regexp" files-project-elisp | grep -E "$test_files_regexp"
} }
function dirnames { function dirnames {
@ -415,7 +452,7 @@ function dirnames {
function filter-files-exclude-default { function filter-files-exclude-default {
# Filter out paths (STDIN) which should be excluded by default. # Filter out paths (STDIN) which should be excluded by default.
egrep -v "(/\.cask/|-autoloads.el|.dir-locals)" grep -E -v "(/\.cask/|-autoloads\.el|\.dir-locals)"
} }
function filter-files-exclude-args { function filter-files-exclude-args {
@ -441,7 +478,7 @@ function filter-files-feature {
# Read paths on STDIN and echo ones that (provide 'a-feature). # Read paths on STDIN and echo ones that (provide 'a-feature).
while read path while read path
do do
egrep "^\\(provide '" "$path" &>/dev/null \ grep -E "^\\(provide '" "$path" &>/dev/null \
&& echo "$path" && echo "$path"
done done
} }
@ -489,7 +526,7 @@ function ert-tests-p {
function package-main-file { function package-main-file {
# Echo the package's main file. # Echo the package's main file.
file_pkg=$(git ls-files ./*-pkg.el 2>/dev/null) file_pkg=$(files-project "*-pkg.el" 2>/dev/null)
if [[ $file_pkg ]] if [[ $file_pkg ]]
then then
@ -512,23 +549,23 @@ function dependencies {
# Search package headers. Use -a so grep won't think that an Elisp file containing # Search package headers. Use -a so grep won't think that an Elisp file containing
# control characters (rare, but sometimes necessary) is binary and refuse to search it. # control characters (rare, but sometimes necessary) is binary and refuse to search it.
egrep -a -i '^;; Package-Requires: ' $(files-project-feature) $(files-project-test) \ grep -E -a -i '^;; Package-Requires: ' $(files-project-feature) $(files-project-test) \
| egrep -o '\([^([:space:]][^)]*\)' \ | grep -E -o '\([^([:space:]][^)]*\)' \
| egrep -o '^[^[:space:])]+' \ | grep -E -o '^[^[:space:])]+' \
| sed -r 's/\(//g' \ | sed -r 's/\(//g' \
| egrep -v '^emacs$' # Ignore Emacs version requirement. | grep -E -v '^emacs$' # Ignore Emacs version requirement.
# Search Cask file. # Search Cask file.
if [[ -r Cask ]] if [[ -r Cask ]]
then then
egrep '\(depends-on "[^"]+"' Cask \ grep -E '\(depends-on "[^"]+"' Cask \
| sed -r -e 's/\(depends-on "([^"]+)".*/\1/g' | sed -r -e 's/\(depends-on "([^"]+)".*/\1/g'
fi fi
# Search -pkg.el file. # Search -pkg.el file.
if [[ $(git ls-files ./*-pkg.el 2>/dev/null) ]] if [[ $(files-project "*-pkg.el" 2>/dev/null) ]]
then then
sed -nr 's/.*\(([-[:alnum:]]+)[[:blank:]]+"[.[:digit:]]+"\).*/\1/p' $(git ls-files ./*-pkg.el 2>/dev/null) sed -nr 's/.*\(([-[:alnum:]]+)[[:blank:]]+"[.[:digit:]]+"\).*/\1/p' $(files-project- -- -pkg.el 2>/dev/null)
fi fi
} }
@ -581,6 +618,9 @@ function sandbox {
local deps=($(dependencies)) local deps=($(dependencies))
debug "Installing dependencies: ${deps[@]}" debug "Installing dependencies: ${deps[@]}"
# Ensure built-in packages get upgraded to newer versions from ELPA.
args_sandbox_package_install+=(--eval "(setq package-install-upgrade-built-in t)")
for package in "${deps[@]}" for package in "${deps[@]}"
do do
args_sandbox_package_install+=(--eval "(package-install '$package)") args_sandbox_package_install+=(--eval "(package-install '$package)")
@ -1193,6 +1233,9 @@ paths_temp+=("$package_initialize_file")
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM
# Change to project root directory first.
cd "$(project-root)"
# Discover project files. # Discover project files.
files_project_feature=($(files-project-feature)) files_project_feature=($(files-project-feature))
files_project_test=($(files-project-test)) files_project_test=($(files-project-test))

View file

@ -1,6 +1,6 @@
;;; org-ql-completing-read.el --- Completing read of Org entries using org-ql -*- lexical-binding: t; -*- ;;; org-ql-completing-read.el --- Completing read of Org entries using org-ql -*- lexical-binding: t; -*-
;; Copyright (C) 2022 Adam Porter ;; Copyright (C) 2022-2023 Adam Porter
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
@ -26,6 +26,18 @@
(require 'org-ql) (require 'org-ql)
(declare-function org-ql-search "org-ql-search")
;;;; Variables
(defvar-keymap org-ql-completing-read-map
:doc "Active during `org-ql-completing-read' sessions."
"C-c C-e" #'org-ql-completing-read-export)
;; `embark-collect' doesn't work for `org-ql-completing-read', so remap
;; it to `embark-export' (which `keymap-set', et al doesn't allow).
(define-key org-ql-completing-read-map [remap embark-collect] 'embark-export)
;;;; Customization ;;;; Customization
(defgroup org-ql-completing-read nil (defgroup org-ql-completing-read nil
@ -82,7 +94,7 @@ To be used in, e.g. annotation functions.")
(defun org-ql-completing-read-action () (defun org-ql-completing-read-action ()
"Default action for `org-ql-completing-read'. "Default action for `org-ql-completing-read'.
Returns (STRING . MARKER) cons for entry at point." Returns (STRING . MARKER) cons for entry at point."
(font-lock-ensure (point-at-bol) (point-at-eol)) (font-lock-ensure (pos-bol) (pos-eol))
(cons (org-link-display-format (org-entry-get nil "ITEM")) (point-marker))) (cons (org-link-display-format (org-entry-get nil "ITEM")) (point-marker)))
(defun org-ql-completing-read-snippet (marker) (defun org-ql-completing-read-snippet (marker)
@ -114,12 +126,17 @@ value, or nil."
;;;;; Completing read ;;;;; Completing read
(defun org-ql-completing-read-export ()
"Show `org-ql-view' buffer for current `org-ql-completing-read'-based search."
(interactive)
(user-error "Not in an `org-ql-completing-read' session"))
;;;###autoload ;;;###autoload
(cl-defun org-ql-completing-read (cl-defun org-ql-completing-read
(buffers-files &key query-prefix query-filter (buffers-files &key query-prefix query-filter
(action #'org-ql-completing-read-action) (action #'org-ql-completing-read-action)
;; FIXME: Unused argument. ;; FIXME: Unused argument.
(annotate #'org-ql-completing-read-snippet) ;; (annotate #'org-ql-completing-read-snippet)
(snippet #'org-ql-completing-read-snippet) (snippet #'org-ql-completing-read-snippet)
(path #'org-ql-completing-read-path) (path #'org-ql-completing-read-path)
(action-filter #'list) (action-filter #'list)
@ -155,7 +172,7 @@ single predicate)."
(cl-labels (;; (debug-message (cl-labels (;; (debug-message
;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args))
(action () (action ()
(font-lock-ensure (point-at-bol) (point-at-eol)) (font-lock-ensure (pos-bol) (pos-eol))
;; This function needs to handle multiple candidates per ;; This function needs to handle multiple candidates per
;; call, so we loop over a list of values by default. ;; call, so we loop over a list of values by default.
(pcase-dolist (`(,string . ,marker) (funcall action-filter (funcall action))) (pcase-dolist (`(,string . ,marker) (funcall action-filter (funcall action)))
@ -173,7 +190,6 @@ single predicate)."
(setf string (format "%s <%s>" string (cl-incf suffix))) (setf string (format "%s <%s>" string (cl-incf suffix)))
(setf string (format "%s <%s>" string (puthash string 2 disambiguations))))) (setf string (format "%s <%s>" string (puthash string 2 disambiguations)))))
(puthash (propertize string 'org-marker marker) marker table))))) (puthash (propertize string 'org-marker marker) marker table)))))
(path (marker) (path (marker)
(org-with-point-at marker (org-with-point-at marker
(let* ((path (thread-first (org-get-outline-path nil t) (let* ((path (thread-first (org-get-outline-path nil t)
@ -183,8 +199,8 @@ single predicate)."
(concat "\\" (string-join (reverse path) "\\")) (concat "\\" (string-join (reverse path) "\\"))
(concat "/" (string-join path "/"))))) (concat "/" (string-join path "/")))))
formatted-path))) formatted-path)))
(todo (todo (marker)
(marker) (if-let (it (org-entry-get marker "TODO")) (if-let (it (org-entry-get marker "TODO"))
(concat (propertize it 'face (org-get-todo-face it)) " ") (concat (propertize it 'face (org-get-todo-face it)) " ")
"")) ""))
(affix (completions) (affix (completions)
@ -201,8 +217,8 @@ single predicate)."
;; e.g. Helm while typing, but it seems to help a little when using the ;; e.g. Helm while typing, but it seems to help a little when using the
;; org-rifle-style snippets. ;; org-rifle-style snippets.
(or (snippet (get-text-property 0 'org-marker candidate)) ""))) (or (snippet (get-text-property 0 'org-marker candidate)) "")))
(snippet (snippet (marker)
(marker) (when-let (when-let
((snippet ((snippet
(org-with-point-at marker (org-with-point-at marker
(or (funcall org-ql-completing-read-snippet-function org-ql-completing-read-input-regexp) (or (funcall org-ql-completing-read-snippet-function org-ql-completing-read-input-regexp)
@ -322,7 +338,23 @@ single predicate)."
(mapc #'org-ql--ensure-buffer buffers-files) (mapc #'org-ql--ensure-buffer buffers-files)
(let* ((completion-styles '(org-ql-completing-read)) (let* ((completion-styles '(org-ql-completing-read))
(completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find"))) (completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find")))
(selected (completing-read prompt #'collection nil t))) (selected
(minibuffer-with-setup-hook
(lambda ()
(use-local-map (make-composed-keymap org-ql-completing-read-map (current-local-map))))
(cl-letf* (((symbol-function 'org-ql-completing-read-export)
(lambda ()
(interactive)
(run-at-time 0 nil
#'org-ql-search
buffers-files
(minibuffer-contents-no-properties))
(if (fboundp 'minibuffer-quit-recursive-edit)
(minibuffer-quit-recursive-edit)
(abort-recursive-edit))))
((symbol-function 'embark-export)
(symbol-function 'org-ql-completing-read-export)))
(completing-read prompt #'collection nil t)))))
;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table))
(or (gethash selected table) (or (gethash selected table)
;; If there are completions in the table, but none of them exactly match the user input ;; If there are completions in the table, but none of them exactly match the user input

View file

@ -1,6 +1,6 @@
;;; org-ql-find.el --- Find headings with completion using org-ql -*- lexical-binding: t; -*- ;;; org-ql-find.el --- Find headings with completion using org-ql -*- lexical-binding: t; -*-
;; Copyright (C) 2022 Adam Porter ;; Copyright (C) 2022-2023 Adam Porter
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
@ -49,7 +49,7 @@
See function `display-buffer'." See function `display-buffer'."
:type 'sexp) :type 'sexp)
;;;; Functions ;;;; Commands
;;;###autoload ;;;###autoload
(cl-defun org-ql-find (buffers-files &key query-prefix query-filter (cl-defun org-ql-find (buffers-files &key query-prefix query-filter
@ -70,28 +70,29 @@ types is filtered before execution (e.g. it could replace spaces
with commas to turn multiple tokens, which would normally be with commas to turn multiple tokens, which would normally be
treated as multiple predicates, into multiple arguments to a treated as multiple predicates, into multiple arguments to a
single predicate)." single predicate)."
(interactive (interactive (list (org-ql-find--buffers)))
(list (if current-prefix-arg
(mapcar #'get-buffer
(completing-read-multiple
"Buffers: "
(cl-loop for buffer in (buffer-list)
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
collect (buffer-name buffer))
nil t))
(cond ((derived-mode-p 'org-agenda-mode) (or org-ql-view-buffers-files
org-agenda-contributing-files))
((derived-mode-p 'org-mode) (current-buffer))
(t (user-error "This is not an Org-related buffer: %S" (current-buffer)))))))
(let ((marker (org-ql-completing-read buffers-files (let ((marker (org-ql-completing-read buffers-files
:query-prefix query-prefix :query-prefix query-prefix
:query-filter query-filter :query-filter query-filter
:prompt prompt))) :prompt prompt)))
(set-buffer (marker-buffer marker)) (set-buffer (or (buffer-base-buffer (marker-buffer marker))
(marker-buffer marker)))
(pop-to-buffer (current-buffer) org-ql-find-display-buffer-action)
(without-restriction
(goto-char marker) (goto-char marker)
(display-buffer (current-buffer) org-ql-find-display-buffer-action) (run-hook-with-args 'org-ql-find-goto-hook))
(select-window (get-buffer-window (current-buffer))) (when (equal (current-buffer) (marker-buffer marker))
(run-hook-with-args 'org-ql-find-goto-hook))) ;; Ensure point is still within visible portion of buffer. (If
;; `org-tree-to-indirect-buffer' is used in `org-ql-find-goto-hook',
;; the buffer will have been changed and it won't matter; otherwise,
;; the buffer could have been narrowed to a region excluding the
;; selected entry.)
(let ((end-of-subtree (org-with-point-at marker
(org-end-of-subtree 'invisible-ok))))
(unless (and (<= (point-min) marker)
(>= (point-max) end-of-subtree))
(widen)
(goto-char marker))))))
;;;###autoload ;;;###autoload
(defun org-ql-refile (marker) (defun org-ql-refile (marker)
@ -135,11 +136,16 @@ which see (but only the files are used)."
(org-ql-find (org-ql-search-directories-files))) (org-ql-find (org-ql-search-directories-files)))
;;;###autoload ;;;###autoload
(defun org-ql-find-path () (defun org-ql-find-path (buffers-files)
"Call `org-ql-find' to search outline paths in the current buffer." "Call `org-ql-find' to search outline paths in BUFFERS-FILES.
(interactive) Interactively, search the buffers and files relevant to the
current buffer (i.e. in `org-agenda-mode', the value of
`org-ql-view-buffers-files' or `org-agenda-contributing-files';
in `org-mode', that buffer). With universal prefix, select
multiple buffers to search with completion and PROMPT."
(interactive (list (org-ql-find--buffers)))
(let ((org-ql-default-predicate 'outline-path)) (let ((org-ql-default-predicate 'outline-path))
(org-ql-find (current-buffer)))) (org-ql-find buffers-files)))
;;;###autoload ;;;###autoload
(cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter (cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter
@ -149,21 +155,14 @@ Links found in entries matching the input query are offered as
candidates, and the selected one is opened with candidates, and the selected one is opened with
`org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER, `org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER,
QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read', QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read',
which see." which see.
(interactive
;; FIXME: Factor this out. Interactively, search the buffers and files relevant to the
(list (if current-prefix-arg current buffer (i.e. in `org-agenda-mode', the value of
(mapcar #'get-buffer `org-ql-view-buffers-files' or `org-agenda-contributing-files';
(completing-read-multiple in `org-mode', that buffer). With universal prefix, select
"Buffers: " multiple buffers to search with completion and PROMPT."
(cl-loop for buffer in (buffer-list) (interactive (list (org-ql-find--buffers)))
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
collect (buffer-name buffer))
nil t))
(progn
(unless (eq major-mode 'org-mode)
(user-error "This is not an Org buffer: %S" (current-buffer)))
(current-buffer)))))
(let* ((marker (org-ql-completing-read buffers-files (let* ((marker (org-ql-completing-read buffers-files
:query-prefix query-prefix :query-prefix query-prefix
:query-filter query-filter :query-filter query-filter
@ -192,6 +191,29 @@ which see."
(org-with-point-at marker (org-with-point-at marker
(org-open-at-point)))) (org-open-at-point))))
;;;; Functions
(defun org-ql-find--buffers ()
"Return list of buffers to search in.
In a mode derived from `org-agenda-mode', return the value of
`org-ql-view-buffers-files' or `org-agenda-contributing-files'.
In a mode derived from `org-mode', return the current buffer.
When `current-prefix-arg', read a list of buffers in `org-mode'
with completion. To be used in `org-ql-find' commands'
interactive forms."
(if current-prefix-arg
(mapcar #'get-buffer
(completing-read-multiple
"Buffers: "
(cl-loop for buffer in (buffer-list)
when (eq 'org-mode (buffer-local-value 'major-mode buffer))
collect (buffer-name buffer))
nil t))
(cond ((derived-mode-p 'org-agenda-mode) (or org-ql-view-buffers-files
org-agenda-contributing-files))
((derived-mode-p 'org-mode) (current-buffer))
(t (user-error "This is not an Org-related buffer: %S" (current-buffer))))))
(provide 'org-ql-find) (provide 'org-ql-find)
;;; org-ql-find.el ends here ;;; org-ql-find.el ends here

View file

@ -1,5 +1,7 @@
;;; org-ql-search.el --- Search commands for org-ql -*- lexical-binding: t; -*- ;;; org-ql-search.el --- Search commands for org-ql -*- lexical-binding: t; -*-
;; Copyright (C) 2019-2023 Adam Porter
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
;; Url: https://github.com/alphapapa/org-ql ;; Url: https://github.com/alphapapa/org-ql
@ -56,6 +58,16 @@
((fboundp 'org-store-link-props) #'org-store-link-props) ((fboundp 'org-store-link-props) #'org-store-link-props)
(t (error "org-ql: Unable to define alias `org-ql-search--org-link-store-props'. Please report this as a bug")))) (t (error "org-ql: Unable to define alias `org-ql-search--org-link-store-props'. Please report this as a bug"))))
(defalias 'org-ql--org-hide-archived-subtrees
(if (version<= "9.6" org-version)
'org-fold-hide-archived-subtrees
'org-hide-archived-subtrees))
(defalias 'org-ql--org-show-context
(if (version<= "9.6" org-version)
'org-fold-show-context
'org-show-context))
;;;; Variables ;;;; Variables
(defvar org-ql-block-header nil (defvar org-ql-block-header nil
@ -124,10 +136,10 @@ Runs `org-occur-hook' after making the sparse tree."
query)))) query))))
(org-ql-select buffer query (org-ql-select buffer query
:action (lambda () :action (lambda ()
(org-show-context 'occur-tree) (org-ql--org-show-context 'occur-tree)
(cl-incf num-results))) (cl-incf num-results)))
(unless org-sparse-tree-open-archived-trees (unless org-sparse-tree-open-archived-trees
(org-hide-archived-subtrees (point-min) (point-max))) (org-ql--org-hide-archived-subtrees (point-min) (point-max)))
(run-hooks 'org-occur-hook) (run-hooks 'org-occur-hook)
(unless (get-buffer-window buffer) (unless (get-buffer-window buffer)
(pop-to-buffer buffer)) (pop-to-buffer buffer))
@ -208,8 +220,7 @@ necessary."
(symbol (symbol-value super-groups)) (symbol (symbol-value super-groups))
(list super-groups)))) (list super-groups))))
(setf strings (org-super-agenda--group-items strings)))) (setf strings (org-super-agenda--group-items strings))))
(org-ql-view--display :buffer buffer :header header (org-ql-view--display :buffer buffer :header header :strings strings))))
:string (s-join "\n" strings)))))
;;;###autoload ;;;###autoload
(defun org-ql-search-block (query) (defun org-ql-search-block (query)
@ -341,8 +352,8 @@ this (must be a single line in the Org buffer):
(setf elements (cl-etypecase take (setf elements (cl-etypecase take
((and integer (satisfies cl-minusp)) (-take-last (abs take) elements)) ((and integer (satisfies cl-minusp)) (-take-last (abs take) elements))
(integer (-take take elements))))) (integer (-take take elements)))))
(cl-labels ((format-element (cl-labels ((format-element (element)
(element) (string-join (cl-loop for column in columns (string-join (cl-loop for column in columns
collect (or (pcase-exhaustive column collect (or (pcase-exhaustive column
((pred symbolp) ((pred symbolp)
(funcall (alist-get column format-fns) element)) (funcall (alist-get column format-fns) element))

View file

@ -1,5 +1,7 @@
;;; org-ql-view.el --- Agenda-like view based on org-ql -*- lexical-binding: t; -*- ;;; org-ql-view.el --- Agenda-like view based on org-ql -*- lexical-binding: t; -*-
;; Copyright (C) 2019-2023 Adam Porter
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
;; Url: https://github.com/alphapapa/org-ql ;; Url: https://github.com/alphapapa/org-ql
@ -302,10 +304,10 @@ SLOT is passed to `display-buffer-in-side-window', which see."
(defun org-ql-view-switch () (defun org-ql-view-switch ()
"Switch to view at point." "Switch to view at point."
(interactive) (interactive)
(let ((key (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (let ((key (buffer-substring-no-properties (pos-bol) (pos-eol))))
(unless (string-empty-p key) (unless (string-empty-p key)
(ov-clear :org-ql-view-selected) (ov-clear :org-ql-view-selected)
(ov (point-at-bol) (1+ (point-at-eol)) :org-ql-view-selected t (ov (pos-bol) (1+ (pos-eol)) :org-ql-view-selected t
'face '(:weight bold :inherit highlight)) 'face '(:weight bold :inherit highlight))
(org-ql-view key)))) (org-ql-view key))))
@ -369,7 +371,7 @@ update search arguments."
(defun org-ql-view-customize () (defun org-ql-view-customize ()
"Customize view at point in `org-ql-view-sidebar' buffer." "Customize view at point in `org-ql-view-sidebar' buffer."
(interactive) (interactive)
(let ((key (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (let ((key (buffer-substring-no-properties (pos-bol) (pos-eol))))
(customize-option 'org-ql-views) (customize-option 'org-ql-views)
(search-forward (concat "Name: " key)))) (search-forward (concat "Name: " key))))
@ -406,7 +408,7 @@ update search arguments."
(defvar bookmark-make-record-function) (defvar bookmark-make-record-function)
(cl-defun org-ql-view--display (&key (buffer org-ql-view-buffer) header string) (cl-defun org-ql-view--display (&key (buffer org-ql-view-buffer) header strings)
"Display STRING in `org-ql-view' BUFFER. "Display STRING in `org-ql-view' BUFFER.
BUFFER may be a buffer, or a string naming a buffer, which is BUFFER may be a buffer, or a string naming a buffer, which is
@ -444,7 +446,9 @@ subsequent refreshing of the buffer: `org-ql-view-buffers-files',
;; Clear buffer, insert entries, etc. ;; Clear buffer, insert entries, etc.
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
(insert string "\n") (dolist (string strings)
(insert string "\n"))
(insert "\n")
(pop-to-buffer (current-buffer) org-ql-view-display-buffer-action) (pop-to-buffer (current-buffer) org-ql-view-display-buffer-action)
(org-agenda-finalize) (org-agenda-finalize)
(goto-char (point-min)))))) (goto-char (point-min))))))
@ -533,8 +537,8 @@ dates in the past, and negative for dates in the future."
(defun org-ql-view-bookmark-make-record () (defun org-ql-view-bookmark-make-record ()
"Return a bookmark record for the current Org QL View buffer." "Return a bookmark record for the current Org QL View buffer."
(cl-labels ((file-nameize (cl-labels ((file-nameize (b-f)
(b-f) (abbreviate-file-name (abbreviate-file-name
(cl-typecase b-f (cl-typecase b-f
(string b-f) (string b-f)
(buffer (or (buffer-file-name b-f) (buffer (or (buffer-file-name b-f)
@ -661,15 +665,17 @@ When opened, the link searches the buffer it's opened from."
nil t nil nil "file link is in") nil t nil nil "file link is in")
("file link is in" nil) ("file link is in" nil)
("files currently searched" buffers-files))) ("files currently searched" buffers-files)))
(strings-or-file-buffers-p (strings-or-file-buffers-p (thing)
(thing) (cl-etypecase thing (cl-etypecase thing
(list (cl-every #'strings-or-file-buffers-p thing)) (list (cl-every #'strings-or-file-buffers-p thing))
(string thing) (string thing)
(buffer (or (buffer-file-name thing) (buffer (or (buffer-file-name thing)
;; TODO: Should indirect buffers be allowed? Maybe not, since their narrowing isn't preserved. ;; TODO: Should indirect buffers be allowed? Maybe not, since their
;; On the other hand, it's possible to accidentally make a search view for an indirect buffer ;; narrowing isn't preserved. On the other hand, it's possible to
;; that's since been widened, and forcing the user to manually change that would be awkward, ;; accidentally make a search view for an indirect buffer that's
;; and trying to communicate the problem would be difficult, so maybe it's okay to allow it. ;; since been widened, and forcing the user to manually change that
;; would be awkward, and trying to communicate the problem would be
;; difficult, so maybe it's okay to allow it.
(when (buffer-base-buffer thing) (when (buffer-base-buffer thing)
(buffer-file-name (buffer-base-buffer thing)))))))) (buffer-file-name (buffer-base-buffer thing))))))))
(unless (strings-or-file-buffers-p org-ql-view-buffers-files) (unless (strings-or-file-buffers-p org-ql-view-buffers-files)
@ -865,8 +871,7 @@ return an empty string."
;; Adding the relative due date property should probably be done explicitly and separately ;; Adding the relative due date property should probably be done explicitly and separately
;; (which would also make it easier to do it independently of faces, etc). ;; (which would also make it easier to do it independently of faces, etc).
(title (--> (org-ql-view--add-faces element) (title (--> (org-ql-view--add-faces element)
(org-element-property :raw-value it) (org-element-property :raw-value it)))
(org-link-display-format it)))
(todo-keyword (-some--> (org-element-property :todo-keyword element) (todo-keyword (-some--> (org-element-property :todo-keyword element)
(org-ql-view--add-todo-face it))) (org-ql-view--add-todo-face it)))
(tag-list (if org-use-tag-inheritance (tag-list (if org-use-tag-inheritance
@ -889,17 +894,20 @@ return an empty string."
(s-join ":" it) (s-join ":" it)
(s-wrap it ":") (s-wrap it ":")
(org-add-props it nil 'face 'org-tag)))) (org-add-props it nil 'face 'org-tag))))
;; (category (org-element-property :category element))
;; Org Agenda priorities are subtracted from `org-priority-lowest'
;; and multiplied by 1000, so do the same here. Also assume that <65
;; means the priority is a number and covert to its ASCII equivalent,
;; which is what `org-priority-to-value' implicitly does. See also
;; `org-get-priority' and `org-priority-lowest'.
(priority (cl-flet ((adjust (p) (if (>= p 65) p (+ p 48)))) (priority (cl-flet ((adjust (p) (if (>= p 65) p (+ p 48))))
(-if-let (pri (org-element-property :priority element)) (-if-let (pri (org-element-property :priority element))
(* 1000 (- (adjust org-priority-lowest) pri)) (* 1000 (- (adjust org-priority-lowest) pri))
(* 1000 (- (adjust org-priority-lowest) (* 1000 (- (adjust org-priority-lowest)
(adjust org-priority-default)))))) (adjust org-priority-default))))))
(category (or (org-element-property :CATEGORY element)
(when-let ((marker (or (org-element-property :org-hd-marker element)
(org-element-property :org-marker element))))
(org-with-point-at marker
(or (org-get-category)
(when buffer-file-name
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))))))
""))
(priority-string (-some->> (org-element-property :priority element) (priority-string (-some->> (org-element-property :priority element)
(char-to-string) (char-to-string)
(format "[#%s]") (format "[#%s]")
@ -920,6 +928,7 @@ return an empty string."
(org-add-props it properties (org-add-props it properties
'org-agenda-type 'search 'org-agenda-type 'search
'priority priority 'priority priority
'org-category category
'todo-state todo-keyword 'todo-state todo-keyword
'tags tag-list 'tags tag-list
'org-habit-p habit-property))))) 'org-habit-p habit-property)))))
@ -1050,8 +1059,8 @@ the variable), \"org-directory\" if it matches the value of
current buffer. Otherwise BUFFERS-FILES is returned unchanged." current buffer. Otherwise BUFFERS-FILES is returned unchanged."
;; Used in `org-ql-view--complete-buffers-files' and ;; Used in `org-ql-view--complete-buffers-files' and
;; `org-ql-view--header-line-format'. ;; `org-ql-view--header-line-format'.
(cl-labels ((expand-files (cl-labels ((expand-files (list)
(list) (--map (cl-typecase it (--map (cl-typecase it
(string (expand-file-name it)) (string (expand-file-name it))
(otherwise it)) (otherwise it))
list))) list)))
@ -1076,8 +1085,8 @@ current buffer. Otherwise BUFFERS-FILES is returned unchanged."
(defun org-ql-view--complete-buffers-files () (defun org-ql-view--complete-buffers-files ()
"Return value for `org-ql-view-buffers-files' using completion." "Return value for `org-ql-view-buffers-files' using completion."
(cl-labels ((initial-input (cl-labels ((initial-input ()
() (when org-ql-view-buffers-files (when org-ql-view-buffers-files
(org-ql-view--contract-buffers-files (org-ql-view--contract-buffers-files
org-ql-view-buffers-files)))) org-ql-view-buffers-files))))
(if (and org-ql-view-buffers-files (if (and org-ql-view-buffers-files

View file

@ -1,11 +1,11 @@
;;; org-ql.el --- Org Query Language, search command, and agenda-like view -*- lexical-binding: t; -*- ;;; org-ql.el --- Org Query Language, search command, and agenda-like view -*- lexical-binding: t; -*-
;; Copyright (C) 2017-2022 Adam Porter ;; Copyright (C) 2017-2023 Adam Porter
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
;; Url: https://github.com/alphapapa/org-ql ;; Url: https://github.com/alphapapa/org-ql
;; Version: 0.8-pre ;; Version: 0.9-pre
;; Package-Requires: ((emacs "26.1") (dash "2.18.1") (f "0.17.2") (map "2.1") (org "9.0") (org-super-agenda "1.2") (ov "1.0.6") (peg "1.0.1") (s "1.12.0") (transient "0.1") (ts "0.2-pre")) ;; Package-Requires: ((emacs "27.1") (compat "29.1") (dash "2.18.1") (f "0.17.2") (map "2.1") (org "9.0") (org-super-agenda "1.2") (ov "1.0.6") (peg "1.0.1") (s "1.12.0") (transient "0.1") (ts "0.2-pre"))
;; Keywords: hypermedia, outlines, Org, agenda ;; Keywords: hypermedia, outlines, Org, agenda
;;; License: ;;; License:
@ -43,6 +43,7 @@
(require 'seq) (require 'seq)
(require 'subr-x) (require 'subr-x)
(require 'compat)
(require 'dash) (require 'dash)
(require 'map) (require 'map)
(require 'ts) (require 'ts)
@ -95,6 +96,12 @@ Necessary because of backward-incompatible changes in Org
`org-bracket-link-regexp' was marked as an obsolete alias for it, `org-bracket-link-regexp' was marked as an obsolete alias for it,
but the match groups were changed, so they are not compatible.") but the match groups were changed, so they are not compatible.")
;;;; Compatibility
(defalias 'org-ql--org-timestamp-format
(if (version<= "9.6" org-version)
'org-format-timestamp
'org-timestamp-format))
;;;; Variables ;;;; Variables
(defvar org-ql--today nil) (defvar org-ql--today nil)
@ -285,6 +292,11 @@ Matches with or without time.")
:link '(custom-manual "(org-ql)Usage") :link '(custom-manual "(org-ql)Usage")
:link '(url-link "https://github.com/alphapapa/org-ql")) :link '(url-link "https://github.com/alphapapa/org-ql"))
(defcustom org-ql-signal-peg-failure nil
"Signal an error when parsing a plain-string query fails.
This should only be enabled while debugging."
:type 'boolean)
(defcustom org-ql-ask-unsafe-queries t (defcustom org-ql-ask-unsafe-queries t
"Ask before running a query that could run arbitrary code. "Ask before running a query that could run arbitrary code.
Org QL queries in sexp form can contain arbitrary expressions. Org QL queries in sexp form can contain arbitrary expressions.
@ -802,25 +814,24 @@ respectively."
(and "\\" (0+ "\\\\") (any "[]")) (and "\\" (0+ "\\\\") (any "[]"))
(and (1+ "\\") (not (any "[]"))))))) (and (1+ "\\") (not (any "[]")))))))
(cl-labels (cl-labels
((no-desc ((no-desc (match)
(match) (rx-to-string `(seq (or bol (1+ blank)) (rx-to-string `(seq (or bol (1+ blank))
"[[" ,link-target-part (regexp ,match) ,link-target-part "[[" ,link-target-part (regexp ,match) ,link-target-part
"]]"))) "]]")))
(match-both (match-both (description target)
(description target)
(rx-to-string `(seq (or bol (1+ blank)) (rx-to-string `(seq (or bol (1+ blank))
"[[" ,link-target-part (regexp ,target) ,link-target-part "[[" ,link-target-part (regexp ,target) ,link-target-part
"][" (*? anything) (regexp ,description) (*? anything) "][" (*? anything) (regexp ,description) (*? anything)
"]]"))) "]]")))
;; Note that these actually allow empty descriptions ;; Note that these actually allow empty descriptions
;; or targets, depending on what they are matching. ;; or targets, depending on what they are matching.
(match-desc (match-desc (match)
(match) (rx-to-string `(seq (or bol (1+ blank)) (rx-to-string `(seq (or bol (1+ blank))
"[[" ,link-target-part "[[" ,link-target-part
"][" (*? anything) (regexp ,match) (*? anything) "][" (*? anything) (regexp ,match) (*? anything)
"]]"))) "]]")))
(match-target (match-target (match)
(match) (rx-to-string `(seq (or bol (1+ blank)) (rx-to-string `(seq (or bol (1+ blank))
"[[" ,link-target-part (regexp ,match) ,link-target-part "[[" ,link-target-part (regexp ,match) ,link-target-part
"][" (*? anything) "][" (*? anything)
"]]")))) "]]"))))
@ -950,7 +961,7 @@ value of `org-ql-predicates')."
(term (or (and negation (list positive-term) (term (or (and negation (list positive-term)
;; This is a bit confusing, but it seems to work. There's probably a better way. ;; This is a bit confusing, but it seems to work. There's probably a better way.
`(pred -- (list 'not (car pred)))) `(pred -- (list 'not (car pred))))
positive-term)) positive-term empty-quote))
(positive-term (or (and predicate-with-args `(pred args -- (cons (intern pred) args))) (positive-term (or (and predicate-with-args `(pred args -- (cons (intern pred) args)))
(and predicate-without-args `(pred -- (list (intern pred)))) (and predicate-without-args `(pred -- (list (intern pred))))
(and plain-string `(s -- (list org-ql-default-predicate s))))) (and plain-string `(s -- (list org-ql-default-predicate s)))))
@ -963,6 +974,12 @@ value of `org-ql-predicates')."
(keyword (substring (+ (not (or separator "=" "\"" (syntax-class whitespace))) (any)))) (keyword (substring (+ (not (or separator "=" "\"" (syntax-class whitespace))) (any))))
(quoted-arg "\"" (substring (+ (not (or separator "\"")) (any))) "\"") (quoted-arg "\"" (substring (+ (not (or separator "\"")) (any))) "\"")
(unquoted-arg (substring (+ (not (or separator "\"" (syntax-class whitespace))) (any)))) (unquoted-arg (substring (+ (not (or separator "\"" (syntax-class whitespace))) (any))))
(empty-quote
;; This avoids aborting parsing or signaling an
;; error if the user types in two successive
;; quotation marks while typing a query (e.g. when
;; using electric-pair-mode).
"\"\"")
(negation "!") (negation "!")
(separator "," ))) (separator "," )))
(closure (lambda (input &optional boolean) (closure (lambda (input &optional boolean)
@ -983,7 +1000,10 @@ value of `org-ql-predicates')."
;; have to borrow some code. It ends up that we only have to ;; have to borrow some code. It ends up that we only have to
;; borrow this `with-peg-rules' call, which isn't too bad. ;; borrow this `with-peg-rules' call, which isn't too bad.
(eval `(with-peg-rules ,pexs (eval `(with-peg-rules ,pexs
(peg-run (peg ,(caar pexs)) #'peg-signal-failure)))))) (peg-run (peg ,(caar pexs))
(lambda (failures)
(when org-ql-signal-peg-failure
(peg-signal-failure failures)))))))))
(pcase parsed-sexp (pcase parsed-sexp
(`(,one-predicate) one-predicate) (`(,one-predicate) one-predicate)
(`(,_ . ,_) (cons boolean (reverse parsed-sexp))) (`(,_ . ,_) (cons boolean (reverse parsed-sexp)))
@ -1121,7 +1141,7 @@ defined in `org-ql-predicates' by calling `org-ql-defpred'."
(byte-compile 'org-ql--query-preamble))) (byte-compile 'org-ql--query-preamble)))
(cl-defmacro org-ql-defpred (name args docstring &key body preambles normalizers coalesce) (cl-defmacro org-ql-defpred (name args docstring &key body preambles normalizers coalesce)
"Define an `org-ql' selector predicate named `org-ql--predicate-NAME'. "Define an \\+`org-ql' selector predicate \\=`org-ql--predicate-NAME'.
NAME may be a symbol or a list of symbols: if a list, the first 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 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 created for NAME, not for aliases, so a normalizer should be used
@ -1166,7 +1186,7 @@ to variables bound in the pattern:
:case-fold Bound to `case-fold-search' around the regexp search. :case-fold Bound to `case-fold-search' around the regexp search.
:query Expression which should replace the query expression, :query Expression which should replace the query expression,
or `query' if it should not be changed (e.g. if the or \\+`query' if it should not be changed (e.g. if the
regexp is insufficient to determine whether a regexp is insufficient to determine whether a
heading matches, in which case the predicate's body heading matches, in which case the predicate's body
needs to be tested on the heading). If the regexp needs to be tested on the heading). If the regexp
@ -1193,7 +1213,7 @@ e.g. a predicate takes keyword arguments, so arguments to
multiple calls can't be simply appended.) multiple calls can't be simply appended.)
For convenience, within the `pcase' patterns, the symbol For convenience, within the `pcase' patterns, the symbol
`predicate-names' is a special form which is replaced with a \\+`predicate-names' is a special form which is replaced with a
pattern matching any of the predicate's name and aliases. For pattern matching any of the predicate's name and aliases. For
example, if NAME were: example, if NAME were:
@ -1201,13 +1221,13 @@ example, if NAME were:
Then if NORMALIZERS were: Then if NORMALIZERS were:
((`(,predicate-names . ,args) ((\\=`(,predicate-names . ,args)
`(heading ,@args))) \\=`(heading ,@args)))
It would be expanded to: It would be expanded to:
((`(,(or 'heading 'h) . ,args) ((\\=`(,(or 'heading 'h) . ,args)
`(heading ,@args)))" \\=`(heading ,@args)))"
;; FIXME: Update defpred tutorial to include :coalesce. ;; FIXME: Update defpred tutorial to include :coalesce.
;; NOTE: The debug form works, completely! For example, use `edebug-defun' ;; NOTE: The debug form works, completely! For example, use `edebug-defun'
@ -1810,9 +1830,9 @@ interpreted as nil or non-nil)."
(when (keywordp property) (when (keywordp property)
(setf property (substring (symbol-name property) 1))) (setf property (substring (symbol-name property) 1)))
(list 'property property value (list 'property property value
:inherit (if (plist-member plist :inherit) :inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
(plist-get plist :inherit) ((listp org-use-property-inheritance) ''selective)
org-use-property-inheritance)))) (t org-use-property-inheritance)))))
;; MAYBE: Should case folding be disabled for properties? What about values? ;; MAYBE: Should case folding be disabled for properties? What about values?
;; MAYBE: Support (property) without args. ;; MAYBE: Support (property) without args.
@ -1959,7 +1979,7 @@ language. Matching is done case-insensitively."
(point))) (point)))
(contents-end (progn (contents-end (progn
(goto-char (match-end 0)) (goto-char (match-end 0))
(point-at-bol)))) (pos-bol))))
(cl-loop for re in regexps (cl-loop for re in regexps
do (goto-char contents-beg) do (goto-char contents-beg)
always (re-search-forward re contents-end t)))))))))) always (re-search-forward re contents-end t))))))))))
@ -2464,7 +2484,7 @@ Deadline is considered before scheduled."
A and B are Org timestamp elements." A and B are Org timestamp elements."
(cl-macrolet ((ts (ts) (cl-macrolet ((ts (ts)
`(when ,ts `(when ,ts
(org-timestamp-format ,ts "%s")))) (org-ql--org-timestamp-format ,ts "%s"))))
(let* ((a-ts (ts a)) (let* ((a-ts (ts a))
(b-ts (ts b))) (b-ts (ts b)))
(cond ((and a-ts b-ts) (cond ((and a-ts b-ts)
@ -2514,8 +2534,8 @@ If QUERY can't be converted to a string, return nil."
thereis (or (eq symbol element) thereis (or (eq symbol element)
(and (listp element) (and (listp element)
(contains-p symbol element))))) (contains-p symbol element)))))
(format-args (format-args (args)
(args) (let (non-paired paired next-keyword) (let (non-paired paired next-keyword)
(cl-loop for arg in args (cl-loop for arg in args
do (cond (next-keyword (push (cons next-keyword arg) paired) do (cond (next-keyword (push (cons next-keyword arg) paired)
(setf next-keyword nil)) (setf next-keyword nil))
@ -2525,14 +2545,14 @@ If QUERY can't be converted to a string, return nil."
(nreverse (--map (format "%s=%s" (car it) (cdr it)) (nreverse (--map (format "%s=%s" (car it) (cdr it))
paired))) paired)))
","))) ",")))
(format-atom (format-atom (atom)
(atom) (cl-typecase atom (cl-typecase atom
(string (if (string-match (rx space) atom) (string (if (string-match (rx space) atom)
(format "%S" atom) (format "%S" atom)
(format "%s" atom))) (format "%s" atom)))
(t (format "%s" atom)))) (t (format "%s" atom))))
(format-form (format-form (form)
(form) (pcase form (pcase form
(`(not . (,rest)) (concat "!" (format-form rest))) (`(not . (,rest)) (concat "!" (format-form rest)))
(`(priority . ,_) (format-priority form)) (`(priority . ,_) (format-priority form))
;; FIXME: Convert (src) queries to non-sexp form...someday... ;; FIXME: Convert (src) queries to non-sexp form...someday...
@ -2543,18 +2563,18 @@ If QUERY can't be converted to a string, return nil."
((guard (= 1 (length args))) (format "%s" (car args))) ((guard (= 1 (length args))) (format "%s" (car args)))
(_ (format-args args))))) (_ (format-args args)))))
(format "%s:%s" pred args-string))))) (format "%s:%s" pred args-string)))))
(format-and (format-and (form)
(form) (pcase-let* ((`(and . ,rest) form)) (pcase-let* ((`(and . ,rest) form))
(string-join (mapcar #'format-form rest) " "))) (string-join (mapcar #'format-form rest) " ")))
(format-priority (format-priority (form)
(form) (pcase-let* ((`(priority . ,rest) form) (pcase-let* ((`(priority . ,rest) form)
(args (pcase rest (args (pcase rest
(`(,(and comparator (or '< '<= '> '>= '=)) ,letter) (`(,(and comparator (or '< '<= '> '>= '=)) ,letter)
(priority-letters comparator letter)) (priority-letters comparator letter))
(_ rest)))) (_ rest))))
(concat "priority:" (string-join args ",")))) (concat "priority:" (string-join args ","))))
(priority-letters (priority-letters (comparator letter)
(comparator letter) (let* ((char (string-to-char (upcase (symbol-name letter)))) (let* ((char (string-to-char (upcase (symbol-name letter))))
(numeric-priorities '(?A ?B ?C)) (numeric-priorities '(?A ?B ?C))
;; NOTE: The comparator inversion is intentional. ;; NOTE: The comparator inversion is intentional.
(others (pcase comparator (others (pcase comparator

View file

@ -72,7 +72,13 @@ Functions / Macros
Changelog Changelog
* 0.8-pre: 08-pre. * 0.9-pre: 09-pre.
* 0.8.4: 084.
* 0.8.3: 083.
* 0.8.2: 082.
* 0.8.1: 081.
* 0.8: 08.
* 0.7.4: 074.
* 0.7.3: 073. * 0.7.3: 073.
* 0.7.2: 072. * 0.7.2: 072.
* 0.7.1: 071. * 0.7.1: 071.
@ -236,7 +242,9 @@ completion facilities with an Org QL query:
Note that these commands are compatible with Embark Note that these commands are compatible with Embark
(https://github.com/oantolin/embark): the embark-act command can be (https://github.com/oantolin/embark): the embark-act command can be
called on a completion candidate (i.e. a search result) to act on it 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. 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.
 
File: README.info, Node: org-ql-open-link, Next: org-ql-refile, Prev: org-ql-find, Up: Commands File: README.info, Node: org-ql-open-link, Next: org-ql-refile, Prev: org-ql-find, Up: Commands
@ -520,9 +528,8 @@ Arguments are listed next to predicate names, where applicable.
Return non-nil if current entry has PROPERTY (a string), and Return non-nil if current entry has PROPERTY (a string), and
optionally VALUE (a string). If INHERIT is nil, only match optionally VALUE (a string). If INHERIT is nil, only match
entries with PROPERTY set on the entry; if t, also match entries entries with PROPERTY set on the entry; if t, also match entries
with inheritance. If INHERIT is not specified, use the Boolean with inheritance. If INHERIT is not specified, use the value of
value of org-use-property-inheritance, which see (i.e. it is org-use-property-inheritance, which see.
only interpreted as nil or non-nil).
regexp (&rest regexps) regexp (&rest regexps)
Return non-nil if current entry matches all of REGEXPS (regexp Return non-nil if current entry matches all of REGEXPS (regexp
strings). Matches against entire entry, from beginning of its strings). Matches against entire entry, from beginning of its
@ -1026,7 +1033,13 @@ releases.
* Menu: * Menu:
* 0.8-pre: 08-pre. * 0.9-pre: 09-pre.
* 0.8.4: 084.
* 0.8.3: 083.
* 0.8.2: 082.
* 0.8.1: 081.
* 0.8: 08.
* 0.7.4: 074.
* 0.7.3: 073. * 0.7.3: 073.
* 0.7.2: 072. * 0.7.2: 072.
* 0.7.1: 071. * 0.7.1: 071.
@ -1058,11 +1071,75 @@ releases.
* 0.1: 01. * 0.1: 01.
 
File: README.info, Node: 08-pre, Next: 073, Up: Changelog File: README.info, Node: 09-pre, Next: 084, Up: Changelog
5.1 0.8-pre 5.1 0.9-pre
=========== ===========
Nothing new yet.

File: README.info, Node: 084, Next: 083, Prev: 09-pre, Up: Changelog
5.2 0.8.4
=========
*Fixes*
• Command 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).

File: README.info, Node: 083, Next: 082, Prev: 084, Up: Changelog
5.3 0.8.3
=========
*Fixes*
• Command org-ql-find incorrectly moved point. (See #380
(https://github.com/alphapapa/org-ql/issues/380#issuecomment-1881913025).
Thanks to Omar Antolín Camarena (https://github.com/oantolin) for
reporting.)

File: README.info, Node: 082, Next: 081, Prev: 083, Up: Changelog
5.4 0.8.2
=========
*Fixes*
• Command org-ql-find incorrectly restored the buffer after jumping
when not using indirect buffers. (See #380
(https://github.com/alphapapa/org-ql/issues/380#issuecomment-1881913025).
Thanks to Bram Schoenmakers (https://github.com/bram85) for
reporting.)

File: README.info, Node: 081, Next: 08, Prev: 082, Up: Changelog
5.5 0.8.1
=========
*Fixes*
• Command org-ql-find widens the buffer before going to the
selected entry.
• In org-ql-view buffers, links in headings remain clickable links.
(Fixes #282 (https://github.com/alphapapa/org-ql/issues/282).
Thanks to Jacob Boxerman (https://github.com/jakebox) for
reporting.)

File: README.info, Node: 08, Next: 074, Prev: 081, Up: Changelog
5.6 0.8
=======
*Additions* *Additions*
• Function org-ql-completing-read, used by command org-ql-find, • Function org-ql-completing-read, used by command org-ql-find,
@ -1075,6 +1152,10 @@ File: README.info, Node: 08-pre, Next: 073, Up: Changelog
Thanks to Omar Antolín Camarena (https://github.com/oantolin), Thanks to Omar Antolín Camarena (https://github.com/oantolin),
Daniel Mendler (https://github.com/minad), and Akira Komamura Daniel Mendler (https://github.com/minad), and Akira Komamura
(https://github.com/akirak).) (https://github.com/akirak).)
• Command 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.
• Command org-ql-find may be called in an org-agenda or • Command org-ql-find may be called in an org-agenda or
org-ql-view buffer to search the buffers which contributed to the org-ql-view buffer to search the buffers which contributed to the
agenda/view buffer. agenda/view buffer.
@ -1087,18 +1168,42 @@ File: README.info, Node: 08-pre, Next: 073, Up: Changelog
containing the desired link, then locate it within the entry, and containing the desired link, then locate it within the entry, and
then open it, the user can simply select the link and open it then open it, the user can simply select the link and open it
directly.) directly.)
• Items in org-ql-view buffers now include the org-category text
property, like Org Agenda buffers, which allows grouping with
org-super-agendas category-related selectors. (#363
(https://github.com/alphapapa/org-ql/issues/363). Thanks to
Gabriele Mongiano (https://github.com/kofm) for reporting.)
*Fixes*
• Predicate property correctly uses the value of
org-use-property-inheritance when not specified. (#346
(https://github.com/alphapapa/org-ql/pull/346), #356
(https://github.com/alphapapa/org-ql/issues/356). Thanks to Bram
Schoenmakers (https://github.com/bram85).)
*Compatibility* *Compatibility*
• Emacs 27.1 or later is now required.
• Org v9.7s org-element API changes required some adjustments. • Org v9.7s org-element API changes required some adjustments.
(#364 (https://github.com/alphapapa/org-ql/issues/364). Thanks to (#364 (https://github.com/alphapapa/org-ql/issues/364). Thanks to
several users for reporting, and to Ihor Radchenko several users for reporting, and to Ihor Radchenko
(https://github.com/yantar92) for his feedback.) (https://github.com/yantar92) for his feedback.)
 
File: README.info, Node: 073, Next: 072, Prev: 08-pre, Up: Changelog File: README.info, Node: 074, Next: 073, Prev: 08, Up: Changelog
5.2 0.7.3 5.7 0.7.4
=========
*Fixes*
• Ignore empty quoted strings in plain-string queries (#383
(https://github.com/alphapapa/org-ql/issues/383)).

File: README.info, Node: 073, Next: 072, Prev: 074, Up: Changelog
5.8 0.7.3
========= =========
*Fixes* *Fixes*
@ -1116,7 +1221,7 @@ File: README.info, Node: 073, Next: 072, Prev: 08-pre, Up: Changelog
 
File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog
5.3 0.7.2 5.9 0.7.2
========= =========
*Fixes* *Fixes*
@ -1137,8 +1242,8 @@ File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog
 
File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog
5.4 0.7.1 5.10 0.7.1
========= ==========
*Fixes* *Fixes*
• Function org-ql-completing-read is more compatible with default • Function org-ql-completing-read is more compatible with default
@ -1156,13 +1261,12 @@ File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog
 
File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog
5.5 0.7 5.11 0.7
======= ========
*Added* *Added*
• Commands org-ql-find, org-ql-find-heading, and • Command org-ql-find, which jumps to entries selected using
org-ql-find-path, which jump to entries selected using Emacss Emacss built-in completion facilities and Org QL queries (like
built-in completion facilities and Org QL queries (like
helm-org-ql, but doesnt require Helm.). helm-org-ql, but doesnt require Helm.).
• Command org-ql-refile, which refiles the entry at point to one • Command org-ql-refile, which refiles the entry at point to one
selected using Org QL completion. selected using Org QL completion.
@ -1216,8 +1320,8 @@ File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog
 
File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog
5.6 0.6.3 5.12 0.6.3
========= ==========
*Fixed* *Fixed*
• Non-sexp query parsing with updated version 1.0.1 of the peg • Non-sexp query parsing with updated version 1.0.1 of the peg
@ -1232,8 +1336,8 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog
 
File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog
5.7 0.6.2 5.13 0.6.2
========= ==========
*Fixed* *Fixed*
link predicate when used in an ored query. (#279 link predicate when used in an ored query. (#279
@ -1243,8 +1347,8 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog
 
File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog
5.8 0.6.1 5.14 0.6.1
========= ==========
*Fixed* *Fixed*
• In dynamic blocks, links to headings with statistics cookies were • In dynamic blocks, links to headings with statistics cookies were
@ -1261,8 +1365,8 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog
 
File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog
5.9 0.6 5.15 0.6
======= ========
*Added* *Added*
• Macro org-ql-defpred, used to define search predicates. (See • Macro org-ql-defpred, used to define search predicates. (See
@ -1328,7 +1432,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog
 
File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog
5.10 0.5.2 5.16 0.5.2
========== ==========
*Fixed* *Fixed*
@ -1339,7 +1443,7 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog
 
File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog
5.11 0.5.1 5.17 0.5.1
========== ==========
*Fixed* *Fixed*
@ -1352,7 +1456,7 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog
 
File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog
5.12 0.5 5.18 0.5
======== ========
*Added* *Added*
@ -1393,7 +1497,7 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog
 
File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog
5.13 0.4.9 5.19 0.4.9
========== ==========
*Fixed* *Fixed*
@ -1404,7 +1508,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog
 
File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog
5.14 0.4.8 5.20 0.4.8
========== ==========
*Fixed* *Fixed*
@ -1416,7 +1520,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog
 
File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog
5.15 0.4.7 5.21 0.4.7
========== ==========
*Fixed* *Fixed*
@ -1429,7 +1533,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog
 
File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog
5.16 0.4.6 5.22 0.4.6
========== ==========
*Fixed* *Fixed*
@ -1442,7 +1546,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog
 
File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog
5.17 0.4.5 5.23 0.4.5
========== ==========
*Fixed* *Fixed*
@ -1454,7 +1558,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog
 
File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog
5.18 0.4.4 5.24 0.4.4
========== ==========
*Fixed* *Fixed*
@ -1466,7 +1570,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog
 
File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog
5.19 0.4.3 5.25 0.4.3
========== ==========
*Fixed* *Fixed*
@ -1476,7 +1580,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog
 
File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog
5.20 0.4.2 5.26 0.4.2
========== ==========
*Fixed* *Fixed*
@ -1485,7 +1589,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog
 
File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog
5.21 0.4.1 5.27 0.4.1
========== ==========
*Fixed* *Fixed*
@ -1495,7 +1599,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog
 
File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog
5.22 0.4 5.28 0.4
======== ========
_Note:_ The next release, 0.5, may include changes which will require _Note:_ The next release, 0.5, may include changes which will require
@ -1576,7 +1680,7 @@ automatically, as they will be pushed to the master branch when ready.
 
File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog
5.23 0.3.2 5.29 0.3.2
========== ==========
*Fixed* *Fixed*
@ -1589,7 +1693,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog
 
File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog
5.24 0.3.1 5.30 0.3.1
========== ==========
*Fixed* *Fixed*
@ -1599,7 +1703,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog
 
File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog
5.25 0.3 5.31 0.3
======== ========
*Added* *Added*
@ -1667,7 +1771,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog
 
File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog
5.26 0.2.3 5.32 0.2.3
========== ==========
*Fixed* *Fixed*
@ -1677,7 +1781,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog
 
File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog
5.27 0.2.2 5.33 0.2.2
========== ==========
*Fixed* *Fixed*
@ -1688,7 +1792,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog
 
File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog
5.28 0.2.1 5.34 0.2.1
========== ==========
*Fixed* *Fixed*
@ -1698,7 +1802,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog
 
File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog
5.29 0.2 5.35 0.2
======== ========
*Added* *Added*
@ -1781,7 +1885,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog
 
File: README.info, Node: 01, Prev: 02, Up: Changelog File: README.info, Node: 01, Prev: 02, Up: Changelog
5.30 0.1 5.36 0.1
======== ========
First tagged release. First tagged release.
@ -1839,75 +1943,81 @@ GPLv3
 
Tag Table: Tag Table:
Node: Top225 Node: Top225
Node: Contents1845 Node: Contents1926
Node: Screenshots1968 Node: Screenshots2049
Node: Installation2086 Node: Installation2167
Node: Quelpa2600 Node: Quelpa2681
Node: Helm support3128 Node: Helm support3209
Node: Usage3531 Node: Usage3612
Node: Commands3929 Node: Commands4010
Node: org-ql-find4394 Node: org-ql-find4475
Node: org-ql-open-link5212 Node: org-ql-open-link5383
Node: org-ql-refile6067 Node: org-ql-refile6238
Node: org-ql-search6395 Node: org-ql-search6566
Node: helm-org-ql8326 Node: helm-org-ql8497
Node: org-ql-view8704 Node: org-ql-view8875
Node: org-ql-view-sidebar9234 Node: org-ql-view-sidebar9405
Node: org-ql-view-recent-items9614 Node: org-ql-view-recent-items9785
Node: org-ql-sparse-tree10110 Node: org-ql-sparse-tree10281
Node: Queries10910 Node: Queries11081
Node: Non-sexp query syntax12027 Node: Non-sexp query syntax12198
Node: General predicates13786 Node: General predicates13957
Node: Ancestor/descendant predicates20773 Node: Ancestor/descendant predicates20882
Node: Date/time predicates21901 Node: Date/time predicates22010
Node: Functions / Macros25025 Node: Functions / Macros25134
Node: Agenda-like views25323 Node: Agenda-like views25432
Ref: Function org-ql-block25485 Ref: Function org-ql-block25594
Node: Listing / acting-on results26746 Node: Listing / acting-on results26855
Ref: Caching26954 Ref: Caching27063
Ref: Function org-ql-select27867 Ref: Function org-ql-select27976
Ref: Function org-ql-query30293 Ref: Function org-ql-query30402
Ref: Macro org-ql (deprecated)32067 Ref: Macro org-ql (deprecated)32176
Node: Custom predicates32382 Node: Custom predicates32491
Ref: Macro org-ql-defpred32606 Ref: Macro org-ql-defpred32715
Node: Dynamic block36047 Node: Dynamic block36156
Node: Links38771 Node: Links38880
Node: Tips39458 Node: Tips39567
Node: Changelog39782 Node: Changelog39891
Node: 08-pre40592 Node: 09-pre40782
Node: 07342357 Node: 08440889
Node: 07243092 Node: 08341344
Node: 07144011 Node: 08241685
Node: 0744820 Node: 08142078
Node: 06347744 Node: 0842499
Node: 06248275 Node: 07445223
Node: 06148580 Node: 07345446
Node: 0649148 Node: 07246178
Node: 05252202 Node: 07147097
Node: 05152504 Node: 0747908
Node: 0552929 Node: 06350774
Node: 04954460 Node: 06251307
Node: 04854742 Node: 06151614
Node: 04755091 Node: 0652184
Node: 04655500 Node: 05255240
Node: 04555908 Node: 05155542
Node: 04456269 Node: 0555967
Node: 04356628 Node: 04957498
Node: 04256831 Node: 04857780
Node: 04156992 Node: 04758129
Node: 0457239 Node: 04658538
Node: 03261340 Node: 04558946
Node: 03161743 Node: 04459307
Node: 0361940 Node: 04359666
Node: 02365240 Node: 04259869
Node: 02265474 Node: 04160030
Node: 02165754 Node: 0460277
Node: 0265959 Node: 03264378
Node: 0170037 Node: 03164781
Node: Notes70138 Node: 0364978
Node: Comparison with Org Agenda searches70300 Node: 02368278
Node: org-sidebar71189 Node: 02268512
Node: License71468 Node: 02168792
Node: 0268997
Node: 0173075
Node: Notes73176
Node: Comparison with Org Agenda searches73338
Node: org-sidebar74227
Node: License74506
 
End Tag Table End Tag Table

View file

@ -648,6 +648,14 @@ with keyword arg NOW in PLIST."
;; TODO: Other predicates. ;; TODO: Other predicates.
(it "Ignores empty quoted strings"
(expect (org-ql--query-string-to-sexp "\"\"")
:to-equal nil)
(expect (org-ql--query-string-to-sexp "foo \"\" bar")
:to-equal '(and (rifle "foo") (rifle "bar")))
(expect (org-ql--query-string-to-sexp "foo \"baz\" bar")
:to-equal '(and (rifle "foo") (rifle "baz") (rifle "bar"))))
(it "Negated terms" (it "Negated terms"
(expect (org-ql--query-string-to-sexp "todo: !todo:CHECK,SOMEDAY") (expect (org-ql--query-string-to-sexp "todo: !todo:CHECK,SOMEDAY")
:to-equal '(and (todo) (not (todo "CHECK" "SOMEDAY")))) :to-equal '(and (todo) (not (todo "CHECK" "SOMEDAY"))))
@ -1836,8 +1844,8 @@ with keyword arg NOW in PLIST."
;; have a chance to be gathered. So we make a test buffer and run the test in that, with a test heading. ;; have a chance to be gathered. So we make a test buffer and run the test in that, with a test heading.
(let ((test-buffer (get-buffer-create "*test-org-ql*"))) (let ((test-buffer (get-buffer-create "*test-org-ql*")))
(cl-flet ((open-link (cl-flet ((open-link (link)
(link) (with-current-buffer test-buffer (with-current-buffer test-buffer
(erase-buffer) (erase-buffer)
(org-mode) (org-mode)
(insert "* TODO Test heading \n\n") (insert "* TODO Test heading \n\n")
@ -1998,8 +2006,7 @@ with keyword arg NOW in PLIST."
(when-let ((buffer (find-file-noselect filename 'nowarn))) (when-let ((buffer (find-file-noselect filename 'nowarn)))
(kill-buffer buffer)))) (kill-buffer buffer))))
(cl-flet ((var-after-bookmark-set-and-jump (cl-flet ((var-after-bookmark-set-and-jump (var buffers-files query &key sort super-groups)
(var buffers-files query &key sort super-groups)
(org-ql-search buffers-files query (org-ql-search buffers-files query
:super-groups super-groups :super-groups super-groups
:sort sort :title title :buffer view-buffer) :sort sort :title title :buffer view-buffer)
@ -2061,8 +2068,8 @@ with keyword arg NOW in PLIST."
(describe "Dynamic blocks" (describe "Dynamic blocks"
(describe "warn about sexp queries" (describe "warn about sexp queries"
(cl-flet ((test-dblock (cl-flet ((test-dblock (&optional input)
(&optional input) (with-current-buffer (get-buffer-create "*TEST DBLOCK*") (with-current-buffer (get-buffer-create "*TEST DBLOCK*")
(erase-buffer) (erase-buffer)
(org-mode) (org-mode)
(insert "* TODO Heading 1\n\n" (insert "* TODO Heading 1\n\n"
@ -2101,8 +2108,7 @@ with keyword arg NOW in PLIST."
(insert "* TODO Test heading\n\n") (insert "* TODO Test heading\n\n")
(org-mode))) (org-mode)))
(cl-flet* ((open-link-in (cl-flet* ((open-link-in (link buffer input)
(link buffer input)
;; Org REDUCED THE NUMBER OF ARGUMENTS TO `org-open-link-from-string'! That BREAKS BACKWARD ;; Org REDUCED THE NUMBER OF ARGUMENTS TO `org-open-link-from-string'! That BREAKS BACKWARD
;; COMPATIBILITY! So I have to make my own function so these tests can work across Org versions! ;; COMPATIBILITY! So I have to make my own function so these tests can work across Org versions!
(with-current-buffer buffer (with-current-buffer buffer
@ -2114,8 +2120,7 @@ with keyword arg NOW in PLIST."
(with-simulated-input input (with-simulated-input input
(org-open-at-point)))) (org-open-at-point))))
(var-after-link-save-open (var-after-link-save-open (var buffers-files query &key sort super-groups
(var buffers-files query &key sort super-groups
(buffer link-buffer) (store-input "RET") open-input) (buffer link-buffer) (store-input "RET") open-input)
(org-ql-search buffers-files query (org-ql-search buffers-files query
:super-groups super-groups :super-groups super-groups