From a5fbb5d9767a2cb777f2cf44873b252a5d7e2931 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 00:01:32 -0600 Subject: [PATCH 01/72] Tidy: Indentation of dash forms See, e.g. . Ultimately I'd prefer to indent with one distinguished argument, but the noise it causes downstream is likely not worth it. (And, unfortunately, the indentation of the built-in thread-first and thread-last forms has changed to be like this as well, which is even worse, causing 10-11 characters of extra indentation in those forms' bodies!) --- helm-org-ql.el | 8 ++-- org-ql-search.el | 10 ++--- org-ql-view.el | 92 ++++++++++++++++++++++---------------------- org-ql.el | 52 ++++++++++++------------- tests/test-org-ql.el | 6 +-- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/helm-org-ql.el b/helm-org-ql.el index 38b9722..02eff9a 100644 --- a/helm-org-ql.el +++ b/helm-org-ql.el @@ -59,8 +59,8 @@ Based on `helm-map'.") (helm-make-source "Org QL Views" 'helm-source-sync :candidates (lambda () (->> org-ql-views - (-map #'car) - (-sort #'string<))) + (-map #'car) + (-sort #'string<))) :action (list (cons "Show view" #'org-ql-view))) "Helm source for `org-ql-views'.") @@ -209,8 +209,8 @@ WINDOW-WIDTH should be the width of the Helm window." (width (- window-width (length prefix))) (heading (org-get-heading t)) (path (-> (org-get-outline-path) - (org-format-outline-path width nil "") - (org-split-string ""))) + (org-format-outline-path width nil "") + (org-split-string ""))) (path (if helm-org-ql-reverse-paths (concat heading "\\" (s-join "\\" (nreverse path))) (concat (s-join "/" path) "/" heading)))) diff --git a/org-ql-search.el b/org-ql-search.el index aa75656..c98f1e4 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -233,9 +233,9 @@ automatically from the query." ;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing. ;; But we do call `org-agenda-finalize-entries', which allows `org-super-agenda' to work. (->> items - (-map #'org-ql-view--format-element) - org-agenda-finalize-entries - insert) + (-map #'org-ql-view--format-element) + org-agenda-finalize-entries + insert) (insert "\n")))) ;;;###autoload @@ -355,8 +355,8 @@ For example, an org-ql dynamic block header could look like: When RECURSE is non-nil, recurse into subdirectories. When REGEXP is non-nil, only return files that match REGEXP." (let ((files (->> directories - (--map (f-files it nil recurse)) - -flatten))) + (--map (f-files it nil recurse)) + -flatten))) (if regexp (--select (string-match regexp it) files) diff --git a/org-ql-view.el b/org-ql-view.el index 74f74d9..13cde85 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -153,11 +153,11 @@ See info node `(elisp)Cyclic Window Ordering'." (interactive) (let* ((ts (ts-now)) (beg-of-week (->> ts - (ts-adjust 'day (- (ts-dow (ts-now)))) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (- (ts-dow (ts-now)))) + (ts-apply :hour 0 :minute 0 :second 0))) (end-of-week (->> ts - (ts-adjust 'day (- 6 (ts-dow (ts-now)))) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day (- 6 (ts-dow (ts-now)))) + (ts-apply :hour 23 :minute 59 :second 59)))) (org-ql-search (org-agenda-files) `(ts-active :from ,beg-of-week :to ,end-of-week) @@ -170,11 +170,11 @@ See info node `(elisp)Cyclic Window Ordering'." (interactive) (let* ((ts (ts-adjust 'day 7 (ts-now))) (beg-of-week (->> ts - (ts-adjust 'day (- (ts-dow (ts-now)))) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (- (ts-dow (ts-now)))) + (ts-apply :hour 0 :minute 0 :second 0))) (end-of-week (->> ts - (ts-adjust 'day (- 6 (ts-dow (ts-now)))) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day (- 6 (ts-dow (ts-now)))) + (ts-apply :hour 23 :minute 59 :second 59)))) (org-ql-search (org-agenda-files) `(ts-active :from ,beg-of-week :to ,end-of-week) @@ -272,8 +272,8 @@ TYPE may be `ts', `ts-active', `ts-inactive', `clocked', or `closed'." (interactive (list :num-days (read-number "Days: ") :type (->> '(ts ts-active ts-inactive clocked closed) - (completing-read "Timestamp type: ") - intern))) + (completing-read "Timestamp type: ") + intern))) ;; It doesn't make much sense to use other date-based selectors to ;; look into the past, so to prevent confusion, we won't allow them. (-let* ((query (pcase-exhaustive type @@ -395,12 +395,12 @@ update search arguments." (let ((inhibit-read-only t)) (erase-buffer) (->> org-ql-views - (-map #'car) - (-sort (if org-ql-view-sidebar-sort-views - #'string< - #'ignore)) - (s-join "\n") - insert)) + (-map #'car) + (-sort (if org-ql-view-sidebar-sort-views + #'string< + #'ignore)) + (s-join "\n") + insert)) (current-buffer))) (defvar bookmark-make-record-function) @@ -469,8 +469,8 @@ If TITLE, prepend it to the header." (format "%s" (org-ql-view--contract-buffers-files buffers-files)))) (buffers-files-formatted (when buffers-files-formatted (propertize (->> buffers-files-formatted - (org-ql-view--font-lock-string 'emacs-lisp-mode) - (s-truncate available-width)) + (org-ql-view--font-lock-string 'emacs-lisp-mode) + (s-truncate available-width)) 'help-echo buffers-files-formatted)))) (concat title (when query (propertize "Query:" 'face 'transient-argument)) @@ -750,8 +750,8 @@ When opened, the link searches the buffer it's opened from." (s-truncate (- (window-width) 15) (concat (propertize key 'face 'transient-argument) ": " (->> value - org-ql-view--format-query - (org-ql-view--font-lock-string 'emacs-lisp-mode))))) + org-ql-view--format-query + (org-ql-view--font-lock-string 'emacs-lisp-mode))))) (transient-define-infix org-ql-view--transient-title () ;; TODO: Add an asterisk or something when the view has been modified but not saved. @@ -850,8 +850,8 @@ return an empty string." ;; 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). (title (--> (org-ql-view--add-faces element) - (org-element-property :raw-value it) - (org-link-display-format it))) + (org-element-property :raw-value it) + (org-link-display-format it))) (todo-keyword (-some--> (org-element-property :todo-keyword element) (org-ql-view--add-todo-face it))) (tag-list (if org-use-tag-inheritance @@ -872,9 +872,9 @@ return an empty string." (org-element-property :tags element))) (tag-string (when tag-list (--> tag-list - (s-join ":" it) - (s-wrap it ":") - (org-add-props it nil 'face 'org-tag)))) + (s-join ":" it) + (s-wrap it ":") + (org-add-props it nil 'face 'org-tag)))) ;; (category (org-element-property :category element)) (priority-string (-some->> (org-element-property :priority element) (char-to-string) @@ -890,19 +890,19 @@ return an empty string." (remove-list-of-text-properties 0 (length string) '(line-prefix) string) ;; Add all the necessary properties and faces to the whole string (--> string - ;; FIXME: Use proper prefix - (concat " " it) - (org-add-props it properties - 'org-agenda-type 'search - 'todo-state todo-keyword - 'tags tag-list - 'org-habit-p habit-property))))) + ;; FIXME: Use proper prefix + (concat " " it) + (org-add-props it properties + 'org-agenda-type 'search + 'todo-state todo-keyword + 'tags tag-list + 'org-habit-p habit-property))))) (defun org-ql-view--add-faces (element) "Return ELEMENT with deadline and scheduled faces added." (->> element - (org-ql-view--add-scheduled-face) - (org-ql-view--add-deadline-face))) + (org-ql-view--add-scheduled-face) + (org-ql-view--add-deadline-face))) (defun org-ql-view--add-priority-face (string) "Return STRING with priority face added." @@ -959,11 +959,11 @@ return an empty string." ((> today-day-number scheduled-day-number) 'org-scheduled-previously) (t 'org-scheduled))) (title (--> (org-element-property :raw-value element) - (org-add-props it nil - 'face face))) + (org-add-props it nil + 'face face))) (properties (--> (cadr element) - (plist-put it :title title) - (plist-put it :relative-due-date relative-due-date)))) + (plist-put it :title title) + (plist-put it :relative-due-date relative-due-date)))) (list (car element) properties)) ;; Not scheduled @@ -985,16 +985,16 @@ property." ;; FIXME: Unused for now: (done-p (member todo-keyword org-done-keywords)) ;; FIXME: Unused for now: (today-p (= today-day-number deadline-day-number)) (deadline-passed-fraction (--> (- deadline-day-number today-day-number) - (float it) - (/ it (max org-deadline-warning-days 1)) - (- 1 it))) + (float it) + (/ it (max org-deadline-warning-days 1)) + (- 1 it))) (face (org-agenda-deadline-face deadline-passed-fraction)) (title (--> (org-element-property :raw-value element) - (org-add-props it nil - 'face face))) + (org-add-props it nil + 'face face))) (properties (--> (cadr element) - (plist-put it :title title) - (plist-put it :relative-due-date relative-due-date)))) + (plist-put it :title title) + (plist-put it :relative-due-date relative-due-date)))) (list (car element) properties)) ;; No deadline @@ -1117,7 +1117,7 @@ The counterpart to `org-ql-view--contract-buffers-files'." "todo") nil nil (when org-ql-view-sort (prin1-to-string org-ql-view-sort))) - (--remove (equal "buffer-order" it))))) + (--remove (equal "buffer-order" it))))) (pcase input ('nil nil) ((and (pred listp) sort) diff --git a/org-ql.el b/org-ql.el index ede80b5..0015f1d 100644 --- a/org-ql.el +++ b/org-ql.el @@ -584,7 +584,7 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)." (cond ((and (listp inherited) (listp local)) (->> (append inherited local) - -non-nil -uniq)) + -non-nil -uniq)) ((listp inherited) inherited) ((listp local) local))))) (cl-typecase org-use-tag-inheritance @@ -680,8 +680,8 @@ from within ELEMENT's buffer." ;; time? I don't know, but for now, it seems that we have to use `copy-marker'. (let* ((marker (copy-marker (org-element-property :begin element))) (properties (--> (cadr element) - (plist-put it :org-marker marker) - (plist-put it :org-hd-marker marker)))) + (plist-put it :org-marker marker) + (plist-put it :org-hd-marker marker)))) (setf (cadr element) properties) element)) @@ -922,16 +922,16 @@ value of `org-ql-predicates')." (let* ((names (--map (symbol-name (plist-get (cdr it) :name)) predicates)) (aliases (->> predicates - (--map (plist-get (cdr it) :aliases)) - -non-nil - -flatten - (-map #'symbol-name))) + (--map (plist-get (cdr it) :aliases)) + -non-nil + -flatten + (-map #'symbol-name))) (predicate-names (->> (append names aliases) - -uniq - ;; Sort the keywords longest-first to work around what seems to be an - ;; obscure bug in `peg': when one keyword is a substring of another, - ;; and the shorter one is listed first, the shorter one fails to match. - (-sort (-on #'> #'length)))) + -uniq + ;; Sort the keywords longest-first to work around what seems to be an + ;; obscure bug in `peg': when one keyword is a substring of another, + ;; and the shorter one is listed first, the shorter one fails to match. + (-sort (-on #'> #'length)))) (pexs `((query (+ (and term (* [blank])))) (term (or (and negation (list positive-term) ;; This is a bit confusing, but it seems to work. There's probably a better way. @@ -1003,8 +1003,8 @@ manually; see the definition of `org-ql-defpred').") "Define function `org-ql--normalize-query' for PREDICATES. PREDICATES should be the value of `org-ql-predicates'." (let ((normalizer-patterns (->> predicates - (--map (plist-get (cdr it) :normalizers)) - (-flatten-n 1)))) + (--map (plist-get (cdr it) :normalizers)) + (-flatten-n 1)))) (fset 'org-ql--normalize-query (byte-compile `(lambda (query) @@ -1274,33 +1274,33 @@ result form." (when from (setq from (pcase from ((or 'today "today") (->> (ts-now) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-apply :hour 0 :minute 0 :second 0))) ((pred numberp) (->> (ts-now) - (ts-adjust 'day from) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day from) + (ts-apply :hour 0 :minute 0 :second 0))) ((and (pred stringp) (guard (ignore-errors (cl-parse-integer from)))) ;; The `pcase' `let' pattern doesn't bind values in the ;; body forms, so we have to parse the integer again. (->> (ts-now) - (ts-adjust 'day (cl-parse-integer from)) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (cl-parse-integer from)) + (ts-apply :hour 0 :minute 0 :second 0))) ((pred stringp) (ts-parse-fill 'begin from)) ((pred ts-p) from)))) (when to (setq to (pcase to ((or 'today "today") (->> (ts-now) - (ts-apply :hour 23 :minute 59 :second 59))) + (ts-apply :hour 23 :minute 59 :second 59))) ((pred numberp) (->> (ts-now) - (ts-adjust 'day to) - (ts-apply :hour 23 :minute 59 :second 59))) + (ts-adjust 'day to) + (ts-apply :hour 23 :minute 59 :second 59))) ((and (pred stringp) (guard (ignore-errors (cl-parse-integer to)))) ;; The `pcase' `let' pattern doesn't bind values in the ;; body forms, so we have to parse the integer again. (->> (ts-now) - (ts-adjust 'day (cl-parse-integer to)) - (ts-apply :hour 23 :minute 59 :second 59))) + (ts-adjust 'day (cl-parse-integer to)) + (ts-apply :hour 23 :minute 59 :second 59))) ((pred stringp) (ts-parse-fill 'end to)) ((pred ts-p) to)))) (setf result (progn ,@body)) @@ -2219,8 +2219,8 @@ non-nil if entry has a deadline." :normalizers ((`(,predicate-names auto . ,rest) ;; Use `org-deadline-warning-days' as the :to arg. (let ((ts (->> (ts-now) - (ts-adjust 'day org-deadline-warning-days) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day org-deadline-warning-days) + (ts-apply :hour 23 :minute 59 :second 59)))) `(deadline-warning :to ,ts ,@rest))) (`(,predicate-names . ,(and rest (guard (numberp (car rest))))) (org-ql--normalize-from-to-on diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 25ac617..fbccd80 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -105,9 +105,9 @@ Set at runtime by test suite.") "Return buffer visiting FILENAME. FILENAME should be a file in the \"tests\" directory." (->> (locate-dominating-file default-directory ".git") - (expand-file-name "tests") - (expand-file-name filename) - find-file-noselect)) + (expand-file-name "tests") + (expand-file-name filename) + find-file-noselect)) ;;;; Macros From 6c9c0b957abd21df57f1885032847a721c3e859f Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 00:05:14 -0600 Subject: [PATCH 02/72] Tests: Rename data2.org to data-file-tags.org It appears likely that we'll need a few test-specific data files, so we should use descriptive names. --- tests/{data2.org => data-file-tags.org} | 0 tests/test-org-ql.el | 18 +++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) rename tests/{data2.org => data-file-tags.org} (100%) diff --git a/tests/data2.org b/tests/data-file-tags.org similarity index 100% rename from tests/data2.org rename to tests/data-file-tags.org diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index fbccd80..5210a7c 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1409,10 +1409,10 @@ with keyword arg NOW in PLIST." (org-ql-it "with file tags" (org-ql-expect ('(tags "food")) '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - :buffer (org-ql-test-data-buffer "data2.org")) + :buffer (org-ql-test-data-buffer "data-file-tags.org")) (org-ql-expect ('(tags "fruit")) '("Fruit" "Blueberry" "Strawberry") - :buffer (org-ql-test-data-buffer "data2.org")))) + :buffer (org-ql-test-data-buffer "data-file-tags.org")))) (describe "(tags-inherited)" @@ -1440,10 +1440,10 @@ with keyword arg NOW in PLIST." (org-ql-it "with file tags" (org-ql-expect ('(tags-inherited "food")) '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - :buffer (org-ql-test-data-buffer "data2.org")) + :buffer (org-ql-test-data-buffer "data-file-tags.org")) (org-ql-expect ('(tags-inherited "fruit")) '("Blueberry" "Strawberry") - :buffer (org-ql-test-data-buffer "data2.org")))) + :buffer (org-ql-test-data-buffer "data-file-tags.org")))) (describe "(tags-local)" @@ -1470,10 +1470,10 @@ with keyword arg NOW in PLIST." (org-ql-it "with file tags" (org-ql-expect ('(tags-local "food")) nil - :buffer (org-ql-test-data-buffer "data2.org")) + :buffer (org-ql-test-data-buffer "data-file-tags.org")) (org-ql-expect ('(tags-local "fruit")) '("Fruit") - :buffer (org-ql-test-data-buffer "data2.org")))) + :buffer (org-ql-test-data-buffer "data-file-tags.org")))) (describe "(tags-all), (tags&)" @@ -1486,7 +1486,7 @@ with keyword arg NOW in PLIST." (org-ql-it "with file tags" (org-ql-expect ('(tags-all "food" "fruit")) '("Fruit" "Blueberry" "Strawberry") - :buffer (org-ql-test-data-buffer "data2.org")))) + :buffer (org-ql-test-data-buffer "data-file-tags.org")))) (describe "(tags-regexp), (tags*)" @@ -1511,10 +1511,10 @@ with keyword arg NOW in PLIST." (org-ql-it "with regexp matching file tags" (org-ql-expect ('(tags-regexp "foo")) '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - :buffer (org-ql-test-data-buffer "data2.org")) + :buffer (org-ql-test-data-buffer "data-file-tags.org")) (org-ql-expect ('(tags* "frui")) '("Fruit" "Blueberry" "Strawberry") - :buffer (org-ql-test-data-buffer "data2.org")))) + :buffer (org-ql-test-data-buffer "data-file-tags.org")))) (describe "(ts)" From 0304a2c9dcfb32a4ef9794a59d6466ddda92c21a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 00:52:47 -0600 Subject: [PATCH 03/72] Tests: (org-ql-it) Expand using Buttercup's it As the implementation of `it' changes, this will change with it (correctly). --- tests/test-org-ql.el | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 5210a7c..9fd9315 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -112,20 +112,17 @@ FILENAME should be a file in the \"tests\" directory." ;;;; Macros (defmacro org-ql-it (description &rest body) - "Expand to two specs, one of which tests with preambles and the other without. -Based on Buttercup macro `it'." + "Expand to two specs, one of which tests with preambles and the other without." (declare (indent 1) (debug (&define sexp def-body))) - (if body - `(progn - (buttercup-it ,(concat description " (preamble) ") - (lambda () - (let ((org-ql-use-preamble t)) - ,@body))) - (buttercup-it ,(concat description " (no preamble)") - (lambda () - (let ((org-ql-use-preamble nil)) - ,@body)))) - `(buttercup-xit ,description))) + `(progn + (it ,(concat description " (preamble) ") + ,(when body + `(let ((org-ql-use-preamble t)) + ,@body))) + (it ,(concat description " (no preamble) ") + ,(when body + `(let ((org-ql-use-preamble nil)) + ,@body)))) ) (cl-defmacro org-ql-expect (ql-args results &key (buffer 'org-ql-test-buffer)) "Expand to `expect' test form that expects QL-ARGS to equal RESULTS. From 1996969920a58259439e8a4baa446264008430ce Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:41:01 -0600 Subject: [PATCH 04/72] Fix: (src) Rewrite body Fixes #304. Thanks to @johanwk for reporting. --- README.org | 1 + org-ql.el | 36 ++++++++++++++++-------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/README.org b/README.org index 2817dcc..4935af9 100644 --- a/README.org +++ b/README.org @@ -558,6 +558,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixed* + Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. ++ Predicate ~src~'s behavior with various arguments. *Internal* + Certain query predicates, when called multiple times in an ~and~ sub-expression, are optimized to a single call. diff --git a/org-ql.el b/org-ql.el index 0015f1d..d602e60 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1925,26 +1925,22 @@ language. Matching is done case-insensitively." ;; Always check contents with predicate. :query query))) :body - (catch 'return - (save-excursion - (save-match-data - (when (re-search-forward org-babel-src-block-regexp (org-entry-end-position) t) - (when lang - (unless (string= lang (match-string 2)) - (throw 'return nil))) - (if regexps - (let ((contents-beg (progn - (goto-char (match-beginning 0)) - (forward-line 1) - (point))) - (contents-end (progn - (goto-char (match-end 0)) - (point-at-bol)))) - (cl-loop for re in regexps - do (goto-char contents-beg) - always (re-search-forward re contents-end t))) - ;; No regexps to check: return non-nil. - t)))))) + (save-excursion + (save-match-data + (cl-loop while (re-search-forward org-babel-src-block-regexp (org-entry-end-position) t) + thereis (when (or (not lang) (equal lang (match-string 2))) + (or (not regexps) + (save-excursion + (let ((contents-beg (progn + (goto-char (match-beginning 0)) + (forward-line 1) + (point))) + (contents-end (progn + (goto-char (match-end 0)) + (point-at-bol)))) + (cl-loop for re in regexps + do (goto-char contents-beg) + always (re-search-forward re contents-end t)))))))))) (org-ql-defpred (tags) (&rest tags) "Return non-nil if current heading has one or more of TAGS (a list of strings). From 1fdad05fef83f6c2fea1eb75231fde5267d56908 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:42:49 -0600 Subject: [PATCH 05/72] Tests: Tidy --- tests/test-org-ql.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 9fd9315..3c44f38 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -161,7 +161,7 @@ with keyword arg NOW in PLIST." (substring-no-properties (org-get-heading t t))) (defun org-ql-test-org-get-heading () ;; For Org 9.1.9. - (substring-no-properties (org-get-heading t t t t)))) + (substring-no-properties (org-get-heading t t t t)))) ) (setq org-ql-test-buffer (org-ql-test-data-buffer "data.org") ;; For manual testing: From 2ae60f8dc50cf2a156a3ca7ec929d19909139097 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:44:20 -0600 Subject: [PATCH 06/72] Tests: (src) More normal forms --- tests/test-org-ql.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 3c44f38..3750798 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -328,7 +328,10 @@ with keyword arg NOW in PLIST." (expect (org-ql--normalize-query '(src :regexps ("foo") :lang "bar")) :to-equal '(src :lang "bar" :regexps '("foo"))) (expect (org-ql--normalize-query '(src :regexps ("foo") :lang)) - :to-equal '(src :regexps '("foo"))))) + :to-equal '(src :regexps '("foo")))) + (it "normalizes just the :lang keyword arg" + (expect (org-ql--normalize-query '(src :lang "bar")) + :to-equal '(src :lang "bar" :regexps 'nil)))) (describe "(tags-inherited)" (it "handles 0 arguments" From 68ac6ddd28b46f4eead9108566c9bc4b545fa2e5 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:44:44 -0600 Subject: [PATCH 07/72] Tests: Use before-each for org-ql-test-data-buffer This seems like the best way. --- tests/test-org-ql.el | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 3750798..f762231 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -163,6 +163,7 @@ with keyword arg NOW in PLIST." ;; For Org 9.1.9. (substring-no-properties (org-get-heading t t t t)))) ) + (before-each (setq org-ql-test-buffer (org-ql-test-data-buffer "data.org") ;; For manual testing: ;; org-ql-test-buffer (find-file-noselect "data.org") From d784f8f71c8d6dd1c0f39955046848f61be951e5 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:45:03 -0600 Subject: [PATCH 08/72] Tests: (src) Implement --- README.org | 1 + tests/data-src.org | 29 +++++++++++++++++++++++++++++ tests/test-org-ql.el | 42 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 tests/data-src.org diff --git a/README.org b/README.org index 4935af9..8f8e751 100644 --- a/README.org +++ b/README.org @@ -563,6 +563,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Internal* + Certain query predicates, when called multiple times in an ~and~ sub-expression, are optimized to a single call. + Use ~buffer-chars-modified-tick~ instead of ~buffer-modified-tick~. (Thanks to [[https://github.com/yantar92][Ihor Radchenko]].) ++ Implemented tests for ~src~ predicate. *Credits* + Thanks to [[https://github.com/chasecaleb][Caleb Chase]] for help with [[https://github.com/alphapapa/org-ql/pull/285][#285]], fixed in [[https://github.com/alphapapa/org-ql/commit/91908186fcca4b5fd2e9d26da5bc0375c2b41acf][9190818]]. diff --git a/tests/data-src.org b/tests/data-src.org new file mode 100644 index 0000000..20f75a8 --- /dev/null +++ b/tests/data-src.org @@ -0,0 +1,29 @@ +#+title: org-ql test data for ~src~ predicate + +* Alpha + +#+begin_src elisp + (message "foo") +#+end_src + +#+begin_src python + print("foo") +#+end_src + +#+begin_src js + console.log("foo") +#+end_src + +* Bravo + +#+begin_src elisp + (message "bar") +#+end_src + +#+begin_src python + print("bar") +#+end_src + +* Charlie + +This entry has no source block. diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index f762231..bac29be 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1367,9 +1367,45 @@ with keyword arg NOW in PLIST." (org-ql-expect ('(scheduled :on 0)) '("Practice leaping tall buildings in a single bound" "Order a pizza" "Get haircut" "Fix flux capacitor" "Shop for groceries" "Rewrite Emacs in Common Lisp"))))) - ;; ;; TODO: Test (src) predicate. That will require modifying test data, which will be a - ;; ;; significant hassle. Manual testing shows that the predicate appears to work properly. - ;; + (describe "(src)" + (before-each + ;; It would seem preferable to use :var for this, but this seems more reliable. + (setq org-ql-test-buffer (org-ql-test-data-buffer "data-src.org"))) + + (org-ql-it "without arguments" + (org-ql-expect ('(src)) + '("Alpha" "Bravo"))) + + (org-ql-it "with plain argument" + ;; Finds in first source block in entry. + (org-ql-expect ('(src "foo")) + '("Alpha")) + (org-ql-expect ('(src "bar")) + '("Bravo")) + (org-ql-expect ('(src "print")) + ;; Finds in subsequent source block in entry. + '("Alpha" "Bravo"))) + + (org-ql-it "with :regexps argument" + (org-ql-expect ('(src :regexps ("foo"))) + '("Alpha")) + (org-ql-expect ('(src :regexps ("bar"))) + '("Bravo")) + (org-ql-expect ('(src :regexps ("print" "foo"))) + '("Alpha")) + (org-ql-expect ('(src :regexps ("foo" "bar"))) + nil)) + + (org-ql-it "with :lang argument" + ;; Finds in first source block in entry. + (org-ql-expect ('(src :lang "elisp")) + '("Alpha" "Bravo")) + ;; Finds in subsequent source block in entry. + (org-ql-expect ('(src :lang "python")) + '("Alpha" "Bravo")) + (org-ql-expect ('(src :lang "js")) + '("Alpha")))) + (describe "(todo)" (org-ql-it "without arguments" From 0d9940c5df02ee51aa307b45b5068f016cc4cb7a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:45:28 -0600 Subject: [PATCH 09/72] Docs: Update README --- org-ql.info | 60 +++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/org-ql.info b/org-ql.info index 0fd3b9f..14a562c 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1050,12 +1050,14 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog *Fixed* • Predicate ‘src’’s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. + • Predicate ‘src’’s behavior with various arguments. *Internal* • Certain query predicates, when called multiple times in an ‘and’ sub-expression, are optimized to a single call. • Use ‘buffer-chars-modified-tick’ instead of ‘buffer-modified-tick’. (Thanks to Ihor Radchenko (https://github.com/yantar92).) + • Implemented tests for ‘src’ predicate. *Credits* • Thanks to Caleb Chase (https://github.com/chasecaleb) for help with @@ -1724,35 +1726,35 @@ Node: Links37140 Node: Tips37827 Node: Changelog38151 Node: 07-pre38934 -Node: 06341209 -Node: 06241744 -Node: 06142049 -Node: 0642617 -Node: 05245671 -Node: 05145971 -Node: 0546394 -Node: 04947923 -Node: 04848203 -Node: 04748552 -Node: 04648961 -Node: 04549369 -Node: 04449730 -Node: 04350089 -Node: 04250292 -Node: 04150453 -Node: 0450700 -Node: 03254801 -Node: 03155204 -Node: 0355401 -Node: 02358701 -Node: 02258935 -Node: 02159215 -Node: 0259420 -Node: 0163498 -Node: Notes63599 -Node: Comparison with Org Agenda searches63761 -Node: org-sidebar64650 -Node: License64929 +Node: 06341323 +Node: 06241858 +Node: 06142163 +Node: 0642731 +Node: 05245785 +Node: 05146085 +Node: 0546508 +Node: 04948037 +Node: 04848317 +Node: 04748666 +Node: 04649075 +Node: 04549483 +Node: 04449844 +Node: 04350203 +Node: 04250406 +Node: 04150567 +Node: 0450814 +Node: 03254915 +Node: 03155318 +Node: 0355515 +Node: 02358815 +Node: 02259049 +Node: 02159329 +Node: 0259534 +Node: 0163612 +Node: Notes63713 +Node: Comparison with Org Agenda searches63875 +Node: org-sidebar64764 +Node: License65043  End Tag Table From 8bb17396615c18ff820d1c8aa8b86aacb77ca871 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 01:47:53 -0600 Subject: [PATCH 10/72] Tests: (src) Normalization with no args Closes #293. Thanks to Akira Komamura (@akirak) for reporting. --- README.org | 2 +- org-ql.info | 61 ++++++++++++++++++++++---------------------- tests/test-org-ql.el | 3 +++ 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/README.org b/README.org index 8f8e751..3e57404 100644 --- a/README.org +++ b/README.org @@ -557,7 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Predicate ~src~ now matches case-insensitively. *Fixed* -+ Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. ++ Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.) + Predicate ~src~'s behavior with various arguments. *Internal* diff --git a/org-ql.info b/org-ql.info index 14a562c..caee1f6 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1049,7 +1049,8 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog *Fixed* • Predicate ‘src’’s matching of begin/end block lines, normalization - of arguments, and handling in non-sexp queries. + of arguments, and handling in non-sexp queries. (Thanks to Akira + Komamura (https://github.com/akirak) for reporting.) • Predicate ‘src’’s behavior with various arguments. *Internal* @@ -1726,35 +1727,35 @@ Node: Links37140 Node: Tips37827 Node: Changelog38151 Node: 07-pre38934 -Node: 06341323 -Node: 06241858 -Node: 06142163 -Node: 0642731 -Node: 05245785 -Node: 05146085 -Node: 0546508 -Node: 04948037 -Node: 04848317 -Node: 04748666 -Node: 04649075 -Node: 04549483 -Node: 04449844 -Node: 04350203 -Node: 04250406 -Node: 04150567 -Node: 0450814 -Node: 03254915 -Node: 03155318 -Node: 0355515 -Node: 02358815 -Node: 02259049 -Node: 02159329 -Node: 0259534 -Node: 0163612 -Node: Notes63713 -Node: Comparison with Org Agenda searches63875 -Node: org-sidebar64764 -Node: License65043 +Node: 06341399 +Node: 06241934 +Node: 06142239 +Node: 0642807 +Node: 05245861 +Node: 05146161 +Node: 0546584 +Node: 04948113 +Node: 04848393 +Node: 04748742 +Node: 04649151 +Node: 04549559 +Node: 04449920 +Node: 04350279 +Node: 04250482 +Node: 04150643 +Node: 0450890 +Node: 03254991 +Node: 03155394 +Node: 0355591 +Node: 02358891 +Node: 02259125 +Node: 02159405 +Node: 0259610 +Node: 0163688 +Node: Notes63789 +Node: Comparison with Org Agenda searches63951 +Node: org-sidebar64840 +Node: License65119  End Tag Table diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index bac29be..c884971 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -325,6 +325,9 @@ with keyword arg NOW in PLIST." (it "normalizes non-keyword args with a :lang keyword arg to keywords" (expect (org-ql--normalize-query '(src "foo" "bar" :lang "baz")) :to-equal '(src :lang "baz" :regexps '("foo" "bar")))) + (it "normalizes zero args without looping" + (expect (org-ql--normalize-query '(src)) + :to-equal '(src))) (it "normalizes all-keyword args without looping" (expect (org-ql--normalize-query '(src :regexps ("foo") :lang "bar")) :to-equal '(src :lang "bar" :regexps '("foo"))) From 2bc327d85f48d314890239cd50b37585ffadcff6 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 02:35:00 -0600 Subject: [PATCH 11/72] Fix: (org-ql-view--link-store) Error message for test suite Use format string to prevent `substitute-quotes' from changing the error string, breaking the test suite when run on CI. Fixes #317. --- org-ql-view.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-ql-view.el b/org-ql-view.el index 13cde85..95dfe3b 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -672,7 +672,7 @@ When opened, the link searches the buffer it's opened from." (when (buffer-base-buffer thing) (buffer-file-name (buffer-base-buffer thing)))))))) (unless (strings-or-file-buffers-p org-ql-view-buffers-files) - (user-error "Views that search non-file-backed buffers can't be linked to")) + (user-error "%s" "Views that search non-file-backed buffers can't be linked to")) (let* ((query-string (--if-let (org-ql--query-sexp-to-string org-ql-view-query) it (org-ql-view--format-query org-ql-view-query))) (buffers-files (prompt-for (org-ql-view--contract-buffers-files org-ql-view-buffers-files))) From 5c5a15a09b5fe0773fabbdc2f55643e9d4b5e847 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 02:47:23 -0600 Subject: [PATCH 12/72] Fix: (org-ql--sanity-check-form) Use pcase --- org-ql.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-ql.el b/org-ql.el index d602e60..1043809 100644 --- a/org-ql.el +++ b/org-ql.el @@ -768,7 +768,7 @@ be coalesced." "Signal error if any forms in FORM do not have preconditions met. Or, when possible, fix the problem." (cl-flet ((check (symbol) - (cl-case symbol + (pcase symbol ('done (unless org-done-keywords ;; NOTE: This check needs to be done from within the Org buffer being checked. (error "Variable `org-done-keywords' is nil. Are you running this from an Org buffer?")))))) From d86a402ba5bf549ea5100c11aec2df32cd91d50c Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 03:04:15 -0600 Subject: [PATCH 13/72] Tidy: Docstrings --- org-ql-search.el | 27 ++++++++++++++++++--------- org-ql.el | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index c98f1e4..1d47be3 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -50,7 +50,7 @@ ;;;; Variables (defvar org-ql-block-header nil - "An optional string to override the default header in `org-ql-block' agenda blocks.") + "Optional string overriding default header in `org-ql-block' agenda blocks.") ;;;; Customization @@ -277,13 +277,16 @@ Valid parameters include: :ts-format Optional format string used to format timestamp-based columns. -For example, an org-ql dynamic block header could look like: +For example, an org-ql dynamic block header could look like +this (must be a single line in the Org buffer): - #+BEGIN: org-ql :query (todo \"UNDERWAY\") :columns (priority todo heading) :sort (priority date) :ts-format \"%Y-%m-%d %H:%M\"" + #+BEGIN: org-ql :query (todo \"UNDERWAY\") +:columns (priority todo heading) :sort (priority date) +:ts-format \"%Y-%m-%d %H:%M\"" (-let* (((&plist :query :columns :sort :ts-format :take) params) (query (cl-etypecase query (string (org-ql--query-string-to-sexp query)) - (list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code. + (list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code. (org-ql--ask-unsafe-query query) query))) (columns (or columns '(heading todo (priority "P")))) @@ -337,7 +340,7 @@ For example, an org-ql dynamic block header could look like: columns) " | ") " |" "\n") - (insert "|- \n") ; Separator hline + (insert "|- \n") ; Separator hline (dolist (element elements) (insert "| " (format-element element) " |" "\n")) (delete-char -1) @@ -345,13 +348,19 @@ For example, an org-ql dynamic block header could look like: ;;;; Functions +(defvar org-ql-search-directories-files-error + ;; Workaround to silence byte-compiler which thinks having this string in an + ;; argument's default value form is a too-long docstring. + "No DIRECTORIES given, and `org-directory' doesn't exist") + (cl-defun org-ql-search-directories-files - (&key (directories (if (file-exists-p org-directory) - (list org-directory) - (user-error "Org-ql-search-directories-files: No DIRECTORIES given, and `org-directory' doesn't exist"))) + (&key (directories + (if (file-exists-p org-directory) + (list org-directory) + (user-error org-ql-search-directories-files-error))) (recurse org-ql-search-directories-files-recursive) (regexp org-ql-search-directories-files-regexp)) - "Return list of matching files in DIRECTORIES, a list of directory paths. + "Return list of matching files in DIRECTORIES. When RECURSE is non-nil, recurse into subdirectories. When REGEXP is non-nil, only return files that match REGEXP." (let ((files (->> directories diff --git a/org-ql.el b/org-ql.el index 1043809..22fa86f 100644 --- a/org-ql.el +++ b/org-ql.el @@ -229,7 +229,8 @@ regexps.") (group-n 1 (regexp ,org-ql-regexp-ts-inactive))) (seq (or "DEADLINE" "SCHEDULED") ":" (0+ " ") (group-n 1 (regexp ,org-ql-regexp-ts-active)))))) - "Matches CLOSED, DEADLINE or SCHEDULED keyword with timestamp, with or without time.") + "Matches CLOSED, DEADLINE or SCHEDULED keyword with timestamp. +Matches with or without time.") (defvar org-ql-regexp-planning-with-time (rx-to-string `(seq bow (or (seq "CLOSED" ":" (0+ " ") @@ -503,8 +504,14 @@ NARROW corresponds to the `org-ql-select' argument NARROW." (cl-defun org-ql--select (&key preamble preamble-case-fold predicate action narrow &allow-other-keys) - "Return results of mapping function ACTION across entries in current buffer matching function PREDICATE. -If NARROW is non-nil, buffer will not be widened." + "Return results for given arguments. +Return results of mapping function ACTION across entries in +current buffer matching function PREDICATE. If NARROW is +non-nil, buffer will not be widened. + +PREAMBLE may be a regexp to search for before calling PREDICATE. +When doing so, `case-fold-search' is bound to +PREAMBLE-CASE-FOLD." ;; Since the mappings are stored in the variable `org-ql-predicates', macros like `flet' ;; can't be used, so we do it manually (this is same as the equivalent `flet' expansion). ;; Mappings are stored in the variable because it allows predicates to be defined with a @@ -1327,7 +1334,7 @@ result form." (setf org-ql-defpred-defer t) (org-ql-defpred (category c) (&rest categories) - "Return non-nil if current heading is in one or more of CATEGORIES (a list of strings)." + "Return non-nil if current heading is in one or more of CATEGORIES." :normalizers ((`(,predicate-names . ,rest) `(category ,@rest))) :body (when-let ((category (org-get-category (point)))) @@ -1359,7 +1366,8 @@ The following forms are accepted: (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. + (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\"." @@ -1492,8 +1500,10 @@ Matching is done case-insensitively." The following forms are accepted: (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. + (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 `>='." :normalizers ((`(,predicate-names . ,args) @@ -1610,7 +1620,7 @@ any link is found." (match-string org-ql-link-description-group))))))))) (org-ql-defpred (rifle smart) (&rest strings) - "Return non-nil if each string argument is found in either the entry or its outline path. + "Return non-nil if each of strings is found in the entry or its outline path. Works like `org-rifle'. This is probably the most useful, intuitive, general-purpose predicate." ;; NOTE: This predicate advertises that it takes strings, but they @@ -1677,7 +1687,7 @@ contiguous segment of the outline path: :body (org-ql--infix-p regexps (org-ql--value-at (point) #'org-ql--outline-path))) (org-ql-defpred path (&rest regexps) - "Return non-nil if current heading's buffer's filename path matches any of REGEXPS (regexp strings). + "Return non-nil if current heading's buffer's file path matches any of REGEXPS. Without arguments, return non-nil if buffer is file-backed." ;; FIXME: This should AND the regexps together, not OR them. :body (when (buffer-file-name) @@ -1764,7 +1774,7 @@ priority B)." thereis (= item-priority (* 1000 (- org-lowest-priority (string-to-char priority-arg))))))))) (org-ql-defpred property (property &optional value &key inherit) - "Return non-nil if current entry has PROPERTY (a string), and optionally VALUE (a string). + "Return non-nil if current entry has PROPERTY, and optionally VALUE. 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 @@ -1856,7 +1866,7 @@ interpreted as nil or non-nil)." (re-search-forward regexp end t)))))) (org-ql-defpred src (&key regexps lang) - "Return non-nil if current entry contains an Org source block matching all of REGEXPS. + "Return non-nil if current entry has an Org source block matching all REGEXPS. If keyword argument LANG is non-nil, the block must be in that language. Matching is done case-insensitively." :coalesce (lambda (coalesced-args current-args) @@ -1968,7 +1978,7 @@ Tests both inherited and local tags." :body (apply #'org-ql--predicate-tags tags)) (org-ql-defpred (tags-inherited inherited-tags tags-i itags) (&rest tags) - "Return non-nil if current heading's inherited tags include one or more of TAGS (a list of strings). + "Return non-nil if current heading's inherited tags include any of TAGS. If TAGS is nil, return non-nil if heading has any inherited tags." :normalizers ((`(,predicate-names . ,tags) `(tags-inherited ,@tags))) @@ -1982,7 +1992,7 @@ If TAGS is nil, return non-nil if heading has any inherited tags." (seq-intersection tags inherited))))))) (org-ql-defpred (tags-local local-tags tags-l ltags) (&rest tags) - "Return non-nil if current heading's local tags include one or more of TAGS (a list of strings). + "Return non-nil if current heading's local tags include any of TAGS. If TAGS is nil, return non-nil if heading has any local tags." :normalizers ((`(,predicate-names . ,tags) `(tags-local ,@tags))) @@ -2025,7 +2035,7 @@ Tests both inherited and local tags." (org-ql-defpred todo (&rest keywords) "Return non-nil if current heading is a TODO item. -With KEYWORDS, return non-nil if its keyword is one of KEYWORDS (a list of strings)." +With KEYWORDS, return non-nil if its keyword is one of KEYWORDS." ;; TODO: Can we make a preamble for plain (todo) queries? :preambles ((`(,predicate-names . ,(and todo-keywords (guard todo-keywords))) (list :case-fold nil :regexp (rx-to-string `(seq bol (1+ "*") (1+ space) (or ,@todo-keywords) (or " " eol)) t)))) @@ -2239,7 +2249,8 @@ non-nil if entry has a deadline." (org-ql-defpred deadline-warning (&key from to) ;; TODO: Should this also accept a WITH-TIME argument? ;; MAYBE: Use the new org-ql-regexps? - "Internal predicate used to handle `org-deadline-warning-days' and deadlines with warning periods." + "Internal predicate. +Used to handle `org-deadline-warning-days' and deadlines with warning periods." :preambles ((`(,predicate-names . ,_) (list :regexp org-deadline-time-regexp :query query))) :body From d21da3682bc74195569164f06d4cb5cb2276b42e Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 03:23:42 -0600 Subject: [PATCH 14/72] Tidy: Compilation warnings --- README.org | 1 + helm-org-ql.el | 2 ++ org-ql-completing-read.el | 1 + org-ql-find.el | 2 +- org-ql-search.el | 16 +++++++++-- org-ql-view.el | 7 +++-- org-ql.el | 21 +++++++------- org-ql.info | 59 ++++++++++++++++++++------------------- tests/test-org-ql.el | 6 +++- 9 files changed, 68 insertions(+), 47 deletions(-) diff --git a/README.org b/README.org index 3e57404..7b66d34 100644 --- a/README.org +++ b/README.org @@ -559,6 +559,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixed* + Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.) + Predicate ~src~'s behavior with various arguments. ++ Various compilation warnings. *Internal* + Certain query predicates, when called multiple times in an ~and~ sub-expression, are optimized to a single call. diff --git a/helm-org-ql.el b/helm-org-ql.el index 02eff9a..5d460a5 100644 --- a/helm-org-ql.el +++ b/helm-org-ql.el @@ -98,6 +98,8 @@ Based on `helm-map'.") Interactively, search the current buffer. Note that this command only accepts non-sexp, \"plain\" queries. +NAME is passed to `helm-org-ql-source', which see. + NOTE: Atoms in the query are turned into strings where appropriate, which makes it unnecessary to type quotation marks around words that are intended to be searched for as indepenent diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 81d8557..b1ef11a 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -81,6 +81,7 @@ For an experience like `org-rifle', use a newline." (cl-defun org-ql-completing-read (buffers-files &key query-prefix query-filter (prompt "Find entry: ")) "Return marker at Org entry in BUFFERS-FILES selected with `org-ql'. +PROMPT is shown to the user. QUERY-PREFIX may be a string to prepend to the query entered by the user (e.g. use \"heading:\" to only search headings, easily diff --git a/org-ql-find.el b/org-ql-find.el index d9ccad9..9483c61 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -55,7 +55,7 @@ See function `display-buffer'." (prompt "Find entry: ")) "Go to an Org entry in BUFFERS-FILES selected by searching entries with `org-ql'. Interactively, with universal prefix, select multiple buffers to -search with completion. +search with completion and PROMPT. QUERY-PREFIX may be a string to prepend to the query (e.g. use \"heading:\" to only search headings, easily creating a custom diff --git a/org-ql-search.el b/org-ql-search.el index 1d47be3..f2fd953 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -47,6 +47,18 @@ (t (warn "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. This may affect links in dynamic blocks. Please report this as a bug.") #'identity))) +(defalias 'org-ql-search--org-make-link-string + (cond ((fboundp 'org-link-make-string) #'org-link-make-string) + ((fboundp 'org-make-link-string) #'org-make-link-string) + (t (warn "org-ql: Unable to define alias `org-ql-search--org-make-link-string'. Please report this as a bug.") + #'identity))) + +(defalias 'org-ql-search--org-link-store-props + (cond ((fboundp 'org-link-store-props) #'org-link-store-props) + ((fboundp 'org-store-link-props) #'org-store-link-props) + (t (warn "org-ql: Unable to define alias `org-ql-search--org-link-store-props'. Please report this as a bug.") + #'identity))) + ;;;; Variables (defvar org-ql-block-header nil @@ -138,7 +150,7 @@ SUPER-GROUPS: An `org-super-agenda' group set. See variable selectors'. NARROW: When non-nil, don't widen buffers before -searching. Interactively, with prefix, leave narrowed. +searching. Interactively, with prefix, leave narrowed. SORT: One or a list of `org-ql' sorting functions, like `date' or `priority' (see Info node `(org-ql)Listing / acting-on results'). @@ -299,7 +311,7 @@ this (must be a single line in the Org buffer): (cons 'heading (lambda (element) (let ((normalized-heading (org-ql-search--link-heading-search-string (org-element-property :raw-value element)))) - (org-make-link-string normalized-heading (org-link-display-format normalized-heading))))) + (org-ql-search--org-make-link-string normalized-heading (org-link-display-format normalized-heading))))) (cons 'priority (lambda (element) (--when-let (org-element-property :priority element) (char-to-string it)))) diff --git a/org-ql-view.el b/org-ql-view.el index 95dfe3b..5a03b80 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -44,6 +44,7 @@ ;; clearly is. It seems to not handle cl-defun, even though its code ;; appears to account for it. (declare-function org-ql-search "org-ql-search" t) +(declare-function org-ql-search--org-link-store-props "org-ql-search" t) (require 'dash) (require 's) @@ -288,7 +289,8 @@ TYPE may be `ts', `ts-active', `ts-inactive', `clocked', or ;;;###autoload (cl-defun org-ql-view-sidebar (&key (slot org-ql-view-list-slot)) - "Show `org-ql-view' view list sidebar." + "Show `org-ql-view' view list sidebar. +SLOT is passed to `display-buffer-in-side-window', which see." ;; TODO: Update sidebar when `org-ql-views' changes. (interactive) (select-window @@ -688,8 +690,7 @@ When opened, the link searches the buffer it's opened from." "?" (url-build-query-string (delete nil params)))) (url (url-recreate-url (url-parse-make-urlobj "org-ql-search" nil nil nil nil filename)))) - ;; FIXME: "Warning: ‘org-store-link-props’ is an obsolete function (as of Org 9.3); use ‘org-link-store-props’ instead" - (org-store-link-props + (org-ql-search--org-link-store-props :type "org-ql-search" :link url :description (concat "org-ql-search: " org-ql-view-title)))) diff --git a/org-ql.el b/org-ql.el index 22fa86f..9bb05fd 100644 --- a/org-ql.el +++ b/org-ql.el @@ -75,10 +75,10 @@ That is, \"CLOSED:\", \"DEADLINE:\", or \"SCHEDULED:\".") Tags are stored in match group 1. Match group 2 stores the tags without the enclosing colons.") -(defconst org-ql-link-regexp +(defvaralias 'org-ql-link-regexp (if (bound-and-true-p org-link-bracket-re) - org-link-bracket-re - org-bracket-link-regexp) + 'org-link-bracket-re + 'org-bracket-link-regexp) "Regexp used to match Org bracket links. Necessary because of changes in Org 9.something.") @@ -1347,18 +1347,17 @@ result form." ;; NOTE: This was a defsubst before being defined with the macro. Might be good to make it a defsubst again. :body (or (apply #'org-ql--predicate-todo org-done-keywords))) -(defun org-ql--duration-to-minutes (duration) +(defalias 'org-ql--duration-to-minutes + ;; TODO: Remove when compatibility with Org 9.0 is dropped. + (cond ((fboundp 'org-duration-to-minutes) #'org-duration-to-minutes) + ((fboundp 'org-duration-string-to-minutes) #'org-duration-string-to-minutes) + (t (warn "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. Please report this as a bug.") + #'identity)) "Return DURATION string as a number of minutes. For compatibility, since Org 9.1 deprecated `org-duration-string-to-minutes', replacing it with `org-duration-to-minutes', which seems to return floats instead -of integers." - ;; FIXME: Define this as an alias instead. - ;; MAYBE: Remove if compatibility with Org 9.0 is dropped. - (funcall (if (fboundp 'org-duration-to-minutes) - #'org-duration-to-minutes - #'org-duration-string-to-minutes) - duration)) +of integers.") (org-ql-defpred effort (&optional effort-or-comparator effort) "Return non-nil if current heading's effort property matches arguments. diff --git a/org-ql.info b/org-ql.info index caee1f6..6857239 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1052,6 +1052,7 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog of arguments, and handling in non-sexp queries. (Thanks to Akira Komamura (https://github.com/akirak) for reporting.) • Predicate ‘src’’s behavior with various arguments. + • Various compilation warnings. *Internal* • Certain query predicates, when called multiple times in an ‘and’ @@ -1727,35 +1728,35 @@ Node: Links37140 Node: Tips37827 Node: Changelog38151 Node: 07-pre38934 -Node: 06341399 -Node: 06241934 -Node: 06142239 -Node: 0642807 -Node: 05245861 -Node: 05146161 -Node: 0546584 -Node: 04948113 -Node: 04848393 -Node: 04748742 -Node: 04649151 -Node: 04549559 -Node: 04449920 -Node: 04350279 -Node: 04250482 -Node: 04150643 -Node: 0450890 -Node: 03254991 -Node: 03155394 -Node: 0355591 -Node: 02358891 -Node: 02259125 -Node: 02159405 -Node: 0259610 -Node: 0163688 -Node: Notes63789 -Node: Comparison with Org Agenda searches63951 -Node: org-sidebar64840 -Node: License65119 +Node: 06341436 +Node: 06241971 +Node: 06142276 +Node: 0642844 +Node: 05245898 +Node: 05146198 +Node: 0546621 +Node: 04948150 +Node: 04848430 +Node: 04748779 +Node: 04649188 +Node: 04549596 +Node: 04449957 +Node: 04350316 +Node: 04250519 +Node: 04150680 +Node: 0450927 +Node: 03255028 +Node: 03155431 +Node: 0355628 +Node: 02358928 +Node: 02259162 +Node: 02159442 +Node: 0259647 +Node: 0163725 +Node: Notes63826 +Node: Comparison with Org Agenda searches63988 +Node: org-sidebar64877 +Node: License65156  End Tag Table diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index c884971..3af3537 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -30,6 +30,7 @@ (require 'with-simulated-input) (require 'org-ql) +(require 'org-ql-search) (require 'org-ql-view) ;;;; Variables @@ -200,7 +201,10 @@ with keyword arg NOW in PLIST." (insert "* Heading 1") ;; FIXME: `--value-at' does not actually move point, so we do it here. (goto-char (point-min)) - (expect (org-ql--value-at (point-min) #'org-get-local-tags) + (expect (org-ql--value-at (point-min) + ;; TODO: Just use org-get-tags when requiring Org 9.2+. + (cond ((fboundp 'org-get-tags) #'org-get-tags) + ((fboundp 'org-get-local-tags) #'org-get-local-tags))) :to-be nil)))) (describe "Query pre-processing" From e5e9daab0757b485df14e10fc52c2ace2c1abd3b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 03:37:52 -0600 Subject: [PATCH 15/72] Fix: Aliases One of them seems to break on Emacs 26.3 only... --- org-ql-search.el | 9 +++------ org-ql.el | 3 +-- tests/test-org-ql.el | 5 +---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index f2fd953..cedcadb 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -44,20 +44,17 @@ (cond ((fboundp 'org-link--normalize-string) #'org-link--normalize-string) ((fboundp 'org-link-heading-search-string) #'org-link-heading-search-string) ((fboundp 'org-make-org-heading-search-string) #'org-make-org-heading-search-string) - (t (warn "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. This may affect links in dynamic blocks. Please report this as a bug.") - #'identity))) + (t (error "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. This may affect links in dynamic blocks. Please report this as a bug")))) (defalias 'org-ql-search--org-make-link-string (cond ((fboundp 'org-link-make-string) #'org-link-make-string) ((fboundp 'org-make-link-string) #'org-make-link-string) - (t (warn "org-ql: Unable to define alias `org-ql-search--org-make-link-string'. Please report this as a bug.") - #'identity))) + (t (error "org-ql: Unable to define alias `org-ql-search--org-make-link-string'. Please report this as a bug")))) (defalias 'org-ql-search--org-link-store-props (cond ((fboundp 'org-link-store-props) #'org-link-store-props) ((fboundp 'org-store-link-props) #'org-store-link-props) - (t (warn "org-ql: Unable to define alias `org-ql-search--org-link-store-props'. Please report this as a bug.") - #'identity))) + (t (error "org-ql: Unable to define alias `org-ql-search--org-link-store-props'. Please report this as a bug")))) ;;;; Variables diff --git a/org-ql.el b/org-ql.el index 9bb05fd..3c70b34 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1351,8 +1351,7 @@ result form." ;; TODO: Remove when compatibility with Org 9.0 is dropped. (cond ((fboundp 'org-duration-to-minutes) #'org-duration-to-minutes) ((fboundp 'org-duration-string-to-minutes) #'org-duration-string-to-minutes) - (t (warn "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. Please report this as a bug.") - #'identity)) + (t (error "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. Please report this as a bug"))) "Return DURATION string as a number of minutes. For compatibility, since Org 9.1 deprecated `org-duration-string-to-minutes', replacing it with diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 3af3537..e6fc909 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -201,10 +201,7 @@ with keyword arg NOW in PLIST." (insert "* Heading 1") ;; FIXME: `--value-at' does not actually move point, so we do it here. (goto-char (point-min)) - (expect (org-ql--value-at (point-min) - ;; TODO: Just use org-get-tags when requiring Org 9.2+. - (cond ((fboundp 'org-get-tags) #'org-get-tags) - ((fboundp 'org-get-local-tags) #'org-get-local-tags))) + (expect (org-ql--value-at (point-min) #'ignore) :to-be nil)))) (describe "Query pre-processing" From 6afe3be5721d6625eac5bc7c900d88d4ce1387c8 Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Wed, 28 Jul 2021 17:31:29 +0900 Subject: [PATCH 16/72] Add: (blocked) predicate --- README.org | 1 + org-ql.el | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.org b/README.org index 7b66d34..9127889 100644 --- a/README.org +++ b/README.org @@ -254,6 +254,7 @@ Arguments are listed next to predicate names, where applicable. + =tags-regexp (&rest regexps)= :: Return non-nil if current heading has tags matching one or more of ~REGEXPS~. Tests both inherited and local tags. - Aliases: ~tags*~. + =todo (&optional keywords)= :: Return non-nil if current heading is a ~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~). ++ =blocked= :: Return non-nil if current heading is blocked. *** Ancestor/descendant predicates diff --git a/org-ql.el b/org-ql.el index 3c70b34..87a090c 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2377,6 +2377,11 @@ any planning prefix); it defaults to 0 (i.e. the whole regexp)." (from (test-timestamps (ts<= from next-ts))) (to (test-timestamps (ts<= next-ts to))))))) +(org-ql-defpred blocked () + "Return non-nil if the entry is blocked." + :body + (org-entry-blocked-p)) + ;; NOTE: Predicates defined: stop deferring and define normalizer and ;; preamble functions now. Reversing preserves the order in which ;; they were defined. Generally it shouldn't matter, but it might... From 902dad04c10e9215db3c49e33abb30b21e41f44e Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 03:36:21 -0600 Subject: [PATCH 17/72] Docs/Tidy: Update readme, reorder forms --- README.org | 3 +- org-ql.el | 10 +++--- org-ql.info | 97 ++++++++++++++++++++++++++++------------------------- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/README.org b/README.org index 9127889..e19b3d6 100644 --- a/README.org +++ b/README.org @@ -221,6 +221,7 @@ Note that the =effort=, =level=, and =priority= predicates do not support compar Arguments are listed next to predicate names, where applicable. ++ =blocked= :: Return non-nil if current heading is blocked. Calls ~org-entry-blocked-p~, which see. + =category (&optional categories)= :: Return non-nil if current heading is in one or more of ~CATEGORIES~ (a list of strings). + =done= :: Return non-nil if entry's ~TODO~ keyword is in ~org-done-keywords~. + =effort (&optional effort-or-comparator effort)= :: Return non-nil if current heading's effort property matches arguments. The following forms are accepted: ~(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=. @@ -254,7 +255,6 @@ Arguments are listed next to predicate names, where applicable. + =tags-regexp (&rest regexps)= :: Return non-nil if current heading has tags matching one or more of ~REGEXPS~. Tests both inherited and local tags. - Aliases: ~tags*~. + =todo (&optional keywords)= :: Return non-nil if current heading is a ~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~). -+ =blocked= :: Return non-nil if current heading is blocked. *** Ancestor/descendant predicates @@ -552,6 +552,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized). + Alias ~c~ for predicate ~category~. + Predicate ~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. ++ Predicate ~blocked~. (Thanks to [[https://github.com/akirak][Akira Komamura]].) *Changed* + Give more useful error message for invalid queries. diff --git a/org-ql.el b/org-ql.el index 87a090c..acfe8c0 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1333,6 +1333,11 @@ result form." ;; redefinitions until all of the predicates have been defined. (setf org-ql-defpred-defer t) +(org-ql-defpred blocked () + "Return non-nil if entry is blocked. +Calls `org-entry-blocked-p', which see." + :body (org-entry-blocked-p)) + (org-ql-defpred (category c) (&rest categories) "Return non-nil if current heading is in one or more of CATEGORIES." :normalizers ((`(,predicate-names . ,rest) @@ -2377,11 +2382,6 @@ any planning prefix); it defaults to 0 (i.e. the whole regexp)." (from (test-timestamps (ts<= from next-ts))) (to (test-timestamps (ts<= next-ts to))))))) -(org-ql-defpred blocked () - "Return non-nil if the entry is blocked." - :body - (org-entry-blocked-p)) - ;; NOTE: Predicates defined: stop deferring and define normalizer and ;; preamble functions now. Reversing preserves the order in which ;; they were defined. Generally it shouldn't matter, but it might... diff --git a/org-ql.info b/org-ql.info index 6857239..ec95d26 100644 --- a/org-ql.info +++ b/org-ql.info @@ -415,6 +415,9 @@ File: README.info, Node: General predicates, Next: Ancestor/descendant predica Arguments are listed next to predicate names, where applicable. +‘blocked’ + Return non-nil if current heading is blocked. Calls + ‘org-entry-blocked-p’, which see. ‘category (&optional categories)’ Return non-nil if current heading is in one or more of ‘CATEGORIES’ (a list of strings). @@ -1042,6 +1045,8 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog entries with property inheritance, and when unspecified, the option ‘org-use-property-inheritance’ controls whether inheritance is used. + • Predicate ‘blocked’. (Thanks to Akira Komamura + (https://github.com/akirak).) *Changed* • Give more useful error message for invalid queries. @@ -1711,52 +1716,52 @@ Node: org-ql-sparse-tree8594 Node: Queries9394 Node: Non-sexp query syntax10511 Node: General predicates12270 -Node: Ancestor/descendant predicates19142 -Node: Date/time predicates20270 -Node: Functions / Macros23394 -Node: Agenda-like views23692 -Ref: Function ‘org-ql-block’23854 -Node: Listing / acting-on results25115 -Ref: Caching25323 -Ref: Function ‘org-ql-select’26236 -Ref: Function ‘org-ql-query’28662 -Ref: Macro ‘org-ql’ (deprecated)30436 -Node: Custom predicates30751 -Ref: Macro ‘org-ql-defpred’30975 -Node: Dynamic block34416 -Node: Links37140 -Node: Tips37827 -Node: Changelog38151 -Node: 07-pre38934 -Node: 06341436 -Node: 06241971 -Node: 06142276 -Node: 0642844 -Node: 05245898 -Node: 05146198 -Node: 0546621 -Node: 04948150 -Node: 04848430 -Node: 04748779 -Node: 04649188 -Node: 04549596 -Node: 04449957 -Node: 04350316 -Node: 04250519 -Node: 04150680 -Node: 0450927 -Node: 03255028 -Node: 03155431 -Node: 0355628 -Node: 02358928 -Node: 02259162 -Node: 02159442 -Node: 0259647 -Node: 0163725 -Node: Notes63826 -Node: Comparison with Org Agenda searches63988 -Node: org-sidebar64877 -Node: License65156 +Node: Ancestor/descendant predicates19257 +Node: Date/time predicates20385 +Node: Functions / Macros23509 +Node: Agenda-like views23807 +Ref: Function ‘org-ql-block’23969 +Node: Listing / acting-on results25230 +Ref: Caching25438 +Ref: Function ‘org-ql-select’26351 +Ref: Function ‘org-ql-query’28777 +Ref: Macro ‘org-ql’ (deprecated)30551 +Node: Custom predicates30866 +Ref: Macro ‘org-ql-defpred’31090 +Node: Dynamic block34531 +Node: Links37255 +Node: Tips37942 +Node: Changelog38266 +Node: 07-pre39049 +Node: 06341645 +Node: 06242180 +Node: 06142485 +Node: 0643053 +Node: 05246107 +Node: 05146407 +Node: 0546830 +Node: 04948359 +Node: 04848639 +Node: 04748988 +Node: 04649397 +Node: 04549805 +Node: 04450166 +Node: 04350525 +Node: 04250728 +Node: 04150889 +Node: 0451136 +Node: 03255237 +Node: 03155640 +Node: 0355837 +Node: 02359137 +Node: 02259371 +Node: 02159651 +Node: 0259856 +Node: 0163934 +Node: Notes64035 +Node: Comparison with Org Agenda searches64197 +Node: org-sidebar65086 +Node: License65365  End Tag Table From 2b7d4e0e79260b5caa9cf978ee80edf03c7c981d Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Tue, 22 Mar 2022 17:59:01 +0900 Subject: [PATCH 18/72] Fix: Accept plain queries in interactive org-ql-sparse-tree --- org-ql-search.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index cedcadb..b442b38 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -102,7 +102,7 @@ matches, which allows stacking calls to this command. Runs `org-occur-hook' after making the sparse tree." ;; Code based on `org-occur'. - (interactive (list (read-minibuffer "Query: ") + (interactive (list (read-string "Query: ") :keep-previous current-prefix-arg)) (with-current-buffer buffer (unless keep-previous @@ -110,7 +110,15 @@ Runs `org-occur-hook' after making the sparse tree." ;; we remove existing `org-occur' highlights, just in case. (org-remove-occur-highlights nil nil t) (org-overview)) - (let ((num-results 0)) + (let ((num-results 0) + (query (cl-etypecase query + (string (if (or (string-prefix-p "(" query) + (string-prefix-p "\"" query)) + ;; Read sexp query. + (read query) + ;; Parse non-sexp query into sexp query. + (org-ql--query-string-to-sexp query))) + (list query)))) ;; FIXME: Accept plain queries as well. (org-ql-select buffer query :action (lambda () From 1ae2f0cd60974e85b204cd1bd255aa39b253473f Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Tue, 22 Mar 2022 18:08:13 +0900 Subject: [PATCH 19/72] Update the docstring --- org-ql-search.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index b442b38..efd9aa7 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -93,8 +93,8 @@ directories, etc, which would make it slow to list the 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. +QUERY: An `org-ql' query in either sexp or non-sexp form (see +Info node `(org-ql)Queries'). When KEEP-PREVIOUS is non-nil (interactively, with prefix), the outline is not reset to the overview state before finding From 99e580b53077ff1de26009de2c56dc5870dd3b19 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 04:44:05 -0600 Subject: [PATCH 20/72] Tidy: (org-ql-sparse-tree) Docstring; use pcase --- org-ql-search.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index efd9aa7..e0ab3ff 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -93,7 +93,7 @@ directories, etc, which would make it slow to list the The tree will show the lines where the query matches, and any other context defined in `org-show-context-detail', which see. -QUERY: An `org-ql' query in either sexp or non-sexp form (see +QUERY is an `org-ql' query in either sexp or string form (see Info node `(org-ql)Queries'). When KEEP-PREVIOUS is non-nil (interactively, with prefix), the @@ -111,14 +111,17 @@ Runs `org-occur-hook' after making the sparse tree." (org-remove-occur-highlights nil nil t) (org-overview)) (let ((num-results 0) - (query (cl-etypecase query - (string (if (or (string-prefix-p "(" query) - (string-prefix-p "\"" query)) - ;; Read sexp query. - (read query) - ;; Parse non-sexp query into sexp query. - (org-ql--query-string-to-sexp query))) - (list query)))) + (query (pcase-exhaustive query + ((and (pred stringp) + (rx bos (0+ blank) (or "(" "\""))) + ;; Read sexp query from string. + (read query)) + ((pred stringp) + ;; Parse string query into sexp query. + (org-ql--query-string-to-sexp query)) + ((pred listp) + ;; Sexp query. + query)))) ;; FIXME: Accept plain queries as well. (org-ql-select buffer query :action (lambda () From d92afcda062b2953b148b0507f8137d6bfbad862 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 04:46:32 -0600 Subject: [PATCH 21/72] Docs: Update changelog --- README.org | 1 + org-ql.info | 60 +++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/README.org b/README.org index e19b3d6..2845805 100644 --- a/README.org +++ b/README.org @@ -557,6 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Changed* + Give more useful error message for invalid queries. + Predicate ~src~ now matches case-insensitively. ++ Command ~org-ql-sparse-tree~ accepts both string and sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]].) *Fixed* + Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.) diff --git a/org-ql.info b/org-ql.info index ec95d26..08900a2 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1051,6 +1051,8 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog *Changed* • Give more useful error message for invalid queries. • Predicate ‘src’ now matches case-insensitively. + • Command ‘org-ql-sparse-tree’ accepts both string and sexp queries. + (Thanks to Akira Komamura (https://github.com/akirak).) *Fixed* • Predicate ‘src’’s matching of begin/end block lines, normalization @@ -1733,35 +1735,35 @@ Node: Links37255 Node: Tips37942 Node: Changelog38266 Node: 07-pre39049 -Node: 06341645 -Node: 06242180 -Node: 06142485 -Node: 0643053 -Node: 05246107 -Node: 05146407 -Node: 0546830 -Node: 04948359 -Node: 04848639 -Node: 04748988 -Node: 04649397 -Node: 04549805 -Node: 04450166 -Node: 04350525 -Node: 04250728 -Node: 04150889 -Node: 0451136 -Node: 03255237 -Node: 03155640 -Node: 0355837 -Node: 02359137 -Node: 02259371 -Node: 02159651 -Node: 0259856 -Node: 0163934 -Node: Notes64035 -Node: Comparison with Org Agenda searches64197 -Node: org-sidebar65086 -Node: License65365 +Node: 06341784 +Node: 06242319 +Node: 06142624 +Node: 0643192 +Node: 05246246 +Node: 05146546 +Node: 0546969 +Node: 04948498 +Node: 04848778 +Node: 04749127 +Node: 04649536 +Node: 04549944 +Node: 04450305 +Node: 04350664 +Node: 04250867 +Node: 04151028 +Node: 0451275 +Node: 03255376 +Node: 03155779 +Node: 0355976 +Node: 02359276 +Node: 02259510 +Node: 02159790 +Node: 0259995 +Node: 0164073 +Node: Notes64174 +Node: Comparison with Org Agenda searches64336 +Node: org-sidebar65225 +Node: License65504  End Tag Table From 9e14f9eefaba4dbfc28382dee306cade11c49189 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 05:52:06 -0600 Subject: [PATCH 22/72] Fix: (link) Allow brackets in description Org 9.3 stopped replacing brackets in link descriptions with braces and started escaping them instead. Fixes #283. Thanks to Daniel Borchmann (@exot) for reporting. --- README.org | 1 + org-ql.el | 77 ++++++++++++++++++++++---------------------- org-ql.info | 61 ++++++++++++++++++----------------- tests/data-links.org | 10 ++++++ tests/test-org-ql.el | 34 ++++++++++++++++++- 5 files changed, 115 insertions(+), 68 deletions(-) create mode 100644 tests/data-links.org diff --git a/README.org b/README.org index 2845805..0715680 100644 --- a/README.org +++ b/README.org @@ -560,6 +560,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Command ~org-ql-sparse-tree~ accepts both string and sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]].) *Fixed* ++ Predicate ~link~ matches links whose descriptions contain escaped brackets (changed in Org 9.3). (Thanks to [[https://github.com/exot][Daniel Borchmann]] for reporting.) + Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.) + Predicate ~src~'s behavior with various arguments. + Various compilation warnings. diff --git a/org-ql.el b/org-ql.el index acfe8c0..a471f4e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -794,38 +794,43 @@ DESCRIPTION-OR-TARGET, match it in either description or target. If DESCRIPTION, match it in the description. If TARGET, match it in the target. If both DESCRIPTION and TARGET, match both, respectively." - (cl-labels - ((no-desc - (match) (rx-to-string `(seq (or bol (1+ blank)) - "[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]"))) - "]]"))) - (match-both - (description target) - (rx-to-string `(seq (or bol (1+ blank)) - "[[" (0+ (not (any "]"))) (regexp ,target) (0+ (not (any "]"))) - "][" (0+ (not (any "]"))) (regexp ,description) (0+ (not (any "]"))) - "]]"))) - ;; Note that these actually allow empty descriptions - ;; or targets, depending on what they are matching. - (match-desc - (match) (rx-to-string `(seq (or bol (1+ blank)) - "[[" (0+ (not (any "]"))) - "][" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]"))) - "]]"))) - (match-target - (match) (rx-to-string `(seq (or bol (1+ blank)) - "[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]"))) - "][" (0+ (not (any "]"))) - "]]")))) - (cond (description-or-target - (rx-to-string `(or (regexp ,(no-desc description-or-target)) - (regexp ,(match-desc description-or-target)) - (regexp ,(match-target description-or-target))))) - ((and description target) - (match-both description target)) - (description (match-desc description)) - (target (rx-to-string `(or (regexp ,(no-desc target)) - (regexp ,(match-target target)))))))) + ;; This `rx' part is borrowed from `org-make-link-regexps'. It matches the interior of an + ;; Org link target (i.e. the parts between the brackets, including any escaped brackets). + (let ((link-target-part '(0+ (or (not (any "[]\\")) + (and "\\" (0+ "\\\\") (any "[]")) + (and (1+ "\\") (not (any "[]"))))))) + (cl-labels + ((no-desc + (match) (rx-to-string `(seq (or bol (1+ blank)) + "[[" ,link-target-part (regexp ,match) ,link-target-part + "]]"))) + (match-both + (description target) + (rx-to-string `(seq (or bol (1+ blank)) + "[[" ,link-target-part (regexp ,target) ,link-target-part + "][" (*? anything) (regexp ,description) (*? anything) + "]]"))) + ;; Note that these actually allow empty descriptions + ;; or targets, depending on what they are matching. + (match-desc + (match) (rx-to-string `(seq (or bol (1+ blank)) + "[[" ,link-target-part + "][" (*? anything) (regexp ,match) (*? anything) + "]]"))) + (match-target + (match) (rx-to-string `(seq (or bol (1+ blank)) + "[[" ,link-target-part (regexp ,match) ,link-target-part + "][" (*? anything) + "]]")))) + (cond (description-or-target + (rx-to-string `(or (regexp ,(no-desc description-or-target)) + (regexp ,(match-desc description-or-target)) + (regexp ,(match-target description-or-target))))) + ((and description target) + (match-both description target)) + (description (match-desc description)) + (target (rx-to-string `(or (regexp ,(no-desc target)) + (regexp ,(match-target target))))))))) (defun org-ql--format-src-block-regexp (&optional lang) "Return regexp equivalent to `org-babel-src-block-regexp' with LANG filled in." @@ -1563,12 +1568,8 @@ any link is found." ;; enabled nearly all of the time, in which case this function won't be called anyway, it's ;; probably not worth rewriting code all over the place to fix this. :preambles ((`(,predicate-names) - (list :regexp ;; Match a link with a target and optionally a description. - (rx (or bol (1+ blank)) - "[[" (1+ (not (any "]"))) "]" - (optional (seq "[" (0+ (not (any "]"))) "]")) - "]" - (or eol blank)))) + ;; Match a link with a target and optionally a description. + (list :regexp (org-ql--link-regexp :target ".*"))) (`(,predicate-names ,(and description-or-target (guard (not (keywordp description-or-target)))) . ,plist) diff --git a/org-ql.info b/org-ql.info index 08900a2..ce8d981 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1055,6 +1055,9 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog (Thanks to Akira Komamura (https://github.com/akirak).) *Fixed* + • Predicate ‘link’ matches links whose descriptions contain escaped + brackets (changed in Org 9.3). (Thanks to Daniel Borchmann + (https://github.com/exot) for reporting.) • Predicate ‘src’’s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to Akira Komamura (https://github.com/akirak) for reporting.) @@ -1735,35 +1738,35 @@ Node: Links37255 Node: Tips37942 Node: Changelog38266 Node: 07-pre39049 -Node: 06341784 -Node: 06242319 -Node: 06142624 -Node: 0643192 -Node: 05246246 -Node: 05146546 -Node: 0546969 -Node: 04948498 -Node: 04848778 -Node: 04749127 -Node: 04649536 -Node: 04549944 -Node: 04450305 -Node: 04350664 -Node: 04250867 -Node: 04151028 -Node: 0451275 -Node: 03255376 -Node: 03155779 -Node: 0355976 -Node: 02359276 -Node: 02259510 -Node: 02159790 -Node: 0259995 -Node: 0164073 -Node: Notes64174 -Node: Comparison with Org Agenda searches64336 -Node: org-sidebar65225 -Node: License65504 +Node: 06341973 +Node: 06242508 +Node: 06142813 +Node: 0643381 +Node: 05246435 +Node: 05146735 +Node: 0547158 +Node: 04948687 +Node: 04848967 +Node: 04749316 +Node: 04649725 +Node: 04550133 +Node: 04450494 +Node: 04350853 +Node: 04251056 +Node: 04151217 +Node: 0451464 +Node: 03255565 +Node: 03155968 +Node: 0356165 +Node: 02359465 +Node: 02259699 +Node: 02159979 +Node: 0260184 +Node: 0164262 +Node: Notes64363 +Node: Comparison with Org Agenda searches64525 +Node: org-sidebar65414 +Node: License65693  End Tag Table diff --git a/tests/data-links.org b/tests/data-links.org new file mode 100644 index 0000000..b158951 --- /dev/null +++ b/tests/data-links.org @@ -0,0 +1,10 @@ +* Alpha + +Let us link to: [[id:74d357ac-fb9c-40d1-a63f-eca8a227321d][Bravo [a phrase in brackets]​]]. + +* Bravo [a phrase in brackets] +:PROPERTIES: +:ID: 74d357ac-fb9c-40d1-a63f-eca8a227321d +:END: + +* Charlie diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index e6fc909..4e78f3a 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1141,7 +1141,39 @@ with keyword arg NOW in PLIST." '("/r/emacs"))) (org-ql-it "with :description and :target regexp" (org-ql-expect ('(link :description "em.cs" :target "em.cs" :regexp-p t)) - '("/r/emacs")))) + '("/r/emacs"))) + + (describe "matches links whose descriptions contain brackets" + (before-each + (setq org-ql-test-buffer (org-ql-test-data-buffer "data-links.org"))) + + (org-ql-it "without arguments" + (org-ql-expect ('(link)) + '("Alpha"))) + (org-ql-it "with description-or-target" + (org-ql-expect ('(link "phrase")) + '("Alpha"))) + (org-ql-it "with :description" + (org-ql-expect ('(link :description "phrase")) + '("Alpha"))) + (org-ql-it "with :target" + (org-ql-expect ('(link :target "id:")) + '("Alpha"))) + (org-ql-it "with :description and :target" + (org-ql-expect ('(link :description "phrase" :target "id")) + '("Alpha"))) + (org-ql-it "with description-or-target regexp" + (org-ql-expect ('(link "id:.*" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :description regexp" + (org-ql-expect ('(link :description "phr.se" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :target regexp" + (org-ql-expect ('(link :target "id:.*" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :description and :target regexp" + (org-ql-expect ('(link :description "phr.se" :target "id:.*" :regexp-p t)) + '("Alpha"))))) (describe "(outline-path)" (org-ql-it "with one argument" From 962a3dc4142d19aa75a618457986e1d6ddf7a695 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 06:19:01 -0600 Subject: [PATCH 23/72] Comment: Remove old FIXME See 3c73888b981b32c20dcaaa6739619b1465deddbd. --- org-ql-search.el | 1 - 1 file changed, 1 deletion(-) diff --git a/org-ql-search.el b/org-ql-search.el index e0ab3ff..b029544 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -122,7 +122,6 @@ Runs `org-occur-hook' after making the sparse tree." ((pred listp) ;; Sexp query. query)))) - ;; FIXME: Accept plain queries as well. (org-ql-select buffer query :action (lambda () (org-show-context 'occur-tree) From 44679a6c93a2207eee9f1e835b75a5be33a4aebb Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 06:23:53 -0600 Subject: [PATCH 24/72] Comment: Remove old FIXMEs --- org-ql-view.el | 7 ------- 1 file changed, 7 deletions(-) diff --git a/org-ql-view.el b/org-ql-view.el index 5a03b80..72a057b 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -40,9 +40,6 @@ (require 'org-ql) -;; FIXME: check-declare declares "function not found", even though it -;; clearly is. It seems to not handle cl-defun, even though its code -;; appears to account for it. (declare-function org-ql-search "org-ql-search" t) (declare-function org-ql-search--org-link-store-props "org-ql-search" t) @@ -1014,10 +1011,6 @@ property." ;; These functions are somewhat regrettable because of the need to keep them ;; in sync, but it seems worth it to provide users with the flexibility. -;; FIXME: `check-declare' declares that this function is not in org-ql-search, even though -;; it is. It appears to happen because `org-ql-search-directories-files' is declared with -;; `cl-defun', because when I remove "cl-", it finds it. This makes no sense, because the -;; source code of `check-declare' shows that it searches for "cl-defun" declarations. (declare-function org-ql-search-directories-files "org-ql-search" t) (defun org-ql-view--contract-buffers-files (buffers-files) From 107fc66d08ea7afbe150a9b76a607b3a5981b383 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 06:24:03 -0600 Subject: [PATCH 25/72] Change: (org-ql-view--format-element) Use display-warning --- org-ql-view.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/org-ql-view.el b/org-ql-view.el index 72a057b..d771d12 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -864,8 +864,7 @@ return an empty string." (not type)) append type))) ;; No marker found - ;; TODO: Use `display-warning' with `org-ql' as the type. - (warn "No marker found for item: %s" title) + (display-warning 'org-ql (format "No marker found for item: %s" title)) (org-element-property :tags element)) (org-element-property :tags element))) (tag-string (when tag-list From aadddc4d84a72fa80d3bf909c9a3a4cbce53cd93 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 06:25:45 -0600 Subject: [PATCH 26/72] Release: v0.7 --- README.org | 2 +- org-ql.el | 2 +- org-ql.info | 140 ++++++++++++++++++++++++++-------------------------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/README.org b/README.org index 0715680..637a13d 100644 --- a/README.org +++ b/README.org @@ -543,7 +543,7 @@ 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. -** 0.7-pre +** 0.7 *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.). diff --git a/org-ql.el b/org-ql.el index a471f4e..3b72ff0 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7-pre +;; Version: 0.7 ;; 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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index ce8d981..e0c6191 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,7 +71,7 @@ Functions / Macros Changelog -* 0.7-pre: 07-pre. +* 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. * 0.6.1: 061. @@ -990,7 +990,7 @@ releases. * Menu: -* 0.7-pre: 07-pre. +* 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. * 0.6.1: 061. @@ -1018,10 +1018,10 @@ releases. * 0.1: 01.  -File: README.info, Node: 07-pre, Next: 063, Up: Changelog +File: README.info, Node: 07, Next: 063, Up: Changelog -5.1 0.7-pre -=========== +5.1 0.7 +======= *Added* • Commands ‘org-ql-find’, ‘org-ql-find-heading’, and @@ -1078,7 +1078,7 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog (https://github.com/alphapapa/org-ql/commit/91908186fcca4b5fd2e9d26da5bc0375c2b41acf).  -File: README.info, Node: 063, Next: 062, Prev: 07-pre, Up: Changelog +File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog 5.2 0.6.3 ========= @@ -1703,70 +1703,70 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1797 -Node: Screenshots1920 -Node: Installation2038 -Node: Quelpa2552 -Node: Helm support3080 -Node: Usage3483 -Node: Commands3881 -Node: org-ql-find4325 -Node: org-ql-refile4791 -Node: org-ql-search5114 -Node: helm-org-ql6810 -Node: org-ql-view7188 -Node: org-ql-view-sidebar7718 -Node: org-ql-view-recent-items8098 -Node: org-ql-sparse-tree8594 -Node: Queries9394 -Node: Non-sexp query syntax10511 -Node: General predicates12270 -Node: Ancestor/descendant predicates19257 -Node: Date/time predicates20385 -Node: Functions / Macros23509 -Node: Agenda-like views23807 -Ref: Function ‘org-ql-block’23969 -Node: Listing / acting-on results25230 -Ref: Caching25438 -Ref: Function ‘org-ql-select’26351 -Ref: Function ‘org-ql-query’28777 -Ref: Macro ‘org-ql’ (deprecated)30551 -Node: Custom predicates30866 -Ref: Macro ‘org-ql-defpred’31090 -Node: Dynamic block34531 -Node: Links37255 -Node: Tips37942 -Node: Changelog38266 -Node: 07-pre39049 -Node: 06341973 -Node: 06242508 -Node: 06142813 -Node: 0643381 -Node: 05246435 -Node: 05146735 -Node: 0547158 -Node: 04948687 -Node: 04848967 -Node: 04749316 -Node: 04649725 -Node: 04550133 -Node: 04450494 -Node: 04350853 -Node: 04251056 -Node: 04151217 -Node: 0451464 -Node: 03255565 -Node: 03155968 -Node: 0356165 -Node: 02359465 -Node: 02259699 -Node: 02159979 -Node: 0260184 -Node: 0164262 -Node: Notes64363 -Node: Comparison with Org Agenda searches64525 -Node: org-sidebar65414 -Node: License65693 +Node: Contents1789 +Node: Screenshots1912 +Node: Installation2030 +Node: Quelpa2544 +Node: Helm support3072 +Node: Usage3475 +Node: Commands3873 +Node: org-ql-find4317 +Node: org-ql-refile4783 +Node: org-ql-search5106 +Node: helm-org-ql6802 +Node: org-ql-view7180 +Node: org-ql-view-sidebar7710 +Node: org-ql-view-recent-items8090 +Node: org-ql-sparse-tree8586 +Node: Queries9386 +Node: Non-sexp query syntax10503 +Node: General predicates12262 +Node: Ancestor/descendant predicates19249 +Node: Date/time predicates20377 +Node: Functions / Macros23501 +Node: Agenda-like views23799 +Ref: Function ‘org-ql-block’23961 +Node: Listing / acting-on results25222 +Ref: Caching25430 +Ref: Function ‘org-ql-select’26343 +Ref: Function ‘org-ql-query’28769 +Ref: Macro ‘org-ql’ (deprecated)30543 +Node: Custom predicates30858 +Ref: Macro ‘org-ql-defpred’31082 +Node: Dynamic block34523 +Node: Links37247 +Node: Tips37934 +Node: Changelog38258 +Node: 0739033 +Node: 06341945 +Node: 06242476 +Node: 06142781 +Node: 0643349 +Node: 05246403 +Node: 05146703 +Node: 0547126 +Node: 04948655 +Node: 04848935 +Node: 04749284 +Node: 04649693 +Node: 04550101 +Node: 04450462 +Node: 04350821 +Node: 04251024 +Node: 04151185 +Node: 0451432 +Node: 03255533 +Node: 03155936 +Node: 0356133 +Node: 02359433 +Node: 02259667 +Node: 02159947 +Node: 0260152 +Node: 0164230 +Node: Notes64331 +Node: Comparison with Org Agenda searches64493 +Node: org-sidebar65382 +Node: License65661  End Tag Table From ce66f67c960495ee24712b106c4f1c87e70e77fe Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 12 Mar 2023 05:59:13 -0500 Subject: [PATCH 27/72] Meta: v0.7.1-pre --- README.org | 4 ++ org-ql.el | 2 +- org-ql.info | 195 +++++++++++++++++++++++++++------------------------- 3 files changed, 108 insertions(+), 93 deletions(-) diff --git a/README.org b/README.org index 637a13d..2532294 100644 --- a/README.org +++ b/README.org @@ -543,6 +543,10 @@ 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. +** 0.7.1-pre + +Nothing new yet. + ** 0.7 *Added* diff --git a/org-ql.el b/org-ql.el index 3b72ff0..c0f548a 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7 +;; Version: 0.7.1-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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index e0c6191..741030a 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,6 +71,7 @@ Functions / Macros Changelog +* 0.7.1-pre: 071-pre. * 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. @@ -990,6 +991,7 @@ releases. * Menu: +* 0.7.1-pre: 071-pre. * 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. @@ -1018,9 +1020,17 @@ releases. * 0.1: 01.  -File: README.info, Node: 07, Next: 063, Up: Changelog +File: README.info, Node: 071-pre, Next: 07, Up: Changelog -5.1 0.7 +5.1 0.7.1-pre +============= + +Nothing new yet. + + +File: README.info, Node: 07, Next: 063, Prev: 071-pre, Up: Changelog + +5.2 0.7 ======= *Added* @@ -1080,7 +1090,7 @@ File: README.info, Node: 07, Next: 063, Up: Changelog  File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog -5.2 0.6.3 +5.3 0.6.3 ========= *Fixed* @@ -1096,7 +1106,7 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog  File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog -5.3 0.6.2 +5.4 0.6.2 ========= *Fixed* @@ -1107,7 +1117,7 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog  File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog -5.4 0.6.1 +5.5 0.6.1 ========= *Fixed* @@ -1125,7 +1135,7 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog  File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog -5.5 0.6 +5.6 0.6 ======= *Added* @@ -1192,7 +1202,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog  File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog -5.6 0.5.2 +5.7 0.5.2 ========= *Fixed* @@ -1203,7 +1213,7 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog  File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog -5.7 0.5.1 +5.8 0.5.1 ========= *Fixed* @@ -1216,7 +1226,7 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog  File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog -5.8 0.5 +5.9 0.5 ======= *Added* @@ -1257,8 +1267,8 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog  File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog -5.9 0.4.9 -========= +5.10 0.4.9 +========== *Fixed* • Agenda restriction in ‘org-ql-block’. (Fixes #84 @@ -1268,7 +1278,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog  File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog -5.10 0.4.8 +5.11 0.4.8 ========== *Fixed* @@ -1280,7 +1290,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog  File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog -5.11 0.4.7 +5.12 0.4.7 ========== *Fixed* @@ -1293,7 +1303,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog  File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog -5.12 0.4.6 +5.13 0.4.6 ========== *Fixed* @@ -1306,7 +1316,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog  File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog -5.13 0.4.5 +5.14 0.4.5 ========== *Fixed* @@ -1318,7 +1328,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.14 0.4.4 +5.15 0.4.4 ========== *Fixed* @@ -1330,7 +1340,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.15 0.4.3 +5.16 0.4.3 ========== *Fixed* @@ -1340,7 +1350,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.16 0.4.2 +5.17 0.4.2 ========== *Fixed* @@ -1349,7 +1359,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.17 0.4.1 +5.18 0.4.1 ========== *Fixed* @@ -1359,7 +1369,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.18 0.4 +5.19 0.4 ======== _Note:_ The next release, 0.5, may include changes which will require @@ -1440,7 +1450,7 @@ automatically, as they will be pushed to the ‘master’ branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.19 0.3.2 +5.20 0.3.2 ========== *Fixed* @@ -1453,7 +1463,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.20 0.3.1 +5.21 0.3.1 ========== *Fixed* @@ -1463,7 +1473,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.21 0.3 +5.22 0.3 ======== *Added* @@ -1531,7 +1541,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.22 0.2.3 +5.23 0.2.3 ========== *Fixed* @@ -1541,7 +1551,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.23 0.2.2 +5.24 0.2.2 ========== *Fixed* @@ -1552,7 +1562,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.24 0.2.1 +5.25 0.2.1 ========== *Fixed* @@ -1562,7 +1572,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.25 0.2 +5.26 0.2 ======== *Added* @@ -1645,7 +1655,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.26 0.1 +5.27 0.1 ======== First tagged release. @@ -1703,70 +1713,71 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1789 -Node: Screenshots1912 -Node: Installation2030 -Node: Quelpa2544 -Node: Helm support3072 -Node: Usage3475 -Node: Commands3873 -Node: org-ql-find4317 -Node: org-ql-refile4783 -Node: org-ql-search5106 -Node: helm-org-ql6802 -Node: org-ql-view7180 -Node: org-ql-view-sidebar7710 -Node: org-ql-view-recent-items8090 -Node: org-ql-sparse-tree8586 -Node: Queries9386 -Node: Non-sexp query syntax10503 -Node: General predicates12262 -Node: Ancestor/descendant predicates19249 -Node: Date/time predicates20377 -Node: Functions / Macros23501 -Node: Agenda-like views23799 -Ref: Function ‘org-ql-block’23961 -Node: Listing / acting-on results25222 -Ref: Caching25430 -Ref: Function ‘org-ql-select’26343 -Ref: Function ‘org-ql-query’28769 -Ref: Macro ‘org-ql’ (deprecated)30543 -Node: Custom predicates30858 -Ref: Macro ‘org-ql-defpred’31082 -Node: Dynamic block34523 -Node: Links37247 -Node: Tips37934 -Node: Changelog38258 -Node: 0739033 -Node: 06341945 -Node: 06242476 -Node: 06142781 -Node: 0643349 -Node: 05246403 -Node: 05146703 -Node: 0547126 -Node: 04948655 -Node: 04848935 -Node: 04749284 -Node: 04649693 -Node: 04550101 -Node: 04450462 -Node: 04350821 -Node: 04251024 -Node: 04151185 -Node: 0451432 -Node: 03255533 -Node: 03155936 -Node: 0356133 -Node: 02359433 -Node: 02259667 -Node: 02159947 -Node: 0260152 -Node: 0164230 -Node: Notes64331 -Node: Comparison with Org Agenda searches64493 -Node: org-sidebar65382 -Node: License65661 +Node: Contents1812 +Node: Screenshots1935 +Node: Installation2053 +Node: Quelpa2567 +Node: Helm support3095 +Node: Usage3498 +Node: Commands3896 +Node: org-ql-find4340 +Node: org-ql-refile4806 +Node: org-ql-search5129 +Node: helm-org-ql6825 +Node: org-ql-view7203 +Node: org-ql-view-sidebar7733 +Node: org-ql-view-recent-items8113 +Node: org-ql-sparse-tree8609 +Node: Queries9409 +Node: Non-sexp query syntax10526 +Node: General predicates12285 +Node: Ancestor/descendant predicates19272 +Node: Date/time predicates20400 +Node: Functions / Macros23524 +Node: Agenda-like views23822 +Ref: Function ‘org-ql-block’23984 +Node: Listing / acting-on results25245 +Ref: Caching25453 +Ref: Function ‘org-ql-select’26366 +Ref: Function ‘org-ql-query’28792 +Ref: Macro ‘org-ql’ (deprecated)30566 +Node: Custom predicates30881 +Ref: Macro ‘org-ql-defpred’31105 +Node: Dynamic block34546 +Node: Links37270 +Node: Tips37957 +Node: Changelog38281 +Node: 071-pre39079 +Node: 0739190 +Node: 06342118 +Node: 06242649 +Node: 06142954 +Node: 0643522 +Node: 05246576 +Node: 05146876 +Node: 0547299 +Node: 04948828 +Node: 04849110 +Node: 04749459 +Node: 04649868 +Node: 04550276 +Node: 04450637 +Node: 04350996 +Node: 04251199 +Node: 04151360 +Node: 0451607 +Node: 03255708 +Node: 03156111 +Node: 0356308 +Node: 02359608 +Node: 02259842 +Node: 02160122 +Node: 0260327 +Node: 0164405 +Node: Notes64506 +Node: Comparison with Org Agenda searches64668 +Node: org-sidebar65557 +Node: License65836  End Tag Table From e08de2a76c2bbd6364126653fdd911b37243f572 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 12 Mar 2023 05:59:22 -0500 Subject: [PATCH 28/72] Fix: (org-ql-completing-read) Bind org-outline-path-cache nil --- org-ql-completing-read.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index b1ef11a..c661d45 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -103,7 +103,8 @@ single predicate)." query-tokens snippet-regexp) (cl-labels ((action () (font-lock-ensure (point-at-bol) (point-at-eol)) - (let* ((path (thread-first (org-get-outline-path t t) + (let* ((org-outline-path-cache) ; See `org-get-outline-path' docstring. + (path (thread-first (org-get-outline-path t t) (org-format-outline-path window-width nil "") (org-split-string ""))) (path (if org-ql-completing-read-reverse-paths From 4c1a4b169f54d37ce541902c0ae5043759ef9d9b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 12 Mar 2023 09:30:29 -0500 Subject: [PATCH 29/72] Fix: (org-ql-completing-read) This seems to work better now with default Emacs completion (i.e. not using Vertico or Helm). It's still not perfect, but it seems to work reasonably well and be more correct. Fixes #338. Thanks to @arozbiz for reporting. --- README.org | 3 +- org-ql-completing-read.el | 224 ++++++++++++++++++++++++++------------ org-ql.info | 66 +++++------ 3 files changed, 192 insertions(+), 101 deletions(-) diff --git a/README.org b/README.org index 2532294..5135cdc 100644 --- a/README.org +++ b/README.org @@ -545,7 +545,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.7.1-pre -Nothing new yet. +*Fixes* ++ Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.) ** 0.7 diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index c661d45..b72c8fa 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -94,104 +94,190 @@ with commas to turn multiple tokens, which would normally be treated as multiple predicates, into multiple arguments to a single predicate)." (declare (indent defun)) - ;; Emacs's completion API is not always easy to understand, - ;; especially when using "programmed completion." This code was - ;; made possible by the example Clemens Radermacher shared at + ;; Emacs's completion API is not always easy to understand, especially when using "programmed + ;; completion." This code was made possible by the example Clemens Radermacher shared at ;; . + + ;; NOTE: I don't usually leave commented-out debugging code, but due to the incredibly tedious + ;; complexity of the "Programmed Completion" API and the time spent trying to get this reasonably + ;; close to "correct," I'm leaving it in, because I will undoubtedly have to go through this + ;; process again. + + ;; (message "ORG-QL-COMPLETING-READ: Starts.") (let ((table (make-hash-table :test #'equal)) + (disambiguations (make-hash-table :test #'equal)) (window-width (window-width)) - query-tokens snippet-regexp) - (cl-labels ((action + last-input org-outline-path-cache query-tokens snippet-regexp) + (cl-labels (;; (debug-message + ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) + (action () (font-lock-ensure (point-at-bol) (point-at-eol)) - (let* ((org-outline-path-cache) ; See `org-get-outline-path' docstring. - (path (thread-first (org-get-outline-path t t) - (org-format-outline-path window-width nil "") - (org-split-string ""))) - (path (if org-ql-completing-read-reverse-paths - (string-join (nreverse path) "\\") - (string-join path "/")))) - (puthash path (point-marker) table) - path)) + ;; FIXME: We want the fontified heading, and `org-heading-components' returns it + ;; without properties, so we have to use `org-get-heading', which added additional + ;; optional arguments in a certain Org version, so in those versions, it will + ;; return priority cookies and comment strings. + (let ((heading (org-get-heading t t))) + (when (gethash heading table) + ;; Disambiguate heading (even adding the path isn't enough, because that could + ;; also be duplicated). + (if-let ((suffix (gethash heading disambiguations))) + (setf heading (format "%s <%s>" heading (cl-incf suffix))) + (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) + (puthash heading (point-marker) table))) + (path (marker) + (org-with-point-at marker + (let* ((path (thread-first (org-get-outline-path nil t) + (org-format-outline-path window-width nil "") + (org-split-string ""))) + (formatted-path (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/"))))) + formatted-path))) + (todo + (marker) (if-let (it (org-entry-get marker "TODO")) + (concat (propertize it 'face (org-get-todo-face it)) " ") + "")) (affix (completions) + ;; (debug-message "AFFIX:%S" completions) (cl-loop for completion in completions for marker = (gethash completion table) - for todo-state = (if-let (it (org-entry-get marker "TODO")) - (concat (propertize it - 'face (org-get-todo-face it)) - " ") - "") - for snippet = (if-let (it (snippet marker)) - (propertize (concat " " it) - 'face 'org-ql-completing-read-snippet) - "") - collect (list completion todo-state snippet))) + for prefix = (todo marker) + for suffix = (concat (path marker) " " (snippet marker)) + collect (list completion prefix suffix))) (annotate (candidate) + ;; (debug-message "ANNOTATE:%S" candidate) (while-no-input - ;; Using `while-no-input' here doesn't make it as - ;; responsive as, e.g. Helm while typing, but it seems to - ;; help a little when using the org-rifle-style snippets. + ;; Using `while-no-input' here doesn't make it as responsive as, + ;; e.g. Helm while typing, but it seems to help a little when using the + ;; org-rifle-style snippets. (or (snippet (gethash candidate table)) ""))) - (snippet (marker) - (org-with-point-at marker - (or (funcall org-ql-completing-read-snippet-function snippet-regexp) - (org-ql-completing-read--snippet-simple)))) + (snippet + (marker) (when-let + ((snippet + (org-with-point-at marker + (or (funcall org-ql-completing-read-snippet-function snippet-regexp) + (org-ql-completing-read--snippet-simple))))) + (propertize (concat " " snippet) + 'face 'org-ql-completing-read-snippet))) (group (candidate transform) (pcase transform (`nil (buffer-name (marker-buffer (gethash candidate table)))) (_ candidate))) - (try (string _table _pred point &optional _metadata) + (try (string _collection _pred point &optional _metadata) + ;; (debug-message "TRY: STRING:%S" string) (cons string point)) (all (string table pred _point) + ;; (debug-message "all: STRING:%S" string) + ;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred)) (all-completions string table pred)) - (collection (str _pred flag) + (collection (input _pred flag) (when query-prefix - (setf str (concat query-prefix str))) + (setf input (concat query-prefix input))) (pcase flag ('metadata (list 'metadata (cons 'group-function #'group) (cons 'affixation-function #'affix) (cons 'annotation-function #'annotate))) - (`t (unless (string-empty-p str) - (when query-filter - (setf str (funcall query-filter str))) - (pcase org-ql-completing-read-snippet-function - ('org-ql-completing-read--snippet-regexp - (setf query-tokens - ;; Remove any tokens that specify predicates or are too short. - (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) - (< (length it) org-ql-completing-read-snippet-minimum-token-length))) - (split-string str nil t (rx space))) - snippet-regexp - (when query-tokens - ;; Limiting each context word to 15 characters - ;; prevents excessively long, non-word strings - ;; from ending up in snippets, which can - ;; adversely affect performance. - (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) - bow (or ,@query-tokens) (0+ (not space)) - (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))))) - (org-ql-select buffers-files (org-ql--query-string-to-sexp str) - :action #'action)))))) - ;; NOTE: It seems that the `completing-read' machinery can call, - ;; abort, and re-call the collection function while the user is - ;; typing, which can interrupt the machinery Org uses to prepare - ;; an Org buffer when an Org file is loaded. This results in, - ;; e.g. the buffer being left in fundamental-mode, unprepared to - ;; be used as an Org buffer, which breaks many things and is - ;; very confusing for the user. Ideally, of course, we would - ;; solve this in `org-ql-select', and we already attempt to, but - ;; that function is called by the `completing-read' machinery, - ;; which interrupts it, so we must work around this problem by - ;; ensuring all of the BUFFERS-FILES are loaded and initialized - ;; before calling `completing-read'. + (`t + ;; (debug-message "COLLECTION:t INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + ;; It's not ideal to call `run-query' unconditionally here, but due to + ;; the complexity of the "Programmed Completion" API, it's basically + ;; necessary, and org-ql's caching should make it nearly free. + (run-query input) + (hash-table-keys table)) + ('lambda + ;; (debug-message "COLLECTION:lambda INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + (if (not (hash-table-empty-p table)) + (when (gethash input table) + t) + (run-query input) + (when (gethash input table) + ;; (debug-message "COLLECTION:lambda INPUT:%S FOUND" input) + t))) + (`nil + ;; (debug-message "COLLECTION:nil INPUT:%S" input) + (if (not (hash-table-empty-p table)) + (when (gethash input table) + t) + (run-query input) + ;; (debug-message "COLLECTION:nil INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + (cond ((hash-table-empty-p table) + nil) + ((gethash input table) + t) + (t + ;; FIXME: "it should return the longest common prefix + ;; substring of all matches otherwise"...but there's no + ;; function to compute that? At least returning an empty + ;; string doesn't seem to break anything. + input)))) + (`(boundaries . ,suffix) + ;; (debug-message "COLLECTION:boundaries INPUT:%S SUFFIX:%S KEYS:%S" + ;; input suffix (hash-table-keys table)) + ;; FIXME: This is unlikely to be correct, but I'm not even sure if it + ;; can be correct in this case since the input (e.g. "todo: foo") + ;; usually won't match a completion candidate directly. + `(boundaries 0 . ,(length suffix))))) + (run-query (input) + ;; (debug-message "RUN-QUERY:%S" input) + (unless (or (string-empty-p input) + (equal last-input input)) + ;; (debug-message "RUN-QUERY:%S RUNNING" input) + (setf last-input input) + ;; Clear hash table each time the user changes the input. + (clrhash table) + (clrhash disambiguations) + (when query-filter + (setf input (funcall query-filter input))) + (pcase org-ql-completing-read-snippet-function + ('org-ql-completing-read--snippet-regexp + (setf query-tokens + ;; Remove any tokens that specify predicates or are too short. + (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) + (< (length it) org-ql-completing-read-snippet-minimum-token-length))) + (split-string input nil t (rx space))) + snippet-regexp + (when query-tokens + ;; Limiting each context word to 15 characters prevents + ;; excessively long, non-word strings from ending up in + ;; snippets, which can adversely affect performance. + (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) + bow (or ,@query-tokens) (0+ (not space)) + (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))))) + (org-ql-select buffers-files (org-ql--query-string-to-sexp input) + :action #'action)))) + ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the + ;; collection function while the user is typing, which can interrupt the machinery Org uses to + ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being + ;; left in fundamental-mode, unprepared to be used as an Org buffer, which breaks many things + ;; and is very confusing for the user. Ideally, of course, we would solve this in + ;; `org-ql-select', and we already attempt to, but that function is called by the + ;; `completing-read' machinery, which interrupts it, so we must work around this problem by + ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling + ;; `completing-read'. (unless (listp buffers-files) ;; Since we map across this argument, we ensure it's a list. (setf buffers-files (list buffers-files))) (mapc #'org-ql--ensure-buffer buffers-files) (let* ((completion-styles '(org-ql-completing-read)) (completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find"))) - (selected (completing-read prompt #'collection nil))) - (gethash selected table))))) + (selected (completing-read prompt #'collection nil t))) + ;; (debug-message "SELECTED:%S KEYS:%S" selected (hash-table-keys table)) + (or (gethash selected table) + ;; If there are completions in the table, but none of them exactly match the user input + ;; (e.g. a heading "foo" that matches a query "todo:"), `completing-read' will not + ;; select it automatically, so we return it ourselves. But note that this is not + ;; necessarily correct. For example, if the user types "todo:" and gets a list of + ;; completions ("foo" "bar"), and then changes the input to "ba" and presses RET + ;; immediately (without getting a new list of completions), the table will include "foo" + ;; and "bar", and we will return "foo"'s value rather than the first match for the query + ;; "ba", because `completing-read' will not cause the COLLECTION function to run a new + ;; query for the new input. + (car (hash-table-values table)) + (user-error "No results for input")))))) (defun org-ql-completing-read--snippet-simple (&optional _regexp) "Return a snippet of the current entry. diff --git a/org-ql.info b/org-ql.info index 741030a..7998193 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1025,7 +1025,11 @@ File: README.info, Node: 071-pre, Next: 07, Up: Changelog 5.1 0.7.1-pre ============= -Nothing new yet. +*Fixes* + • Function ‘org-ql-completing-read’ is more compatible with default + Emacs completion. (See #338 + (https://github.com/alphapapa/org-ql/issues/338). Thanks to + arozbiz (https://github.com/arozbiz) for reporting.)  File: README.info, Node: 07, Next: 063, Prev: 071-pre, Up: Changelog @@ -1748,36 +1752,36 @@ Node: Links37270 Node: Tips37957 Node: Changelog38281 Node: 071-pre39079 -Node: 0739190 -Node: 06342118 -Node: 06242649 -Node: 06142954 -Node: 0643522 -Node: 05246576 -Node: 05146876 -Node: 0547299 -Node: 04948828 -Node: 04849110 -Node: 04749459 -Node: 04649868 -Node: 04550276 -Node: 04450637 -Node: 04350996 -Node: 04251199 -Node: 04151360 -Node: 0451607 -Node: 03255708 -Node: 03156111 -Node: 0356308 -Node: 02359608 -Node: 02259842 -Node: 02160122 -Node: 0260327 -Node: 0164405 -Node: Notes64506 -Node: Comparison with Org Agenda searches64668 -Node: org-sidebar65557 -Node: License65836 +Node: 0739416 +Node: 06342344 +Node: 06242875 +Node: 06143180 +Node: 0643748 +Node: 05246802 +Node: 05147102 +Node: 0547525 +Node: 04949054 +Node: 04849336 +Node: 04749685 +Node: 04650094 +Node: 04550502 +Node: 04450863 +Node: 04351222 +Node: 04251425 +Node: 04151586 +Node: 0451833 +Node: 03255934 +Node: 03156337 +Node: 0356534 +Node: 02359834 +Node: 02260068 +Node: 02160348 +Node: 0260553 +Node: 0164631 +Node: Notes64732 +Node: Comparison with Org Agenda searches64894 +Node: org-sidebar65783 +Node: License66062  End Tag Table From 1d98c7d07c6f2af5c84e8358cb6c5db71e8f1006 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 14 Mar 2023 12:13:07 -0500 Subject: [PATCH 30/72] Tests: Disable Org link bracket tests on old Org versions --- tests/test-org-ql.el | 56 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 4e78f3a..5f9463f 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1147,33 +1147,35 @@ with keyword arg NOW in PLIST." (before-each (setq org-ql-test-buffer (org-ql-test-data-buffer "data-links.org"))) - (org-ql-it "without arguments" - (org-ql-expect ('(link)) - '("Alpha"))) - (org-ql-it "with description-or-target" - (org-ql-expect ('(link "phrase")) - '("Alpha"))) - (org-ql-it "with :description" - (org-ql-expect ('(link :description "phrase")) - '("Alpha"))) - (org-ql-it "with :target" - (org-ql-expect ('(link :target "id:")) - '("Alpha"))) - (org-ql-it "with :description and :target" - (org-ql-expect ('(link :description "phrase" :target "id")) - '("Alpha"))) - (org-ql-it "with description-or-target regexp" - (org-ql-expect ('(link "id:.*" :regexp-p t)) - '("Alpha"))) - (org-ql-it "with :description regexp" - (org-ql-expect ('(link :description "phr.se" :regexp-p t)) - '("Alpha"))) - (org-ql-it "with :target regexp" - (org-ql-expect ('(link :target "id:.*" :regexp-p t)) - '("Alpha"))) - (org-ql-it "with :description and :target regexp" - (org-ql-expect ('(link :description "phr.se" :target "id:.*" :regexp-p t)) - '("Alpha"))))) + (unless (version< org-version "9.3") + ;; Earlier Org versions don't allow escaped brackets in descriptions. + (org-ql-it "without arguments" + (org-ql-expect ('(link)) + '("Alpha"))) + (org-ql-it "with description-or-target" + (org-ql-expect ('(link "phrase")) + '("Alpha"))) + (org-ql-it "with :description" + (org-ql-expect ('(link :description "phrase")) + '("Alpha"))) + (org-ql-it "with :target" + (org-ql-expect ('(link :target "id:")) + '("Alpha"))) + (org-ql-it "with :description and :target" + (org-ql-expect ('(link :description "phrase" :target "id")) + '("Alpha"))) + (org-ql-it "with description-or-target regexp" + (org-ql-expect ('(link "id:.*" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :description regexp" + (org-ql-expect ('(link :description "phr.se" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :target regexp" + (org-ql-expect ('(link :target "id:.*" :regexp-p t)) + '("Alpha"))) + (org-ql-it "with :description and :target regexp" + (org-ql-expect ('(link :description "phr.se" :target "id:.*" :regexp-p t)) + '("Alpha")))))) (describe "(outline-path)" (org-ql-it "with one argument" From 2c098540cab6a0ee7d82abe2327d524a171edd1e Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 5 May 2023 17:23:50 -0500 Subject: [PATCH 31/72] Fix: (org-ql-completing-read) Format links before display Also use org-entry-get to get the heading, which should avoid issues with different Org versions having different optional arguments to org-get-heading. --- README.org | 1 + org-ql-completing-read.el | 2 +- org-ql.info | 242 +++++++++++++++++++------------------- 3 files changed, 124 insertions(+), 121 deletions(-) diff --git a/README.org b/README.org index 5135cdc..827f04f 100644 --- a/README.org +++ b/README.org @@ -547,6 +547,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.) ++ In ~org-ql-completing-read~, format links for display, and use ~org-entry-get~ internally rather than ~org-get-heading~. ** 0.7 diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index b72c8fa..7d335b3 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -116,7 +116,7 @@ single predicate)." ;; without properties, so we have to use `org-get-heading', which added additional ;; optional arguments in a certain Org version, so in those versions, it will ;; return priority cookies and comment strings. - (let ((heading (org-get-heading t t))) + (let ((heading (org-link-display-format (org-entry-get (point) "ITEM")))) (when (gethash heading table) ;; Disambiguate heading (even adding the path isn't enough, because that could ;; also be duplicated). diff --git a/org-ql.info b/org-ql.info index 7998193..bc9c3be 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1,4 +1,4 @@ -This is README.info, produced by makeinfo version 5.2 from README.texi. +This is README.info, produced by makeinfo version 6.7 from README.texi. INFO-DIR-SECTION Emacs START-INFO-DIR-ENTRY @@ -71,33 +71,33 @@ Functions / Macros Changelog -* 0.7.1-pre: 071-pre. -* 0.7: 07. -* 0.6.3: 063. -* 0.6.2: 062. -* 0.6.1: 061. -* 0.6: 06. -* 0.5.2: 052. -* 0.5.1: 051. -* 0.5: 05. -* 0.4.9: 049. -* 0.4.8: 048. -* 0.4.7: 047. -* 0.4.6: 046. -* 0.4.5: 045. -* 0.4.4: 044. -* 0.4.3: 043. -* 0.4.2: 042. -* 0.4.1: 041. -* 0.4: 04. -* 0.3.2: 032. -* 0.3.1: 031. -* 0.3: 03. -* 0.2.3: 023. -* 0.2.2: 022. -* 0.2.1: 021. -* 0.2: 02. -* 0.1: 01. +* 0.7.1-pre: 071-pre. +* 0.7: 07. +* 0.6.3: 063. +* 0.6.2: 062. +* 0.6.1: 061. +* 0.6: 06. +* 0.5.2: 052. +* 0.5.1: 051. +* 0.5: 05. +* 0.4.9: 049. +* 0.4.8: 048. +* 0.4.7: 047. +* 0.4.6: 046. +* 0.4.5: 045. +* 0.4.4: 044. +* 0.4.3: 043. +* 0.4.2: 042. +* 0.4.1: 041. +* 0.4: 04. +* 0.3.2: 032. +* 0.3.1: 031. +* 0.3: 03. +* 0.2.3: 023. +* 0.2.2: 022. +* 0.2.1: 021. +* 0.2: 02. +* 0.1: 01. Notes @@ -991,33 +991,33 @@ releases. * Menu: -* 0.7.1-pre: 071-pre. -* 0.7: 07. -* 0.6.3: 063. -* 0.6.2: 062. -* 0.6.1: 061. -* 0.6: 06. -* 0.5.2: 052. -* 0.5.1: 051. -* 0.5: 05. -* 0.4.9: 049. -* 0.4.8: 048. -* 0.4.7: 047. -* 0.4.6: 046. -* 0.4.5: 045. -* 0.4.4: 044. -* 0.4.3: 043. -* 0.4.2: 042. -* 0.4.1: 041. -* 0.4: 04. -* 0.3.2: 032. -* 0.3.1: 031. -* 0.3: 03. -* 0.2.3: 023. -* 0.2.2: 022. -* 0.2.1: 021. -* 0.2: 02. -* 0.1: 01. +* 0.7.1-pre: 071-pre. +* 0.7: 07. +* 0.6.3: 063. +* 0.6.2: 062. +* 0.6.1: 061. +* 0.6: 06. +* 0.5.2: 052. +* 0.5.1: 051. +* 0.5: 05. +* 0.4.9: 049. +* 0.4.8: 048. +* 0.4.7: 047. +* 0.4.6: 046. +* 0.4.5: 045. +* 0.4.4: 044. +* 0.4.3: 043. +* 0.4.2: 042. +* 0.4.1: 041. +* 0.4: 04. +* 0.3.2: 032. +* 0.3.1: 031. +* 0.3: 03. +* 0.2.3: 023. +* 0.2.2: 022. +* 0.2.1: 021. +* 0.2: 02. +* 0.1: 01.  File: README.info, Node: 071-pre, Next: 07, Up: Changelog @@ -1030,6 +1030,8 @@ File: README.info, Node: 071-pre, Next: 07, Up: Changelog Emacs completion. (See #338 (https://github.com/alphapapa/org-ql/issues/338). Thanks to arozbiz (https://github.com/arozbiz) for reporting.) + • In ‘org-ql-completing-read’, format links for display, and use + ‘org-entry-get’ internally rather than ‘org-get-heading’.  File: README.info, Node: 07, Next: 063, Prev: 071-pre, Up: Changelog @@ -1717,71 +1719,71 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1812 -Node: Screenshots1935 -Node: Installation2053 -Node: Quelpa2567 -Node: Helm support3095 -Node: Usage3498 -Node: Commands3896 -Node: org-ql-find4340 -Node: org-ql-refile4806 -Node: org-ql-search5129 -Node: helm-org-ql6825 -Node: org-ql-view7203 -Node: org-ql-view-sidebar7733 -Node: org-ql-view-recent-items8113 -Node: org-ql-sparse-tree8609 -Node: Queries9409 -Node: Non-sexp query syntax10526 -Node: General predicates12285 -Node: Ancestor/descendant predicates19272 -Node: Date/time predicates20400 -Node: Functions / Macros23524 -Node: Agenda-like views23822 -Ref: Function ‘org-ql-block’23984 -Node: Listing / acting-on results25245 -Ref: Caching25453 -Ref: Function ‘org-ql-select’26366 -Ref: Function ‘org-ql-query’28792 -Ref: Macro ‘org-ql’ (deprecated)30566 -Node: Custom predicates30881 -Ref: Macro ‘org-ql-defpred’31105 -Node: Dynamic block34546 -Node: Links37270 -Node: Tips37957 -Node: Changelog38281 -Node: 071-pre39079 -Node: 0739416 -Node: 06342344 -Node: 06242875 -Node: 06143180 -Node: 0643748 -Node: 05246802 -Node: 05147102 -Node: 0547525 -Node: 04949054 -Node: 04849336 -Node: 04749685 -Node: 04650094 -Node: 04550502 -Node: 04450863 -Node: 04351222 -Node: 04251425 -Node: 04151586 -Node: 0451833 -Node: 03255934 -Node: 03156337 -Node: 0356534 -Node: 02359834 -Node: 02260068 -Node: 02160348 -Node: 0260553 -Node: 0164631 -Node: Notes64732 -Node: Comparison with Org Agenda searches64894 -Node: org-sidebar65783 -Node: License66062 +Node: Contents1785 +Node: Screenshots1908 +Node: Installation2026 +Node: Quelpa2540 +Node: Helm support3068 +Node: Usage3471 +Node: Commands3869 +Node: org-ql-find4313 +Node: org-ql-refile4779 +Node: org-ql-search5102 +Node: helm-org-ql6798 +Node: org-ql-view7176 +Node: org-ql-view-sidebar7706 +Node: org-ql-view-recent-items8086 +Node: org-ql-sparse-tree8582 +Node: Queries9382 +Node: Non-sexp query syntax10499 +Node: General predicates12258 +Node: Ancestor/descendant predicates19245 +Node: Date/time predicates20373 +Node: Functions / Macros23497 +Node: Agenda-like views23795 +Ref: Function org-ql-block23957 +Node: Listing / acting-on results25218 +Ref: Caching25426 +Ref: Function org-ql-select26339 +Ref: Function org-ql-query28765 +Ref: Macro org-ql (deprecated)30539 +Node: Custom predicates30854 +Ref: Macro org-ql-defpred31078 +Node: Dynamic block34519 +Node: Links37243 +Node: Tips37930 +Node: Changelog38254 +Node: 071-pre39025 +Node: 0739507 +Node: 06342435 +Node: 06242966 +Node: 06143271 +Node: 0643839 +Node: 05246893 +Node: 05147193 +Node: 0547616 +Node: 04949145 +Node: 04849427 +Node: 04749776 +Node: 04650185 +Node: 04550593 +Node: 04450954 +Node: 04351313 +Node: 04251516 +Node: 04151677 +Node: 0451924 +Node: 03256025 +Node: 03156428 +Node: 0356625 +Node: 02359925 +Node: 02260159 +Node: 02160439 +Node: 0260644 +Node: 0164722 +Node: Notes64823 +Node: Comparison with Org Agenda searches64985 +Node: org-sidebar65874 +Node: License66153  End Tag Table From eb5377320fcfd38354d6e9e3e655969ae3c0e052 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 25 May 2023 10:48:47 -0500 Subject: [PATCH 32/72] Comment: Add FIXME --- org-ql.el | 1 + 1 file changed, 1 insertion(+) diff --git a/org-ql.el b/org-ql.el index c0f548a..94f48c7 100644 --- a/org-ql.el +++ b/org-ql.el @@ -76,6 +76,7 @@ Tags are stored in match group 1. Match group 2 stores the tags without the enclosing colons.") (defvaralias 'org-ql-link-regexp + ;; FIXME: `org-link-bracket-re' is void until `org-link-make-regexps' is called. (if (bound-and-true-p org-link-bracket-re) 'org-link-bracket-re 'org-bracket-link-regexp) From 898addeee956b02118f1db421a1a6c21cd5bd866 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 4 Sep 2023 22:40:52 -0500 Subject: [PATCH 33/72] Docs: Tidy The circumstances which precipitated this expression of support for fellow developers thankfully passed some time ago. --- README.org | 1 - images/dont-tread-on-emacs-150.png | Bin 5660 -> 0 bytes 2 files changed, 1 deletion(-) delete mode 100644 images/dont-tread-on-emacs-150.png diff --git a/README.org b/README.org index 827f04f..92de36f 100644 --- a/README.org +++ b/README.org @@ -1,7 +1,6 @@ #+TITLE: org-ql # NOTE: Using =BEGIN_HTML= for this causes TeX/info export to fail, but this HTML block works. -# #+HTML: #+HTML: # NOTE: To avoid having this in the info manual, we use HTML rather than Org syntax; it still appears with the GitHub renderer. diff --git a/images/dont-tread-on-emacs-150.png b/images/dont-tread-on-emacs-150.png deleted file mode 100644 index 71f37362a5289714efa07aed1e7520198e8f8b87..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5660 zcmeAS@N?(olHy`uVBq!ia0y~yV3@|hz>vbh1|p+Reqdl=U@3O;4B_D5;Hcq9>0n@B z;4JWnEM{O()C6J1dq)rZF)%PlmbgZg1m~xflqVLYGL)B>>t*I;7bhncr0V4trO$q6 zBgMcVI@8m|F{EP7+qsoFGS_R5+ZVs})yvn*|2UyEU{lKLZL;2dk1ag-Z)VO}mLa5) zadDYz@D`7WOsq^>G6F<0nzy({ZQ;1Z;#qvPY?g)ZWs5=?_iZ_z({k=Es+fN|`+as= zdEdW{Dyp+Ye1l>pdY@yLIrC=r_q2P`H9!0A?{2wY^=!A8nOSzvj(dU|ZqB)JXp<(# zwhcL4O}aX>n-aKBFH^uJ^r^~yfyBg(AFNno_&ApbA9^{Za92u zn=5*!eu?DKox9FUO8I~Io4@zy%i_l=J*ItctQ2p|y^!6I8u+MT*)gG6vrc8?=%xOj zn5LEO9sXs;J8#E%|G&BFeLb@9gt0+%1gq0Vo>$p-Di@kg-IVR$@b>qs`=)aeXViTB ztpBOZ|Bu{}O$9d&?Q-u}cJkXap+1@HCwuqb>O5TfJjqzh@8kCQ|0SD)Z`t-dyruN^ zZOt?N>()ZAT~{(ot-70&t+n*?KCURK+9{Q(bA%SWezJ*e+72_`bZ-HUqs1|Mq!vA2 zo7g9p?>tGYe%tA{3zqKexxD|)ag9qxh2CNJRCW5^t$+5ozF^9wqVtRDc;LZYME*B1m*%T|d2+Nj3LmmiA;7VXc!X(^8bY zm1e4%7SHub^Gq$7!^gP)zVFKWp1E76yU&aH^_O97?$a;+Ea7vG^&XfeeC^%uQ};qc zP9J?<{`m9m%-gaNm*V{{Pn0z}#O1y9S#IiwUAk))DFlQUoxi^`>UWq~^d7ghy4RN) z8_tV)uc0&hWapJC_r$9?mWg+FNT$_T?7DX`LTvHjjbHl?t-4us$V-~(|L;FfzxEy5 z{mK6Rz5~6DN2=VDujcHu5<9T-^W!-({lStEanrl!8C(3%vX8y4CMnyg%)zusL%~z2 ziDi<8QWw)A4JB)rQ>SC5gzwSZVb_u%ae>#-n&Bgt|DZEAe-)9?j`?>_r`u#sV#cPFE3y3yo zOmIz7$}ka-t#hxFYVs+@4(t~)5OIbt`~Ia*FH?0wDG8Q&28)K zpOeqqIt4HNEO&fO#l}|C!@Ubt;(s0TKH}6Z-u-rW*3UcfcIVcqy|?X)EZns8c=F!K zFC+TA^LZ}ZiSY`3d&thU|NOy?k8^##`x@EIOFFvuR5V9)#CwH#h83^h7|5MmRO)`V z>Gvd^q8As$0_Cr&xTt6hQ2WS+Uv(U z({oDq3P(qjA8=VvZs7U;_TiFus}H}8%_v&2PW$NzXWgFCUSXb-=ymvy2kUd5cPWsbXyZ--pZu~|39Z1_|L2R~ ztukGmX=Y3_mmJ&w_pkPxy;5w6*&@BJ_qA-cZEv#w`RDhFb@4Y(>3tVEs#yHR#X8CA zutR;0cf{-NT^e_;zIl4N{+~ow^56C?PfX^9I4MsJ2n@Eo;=|{A^D^sml?Y_3Vb8BhoPELOCOy%H2iHjX>Dzg;D0zH>*&Y0D= zOfq9t-zv$J&1zBS&iFS7wEW4qU~Ot|zH`Nbj@HunYRlf-soDSTyiAyLJ?_=BTURxA zRWDwlwqcEEx=X+|x4)T|BI`Glg{{50dC_IfxSt<+*Tv3Wv|GQ;>bkD-E#+%ro)@{i zCtW+X=I<;2T@~+cuJ$?hRdTv+j$XWTS6D>nk-IlrFL6#?U;oo&{a)M7#G5xSMFnp; zB=w^EPUsK)|7TC{xjXxS-fJ%Bi*;95-xaJ{-@9Jx&Cd8Q&%)KVX-c?iubHFz=@Iw! zaM5pfW+wVn2gEsQMkO-N*=KOF`~Ln-j|zBurLTMKkJQLYl;p7a|A#j(MkYFNNBh0o zj?PnUcki4avULN4(5#dD|6P`jsVuIznYik;*U!!SD|)6$RWoHR)cEC>(GYU&$y;-G z&F@+!`=f%*S~oCkVvE@&al~u&n?3vMA{V>J>a{ZS z=P%y7v*qMNj)yDK&TolSHtXHMz~lWODtyMg?d}Dip>^KYJ>=j^M^pBEKlX?^5rx8tte%OoXy7vB8LHvQ-`v1>eC z8HFYFy8i#a*)jP(U0rwXh{qJ;^zH8dm z=Ly@BXNujO-W0Rj=GcjXIS&^~9GuXlx90zbmtPaSxw6I9^YGt`KkTd?b+dYfWMS{I zinB(S#2Y39hP=$gvx$)`r$n}uhg`T8c<`d|+aKE3>z?jAxK8t4 z#n$<+!_{BPdrrK4#4R#9qWgiE&o7xm#Igoff>7aq`W+*TQ># z9DY4#uffT*IU0L4TT>&&I$c^^wAwP&Dj)q_Yx6rk+(4I`oAJz_n?el2&vZDZHJE9AOm$oo z<(UHo3anD*@Ubp;KK8aK=#{p!#w5=5uG(v2{FJ3;tIhSCbZ$w2vF4?jJd&ZVmrZ!Q z9YjP|t+uUsyL$iOVEJF=EP-w!sVsp`BB?HcvkGTha{t_{;^{G|N#nG~r8A1&9mdxe zsVJWP@%glx?^Zvl*R>{Bs(*ate}61~W6?s}@4ef9>|P(Emi=NzTjRpl635Oge7?a) z)<<-{`@$oS7j4=jGr#;X-~XE*oF^~dn0e?S=cJV^nWn9?JST@;&bTSlWS~7|kHx3! zc_QVU=Oj03=(XmA9e=xerr>4WM9)o4I;TA*HK{zW_kRCF*L(Z!^D*9^dS0lw1S%Kwjs_Hxa)_4k^yCyFvme{@*BzCnIZLFZ{_Lmg*!Z+9_Ym7<76j58V<^Okk0 zDZ5No4w>>ZgKG=(KBt;ryOR!cYRmB(n_Tj>F!D5!Qkv^|Uik3ZJI8h!92Zn&ah&yC z+B+pBMIi9Z`TY|&2gBvCl7dESwkUxin}=kmjYAU+!4W^-GQvlj~>iKi+)(_0iW~AC>JkT>H4g>EX2O zC|>DJeN#`mNbr6W>h_)Jb^K(?rHrU)bJk5hJu|}l%XQ8sj;4l&289j{zRvSC&m8Af zubchBrSI+8-Yr|NZCq>W@OoQR)a_Rp_XFK)i&f`Mn)+6Ihm;QYul%0EZ(n%V#l3uf zWu^C?qJOzAf-!oW`|tN&e|_kA@#C*n>F3t%Jp4ASV7Kg!7_PYWlU#nLRV-ff zG-;NlQI<$(?^Ax=wpDJ1zOt8140vR9XFt90aPF6HJw|3`y_vISESqX>JA-Z7)cE`> zn+_aeIekbee-lIYv;1$jm_Dg-GBQ>!Q_YNgwuay5^pn5-a)%ykKDEAY$$CesR9WGS z@0NMxwv!JlMRY7`Q1U*psb!Ieg{+^=y&x}dEzR%j1-nld?))Qt?@hp!L%XC)VpV7R zPCUEx#M4X0?rn4CIi63wz{`7j(*_;k4bNKABE#Y`!v1ZJ+&oSH^|ka68KFfA3sQUc zB&5v{J^c20O>2z9BoUFL%}To`i1K&6Iri|wB8@zmF8=nz&W67K?@w@jxYuD??1@d> z{L<^|Hc8&N@pGl`#Uywyu{`v6R-WeKH9GmfJ(m~r@VT70yRB%oPWPMJ@(hj-UOnXu z33V4?{q|<9s)(1dm5}=+7OU@9lsGQjmR6g2f~nv^0JHl1TPN@T`KrAltM0AV{PT|0 z?nj#{N=khfr+s04x4roPz5`8`g2{_HlMJWM-M#Ahou-2|E>2 z85$b5E@s{V6J4pZz&gW=@-SRQ~VBKpQ#M%PkopPaiB~E4mrI=u9fFl$7^#JC-M{F+q>!e3tKBb>-Tx z6>BTM@7wg3|H@hJ=^iPTB}*6&8+`mJ6LP(x^JvJe+u9aCzvwC4zi`>4S=M@W$I*}^ zL($7yZv1zUognU`v#RJr0dxPJ<*E06Z&_paUC(rJ@go=Q<8pa%*UD}GMQE$bWk3D( zRWs`LDa()d{_OhtvZT-5Kj-n0WaIt8kyhWYEqd+Uzx$#|bGuyLvx|>!KfB{+bL~_! z`>Ttk%@ICN|NU*;X_97S*(Z}56BhISNGzwe%qfB1RXltyJIhKZ<=1~!I`02O`0tne zH_xii$3A^CQ&8>L=F~d3@hL3y_vUeUZcN&%}bZ z3tt}H<~={@($aoS?$EJowlq1sT7^nQV)d3l}{+6C?GzO1Y=+-d!XA?5N{L zJl!Q$>`%Ja-fm5lP=+TYAIFAmR5F|u42 zH*?PJ?++TQ?(GtIa_MN{w|o1)u(3_o>$`ky+XjvOb7iepRlNT5$JOuLe#>L$?r!gT zJ-zPM>Bs(C^ncDdYEhlma@c)##gB<;arU+*@8e=?Ie&j+uXtwuJwZY(KbB+NkDuFv zH=L@@nCQE^I5PR(t%d9NTAeuDuM=k@(RS3o{*v)|-PxvMDZgi>B}lxtV=`M z??&aj7kc!tPyT#o5-0EW*I}g~yKJ>tq?mY**oqZj&UEicJ-Bo8Vi~)l@~1ze3Vv->tov~P`pgdpZS`KN#CT`^MC&JvQ_)DkN?saFZn*cDgXSs_w2I5 zt!rj(@baEJr>08$`MDm358d;>f8OZ-X7L^y`#Fy{9=|R2#DSr9Z=#fxci@y>Ltibi z;GH#@P0sD&Tq$PhYw}O@-?1s$(kcFbefzw30=9P*_2$Sg-nTHt(IQgJvSbJ2#rAVSKo8sefE03!Z!<_nsTH`%5)eR$?Sgow|rUQ z);m{k@v`%o282CJDo^J%HH|wrPckvbZGo=+}>#XP7}VKc73PAE@5d&kg5#QF5AH#Y)Z zv!gBd+9vv3e)J=GZN*+b70vn4=BB@I-i>rV{>{tH?a>@->s@Q!SN*-EvfDbl;)8>2 z-u6T1>#wzEMqRl&{lb+u&-clO-g(0%*#ETn^uvWO79IVf^Y*PM%d1a`)zybMnEw0< zwhk2OtcZDh(S7^Fl9Qh=S;+Yq*p#F*?vsw*CVXqzh8xq$2@Gd$!yNSd&tH7{&4nKY T9~Ln%Ffe$!`njxgN@xNAk>vYn From a7af6d78b220f374221d802397fb2337238a3b89 Mon Sep 17 00:00:00 2001 From: Ankit Pandey Date: Wed, 21 Jun 2023 04:02:59 -0700 Subject: [PATCH 34/72] Fix: (org-ql-completing-read) Store markers as text property Fixes #350 --- org-ql-completing-read.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 7d335b3..952ebf1 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -123,7 +123,8 @@ single predicate)." (if-let ((suffix (gethash heading disambiguations))) (setf heading (format "%s <%s>" heading (cl-incf suffix))) (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) - (puthash heading (point-marker) table))) + (let ((marker (point-marker))) + (puthash (propertize heading 'org-marker marker) marker table)))) (path (marker) (org-with-point-at marker (let* ((path (thread-first (org-get-outline-path nil t) @@ -140,7 +141,7 @@ single predicate)." (affix (completions) ;; (debug-message "AFFIX:%S" completions) (cl-loop for completion in completions - for marker = (gethash completion table) + for marker = (get-text-property 0 'org-marker completion) for prefix = (todo marker) for suffix = (concat (path marker) " " (snippet marker)) collect (list completion prefix suffix))) @@ -150,7 +151,7 @@ single predicate)." ;; Using `while-no-input' here doesn't make it as responsive as, ;; e.g. Helm while typing, but it seems to help a little when using the ;; org-rifle-style snippets. - (or (snippet (gethash candidate table)) ""))) + (or (snippet (get-text-property 0 'org-marker completion)) ""))) (snippet (marker) (when-let ((snippet @@ -161,7 +162,7 @@ single predicate)." 'face 'org-ql-completing-read-snippet))) (group (candidate transform) (pcase transform - (`nil (buffer-name (marker-buffer (gethash candidate table)))) + (`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate)))) (_ candidate))) (try (string _collection _pred point &optional _metadata) ;; (debug-message "TRY: STRING:%S" string) From 2d29d69133ae7d437afb4ce0a1f644b0bfd42d75 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 16:08:54 -0500 Subject: [PATCH 35/72] Docs: Update changelog --- README.org | 1 + org-ql.info | 65 ++++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/README.org b/README.org index 92de36f..ad803be 100644 --- a/README.org +++ b/README.org @@ -546,6 +546,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.) ++ Function ~org-ql-completing-read~ would sometimes stop updating with changes in input. (See [[https://github.com/alphapapa/org-ql/issues/350][#350]]. Thanks to [[https://github.com/anpandey][Ankit Raj Pandey]] for reporting and fixing, and to [[https://github.com/minad][Daniel Mendler]] for advising.) + In ~org-ql-completing-read~, format links for display, and use ~org-entry-get~ internally rather than ~org-get-heading~. ** 0.7 diff --git a/org-ql.info b/org-ql.info index bc9c3be..5ecb26e 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1030,6 +1030,11 @@ File: README.info, Node: 071-pre, Next: 07, Up: Changelog Emacs completion. (See #338 (https://github.com/alphapapa/org-ql/issues/338). Thanks to arozbiz (https://github.com/arozbiz) for reporting.) + • Function ‘org-ql-completing-read’ would sometimes stop updating + with changes in input. (See #350 + (https://github.com/alphapapa/org-ql/issues/350). Thanks to Ankit + Raj Pandey (https://github.com/anpandey) for reporting and fixing, + and to Daniel Mendler (https://github.com/minad) for advising.) • In ‘org-ql-completing-read’, format links for display, and use ‘org-entry-get’ internally rather than ‘org-get-heading’. @@ -1754,36 +1759,36 @@ Node: Links37243 Node: Tips37930 Node: Changelog38254 Node: 071-pre39025 -Node: 0739507 -Node: 06342435 -Node: 06242966 -Node: 06143271 -Node: 0643839 -Node: 05246893 -Node: 05147193 -Node: 0547616 -Node: 04949145 -Node: 04849427 -Node: 04749776 -Node: 04650185 -Node: 04550593 -Node: 04450954 -Node: 04351313 -Node: 04251516 -Node: 04151677 -Node: 0451924 -Node: 03256025 -Node: 03156428 -Node: 0356625 -Node: 02359925 -Node: 02260159 -Node: 02160439 -Node: 0260644 -Node: 0164722 -Node: Notes64823 -Node: Comparison with Org Agenda searches64985 -Node: org-sidebar65874 -Node: License66153 +Node: 0739834 +Node: 06342762 +Node: 06243293 +Node: 06143598 +Node: 0644166 +Node: 05247220 +Node: 05147520 +Node: 0547943 +Node: 04949472 +Node: 04849754 +Node: 04750103 +Node: 04650512 +Node: 04550920 +Node: 04451281 +Node: 04351640 +Node: 04251843 +Node: 04152004 +Node: 0452251 +Node: 03256352 +Node: 03156755 +Node: 0356952 +Node: 02360252 +Node: 02260486 +Node: 02160766 +Node: 0260971 +Node: 0165049 +Node: Notes65150 +Node: Comparison with Org Agenda searches65312 +Node: org-sidebar66201 +Node: License66480  End Tag Table From 3c24958738089990692267265943c7fad29e59f3 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 18:55:39 -0500 Subject: [PATCH 36/72] Fix: (org-ql-completing-read) Variable name --- org-ql-completing-read.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 952ebf1..47b6c35 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -151,7 +151,7 @@ single predicate)." ;; Using `while-no-input' here doesn't make it as responsive as, ;; e.g. Helm while typing, but it seems to help a little when using the ;; org-rifle-style snippets. - (or (snippet (get-text-property 0 'org-marker completion)) ""))) + (or (snippet (get-text-property 0 'org-marker candidate)) ""))) (snippet (marker) (when-let ((snippet From ed81b7d7c81479a73f50a46c2f0e338ec264b924 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 18:56:32 -0500 Subject: [PATCH 37/72] Tests: Require xr This is only a development dependency. --- tests/test-org-ql.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 5f9463f..9008179 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -33,6 +33,8 @@ (require 'org-ql-search) (require 'org-ql-view) +(require 'xr) + ;;;; Variables (defvar org-ql-test-buffer nil From d776e205d53adccd1d66a9c666fd885a2334262e Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 18:57:36 -0500 Subject: [PATCH 38/72] Release: v0.7.1 --- README.org | 2 +- org-ql.el | 2 +- org-ql.info | 142 ++++++++++++++++++++++++++-------------------------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/README.org b/README.org index ad803be..13d6732 100644 --- a/README.org +++ b/README.org @@ -542,7 +542,7 @@ 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. -** 0.7.1-pre +** 0.7.1 *Fixes* + Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.) diff --git a/org-ql.el b/org-ql.el index 94f48c7..991944e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.1-pre +;; Version: 0.7.1 ;; 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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index 5ecb26e..900e0ce 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,7 +71,7 @@ Functions / Macros Changelog -* 0.7.1-pre: 071-pre. +* 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. @@ -991,7 +991,7 @@ releases. * Menu: -* 0.7.1-pre: 071-pre. +* 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. * 0.6.2: 062. @@ -1020,10 +1020,10 @@ releases. * 0.1: 01.  -File: README.info, Node: 071-pre, Next: 07, Up: Changelog +File: README.info, Node: 071, Next: 07, Up: Changelog -5.1 0.7.1-pre -============= +5.1 0.7.1 +========= *Fixes* • Function ‘org-ql-completing-read’ is more compatible with default @@ -1039,7 +1039,7 @@ File: README.info, Node: 071-pre, Next: 07, Up: Changelog ‘org-entry-get’ internally rather than ‘org-get-heading’.  -File: README.info, Node: 07, Next: 063, Prev: 071-pre, Up: Changelog +File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog 5.2 0.7 ======= @@ -1724,71 +1724,71 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1785 -Node: Screenshots1908 -Node: Installation2026 -Node: Quelpa2540 -Node: Helm support3068 -Node: Usage3471 -Node: Commands3869 -Node: org-ql-find4313 -Node: org-ql-refile4779 -Node: org-ql-search5102 -Node: helm-org-ql6798 -Node: org-ql-view7176 -Node: org-ql-view-sidebar7706 -Node: org-ql-view-recent-items8086 -Node: org-ql-sparse-tree8582 -Node: Queries9382 -Node: Non-sexp query syntax10499 -Node: General predicates12258 -Node: Ancestor/descendant predicates19245 -Node: Date/time predicates20373 -Node: Functions / Macros23497 -Node: Agenda-like views23795 -Ref: Function org-ql-block23957 -Node: Listing / acting-on results25218 -Ref: Caching25426 -Ref: Function org-ql-select26339 -Ref: Function org-ql-query28765 -Ref: Macro org-ql (deprecated)30539 -Node: Custom predicates30854 -Ref: Macro org-ql-defpred31078 -Node: Dynamic block34519 -Node: Links37243 -Node: Tips37930 -Node: Changelog38254 -Node: 071-pre39025 -Node: 0739834 -Node: 06342762 -Node: 06243293 -Node: 06143598 -Node: 0644166 -Node: 05247220 -Node: 05147520 -Node: 0547943 -Node: 04949472 -Node: 04849754 -Node: 04750103 -Node: 04650512 -Node: 04550920 -Node: 04451281 -Node: 04351640 -Node: 04251843 -Node: 04152004 -Node: 0452251 -Node: 03256352 -Node: 03156755 -Node: 0356952 -Node: 02360252 -Node: 02260486 -Node: 02160766 -Node: 0260971 -Node: 0165049 -Node: Notes65150 -Node: Comparison with Org Agenda searches65312 -Node: org-sidebar66201 -Node: License66480 +Node: Contents1777 +Node: Screenshots1900 +Node: Installation2018 +Node: Quelpa2532 +Node: Helm support3060 +Node: Usage3463 +Node: Commands3861 +Node: org-ql-find4305 +Node: org-ql-refile4771 +Node: org-ql-search5094 +Node: helm-org-ql6790 +Node: org-ql-view7168 +Node: org-ql-view-sidebar7698 +Node: org-ql-view-recent-items8078 +Node: org-ql-sparse-tree8574 +Node: Queries9374 +Node: Non-sexp query syntax10491 +Node: General predicates12250 +Node: Ancestor/descendant predicates19237 +Node: Date/time predicates20365 +Node: Functions / Macros23489 +Node: Agenda-like views23787 +Ref: Function org-ql-block23949 +Node: Listing / acting-on results25210 +Ref: Caching25418 +Ref: Function org-ql-select26331 +Ref: Function org-ql-query28757 +Ref: Macro org-ql (deprecated)30531 +Node: Custom predicates30846 +Ref: Macro org-ql-defpred31070 +Node: Dynamic block34511 +Node: Links37235 +Node: Tips37922 +Node: Changelog38246 +Node: 07139009 +Node: 0739806 +Node: 06342730 +Node: 06243261 +Node: 06143566 +Node: 0644134 +Node: 05247188 +Node: 05147488 +Node: 0547911 +Node: 04949440 +Node: 04849722 +Node: 04750071 +Node: 04650480 +Node: 04550888 +Node: 04451249 +Node: 04351608 +Node: 04251811 +Node: 04151972 +Node: 0452219 +Node: 03256320 +Node: 03156723 +Node: 0356920 +Node: 02360220 +Node: 02260454 +Node: 02160734 +Node: 0260939 +Node: 0165017 +Node: Notes65118 +Node: Comparison with Org Agenda searches65280 +Node: org-sidebar66169 +Node: License66448  End Tag Table From 3622b92403a53c360ea9ed9ca8692a157cec8a4c Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 20:49:12 -0500 Subject: [PATCH 39/72] Meta: v0.7.2-pre --- README.org | 4 ++++ org-ql.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 13d6732..32d6662 100644 --- a/README.org +++ b/README.org @@ -542,6 +542,10 @@ 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. +** 0.7.2-pre + +Nothing new yet. + ** 0.7.1 *Fixes* diff --git a/org-ql.el b/org-ql.el index 991944e..b92784e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.1 +;; Version: 0.7.2-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")) ;; Keywords: hypermedia, outlines, Org, agenda From f65b1d91a49468e176bd733d3b930ec4b7ed4cf1 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 6 Sep 2023 20:50:39 -0500 Subject: [PATCH 40/72] Fix: (org-ql--normalize-from-to-on) Tolerate "-" input Avoids errors while typing a query (e.g. a negative number) into org-ql-find, which interrupts completion altogether. --- README.org | 3 ++- org-ql.el | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 32d6662..92d5cb5 100644 --- a/README.org +++ b/README.org @@ -544,7 +544,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.7.2-pre -Nothing new yet. +*Fixes* ++ Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). ** 0.7.1 diff --git a/org-ql.el b/org-ql.el index b92784e..e153138 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1286,6 +1286,9 @@ result form." to on)) (when from (setq from (pcase from + ("-" + ;; Ignore, because it means the user is typing a negative number. + nil) ((or 'today "today") (->> (ts-now) (ts-apply :hour 0 :minute 0 :second 0))) ((pred numberp) (->> (ts-now) @@ -1302,6 +1305,9 @@ result form." ((pred ts-p) from)))) (when to (setq to (pcase to + ("-" + ;; Ignore, because it means the user is typing a negative number. + nil) ((or 'today "today") (->> (ts-now) (ts-apply :hour 23 :minute 59 :second 59))) ((pred numberp) (->> (ts-now) From 131407814ebfd8d409f23bc5cceeeb2b5da1a8d9 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 8 Sep 2023 02:22:40 -0500 Subject: [PATCH 41/72] Fix: (org-ql--def-query-string-to-sexp-fn) Ignore leading blanks --- README.org | 1 + org-ql.el | 2 +- org-ql.info | 204 ++++++++++++++++++++++++++++------------------------ 3 files changed, 112 insertions(+), 95 deletions(-) diff --git a/README.org b/README.org index 92d5cb5..4e499a6 100644 --- a/README.org +++ b/README.org @@ -546,6 +546,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). ++ Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~). ** 0.7.1 diff --git a/org-ql.el b/org-ql.el index e153138..2a54768 100644 --- a/org-ql.el +++ b/org-ql.el @@ -945,7 +945,7 @@ value of `org-ql-predicates')." ;; obscure bug in `peg': when one keyword is a substring of another, ;; and the shorter one is listed first, the shorter one fails to match. (-sort (-on #'> #'length)))) - (pexs `((query (+ (and term (* [blank])))) + (pexs `((query (and (* [blank]) (+ (and term (* [blank]))))) (term (or (and negation (list positive-term) ;; This is a bit confusing, but it seems to work. There's probably a better way. `(pred -- (list 'not (car pred)))) diff --git a/org-ql.info b/org-ql.info index 900e0ce..c120823 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,6 +71,7 @@ Functions / Macros Changelog +* 0.7.2-pre: 072-pre. * 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. @@ -991,6 +992,7 @@ releases. * Menu: +* 0.7.2-pre: 072-pre. * 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. @@ -1020,9 +1022,22 @@ releases. * 0.1: 01.  -File: README.info, Node: 071, Next: 07, Up: Changelog +File: README.info, Node: 072-pre, Next: 071, Up: Changelog -5.1 0.7.1 +5.1 0.7.2-pre +============= + +*Fixes* + • Timestamp predicates are more tolerant of partial input (e.g. + preventing errors while the user is typing a query into + ‘org-ql-find’). + • Query parser ignores leading whitespace (e.g. preventing errors + while the user is typing a query into ‘org-ql-find’). + + +File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog + +5.2 0.7.1 ========= *Fixes* @@ -1041,7 +1056,7 @@ File: README.info, Node: 071, Next: 07, Up: Changelog  File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog -5.2 0.7 +5.3 0.7 ======= *Added* @@ -1101,7 +1116,7 @@ File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog  File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog -5.3 0.6.3 +5.4 0.6.3 ========= *Fixed* @@ -1117,7 +1132,7 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog  File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog -5.4 0.6.2 +5.5 0.6.2 ========= *Fixed* @@ -1128,7 +1143,7 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog  File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog -5.5 0.6.1 +5.6 0.6.1 ========= *Fixed* @@ -1146,7 +1161,7 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog  File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog -5.6 0.6 +5.7 0.6 ======= *Added* @@ -1213,7 +1228,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog  File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog -5.7 0.5.2 +5.8 0.5.2 ========= *Fixed* @@ -1224,7 +1239,7 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog  File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog -5.8 0.5.1 +5.9 0.5.1 ========= *Fixed* @@ -1237,8 +1252,8 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog  File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog -5.9 0.5 -======= +5.10 0.5 +======== *Added* • View dispatcher using ‘transient.el’ (like Magit), bound to ‘v’ in @@ -1278,7 +1293,7 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog  File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog -5.10 0.4.9 +5.11 0.4.9 ========== *Fixed* @@ -1289,7 +1304,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog  File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog -5.11 0.4.8 +5.12 0.4.8 ========== *Fixed* @@ -1301,7 +1316,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog  File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog -5.12 0.4.7 +5.13 0.4.7 ========== *Fixed* @@ -1314,7 +1329,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog  File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog -5.13 0.4.6 +5.14 0.4.6 ========== *Fixed* @@ -1327,7 +1342,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog  File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog -5.14 0.4.5 +5.15 0.4.5 ========== *Fixed* @@ -1339,7 +1354,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.15 0.4.4 +5.16 0.4.4 ========== *Fixed* @@ -1351,7 +1366,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.16 0.4.3 +5.17 0.4.3 ========== *Fixed* @@ -1361,7 +1376,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.17 0.4.2 +5.18 0.4.2 ========== *Fixed* @@ -1370,7 +1385,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.18 0.4.1 +5.19 0.4.1 ========== *Fixed* @@ -1380,7 +1395,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.19 0.4 +5.20 0.4 ======== _Note:_ The next release, 0.5, may include changes which will require @@ -1461,7 +1476,7 @@ automatically, as they will be pushed to the ‘master’ branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.20 0.3.2 +5.21 0.3.2 ========== *Fixed* @@ -1474,7 +1489,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.21 0.3.1 +5.22 0.3.1 ========== *Fixed* @@ -1484,7 +1499,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.22 0.3 +5.23 0.3 ======== *Added* @@ -1552,7 +1567,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.23 0.2.3 +5.24 0.2.3 ========== *Fixed* @@ -1562,7 +1577,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.24 0.2.2 +5.25 0.2.2 ========== *Fixed* @@ -1573,7 +1588,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.25 0.2.1 +5.26 0.2.1 ========== *Fixed* @@ -1583,7 +1598,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.26 0.2 +5.27 0.2 ======== *Added* @@ -1666,7 +1681,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.27 0.1 +5.28 0.1 ======== First tagged release. @@ -1724,71 +1739,72 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1777 -Node: Screenshots1900 -Node: Installation2018 -Node: Quelpa2532 -Node: Helm support3060 -Node: Usage3463 -Node: Commands3861 -Node: org-ql-find4305 -Node: org-ql-refile4771 -Node: org-ql-search5094 -Node: helm-org-ql6790 -Node: org-ql-view7168 -Node: org-ql-view-sidebar7698 -Node: org-ql-view-recent-items8078 -Node: org-ql-sparse-tree8574 -Node: Queries9374 -Node: Non-sexp query syntax10491 -Node: General predicates12250 -Node: Ancestor/descendant predicates19237 -Node: Date/time predicates20365 -Node: Functions / Macros23489 -Node: Agenda-like views23787 -Ref: Function org-ql-block23949 -Node: Listing / acting-on results25210 -Ref: Caching25418 -Ref: Function org-ql-select26331 -Ref: Function org-ql-query28757 -Ref: Macro org-ql (deprecated)30531 -Node: Custom predicates30846 -Ref: Macro org-ql-defpred31070 -Node: Dynamic block34511 -Node: Links37235 -Node: Tips37922 -Node: Changelog38246 -Node: 07139009 -Node: 0739806 -Node: 06342730 -Node: 06243261 -Node: 06143566 -Node: 0644134 -Node: 05247188 -Node: 05147488 -Node: 0547911 -Node: 04949440 -Node: 04849722 -Node: 04750071 -Node: 04650480 -Node: 04550888 -Node: 04451249 -Node: 04351608 -Node: 04251811 -Node: 04151972 -Node: 0452219 -Node: 03256320 -Node: 03156723 -Node: 0356920 -Node: 02360220 -Node: 02260454 -Node: 02160734 -Node: 0260939 -Node: 0165017 -Node: Notes65118 -Node: Comparison with Org Agenda searches65280 -Node: org-sidebar66169 -Node: License66448 +Node: Contents1799 +Node: Screenshots1922 +Node: Installation2040 +Node: Quelpa2554 +Node: Helm support3082 +Node: Usage3485 +Node: Commands3883 +Node: org-ql-find4327 +Node: org-ql-refile4793 +Node: org-ql-search5116 +Node: helm-org-ql6812 +Node: org-ql-view7190 +Node: org-ql-view-sidebar7720 +Node: org-ql-view-recent-items8100 +Node: org-ql-sparse-tree8596 +Node: Queries9396 +Node: Non-sexp query syntax10513 +Node: General predicates12272 +Node: Ancestor/descendant predicates19259 +Node: Date/time predicates20387 +Node: Functions / Macros23511 +Node: Agenda-like views23809 +Ref: Function org-ql-block23971 +Node: Listing / acting-on results25232 +Ref: Caching25440 +Ref: Function org-ql-select26353 +Ref: Function org-ql-query28779 +Ref: Macro org-ql (deprecated)30553 +Node: Custom predicates30868 +Ref: Macro org-ql-defpred31092 +Node: Dynamic block34533 +Node: Links37257 +Node: Tips37944 +Node: Changelog38268 +Node: 072-pre39053 +Node: 07139446 +Node: 0740259 +Node: 06343183 +Node: 06243714 +Node: 06144019 +Node: 0644587 +Node: 05247641 +Node: 05147941 +Node: 0548364 +Node: 04949895 +Node: 04850177 +Node: 04750526 +Node: 04650935 +Node: 04551343 +Node: 04451704 +Node: 04352063 +Node: 04252266 +Node: 04152427 +Node: 0452674 +Node: 03256775 +Node: 03157178 +Node: 0357375 +Node: 02360675 +Node: 02260909 +Node: 02161189 +Node: 0261394 +Node: 0165472 +Node: Notes65573 +Node: Comparison with Org Agenda searches65735 +Node: org-sidebar66624 +Node: License66903  End Tag Table From 95abce2340efabecc6f07626eb3f28159929709f Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 14 Sep 2023 08:10:49 -0500 Subject: [PATCH 42/72] Fix: (org-ql-completing-read) :query-prefix prevented selection COMPLETING-READ, when used with its REQUIRE-MATCH argument, would not allow a result to be selected when ORG-QL-FIND was called with its QUERY-PREFIX argument. This change moves where the query is modified to include the prefix, putting it into the RUN-QUERY function instead of the COLLECTION function. It seems to solve the problem, and the function seems to still work when used without QUERY-PREFIX. However, due to the complexity of all this (we really need a SELECTING-READ API), it wouldn't surprise me if something is later found to have been broken by it... Fixes #351. Reported-by: Daniel Fleischer --- README.org | 1 + org-ql-completing-read.el | 4 +-- org-ql.info | 66 +++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/README.org b/README.org index 4e499a6..cc926a5 100644 --- a/README.org +++ b/README.org @@ -547,6 +547,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~). ++ Use of ~org-ql-find~ with ~:query-prefix~ argument prevented selection of results. ([[https://github.com/alphapapa/org-ql/issues/351][#351]]. Thanks to [[https://github.com/danielfleischer][Daniel Fleischer]] for reporting.) ** 0.7.1 diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 47b6c35..aa6b887 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -172,8 +172,6 @@ single predicate)." ;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred)) (all-completions string table pred)) (collection (input _pred flag) - (when query-prefix - (setf input (concat query-prefix input))) (pcase flag ('metadata (list 'metadata (cons 'group-function #'group) @@ -224,6 +222,8 @@ single predicate)." `(boundaries 0 . ,(length suffix))))) (run-query (input) ;; (debug-message "RUN-QUERY:%S" input) + (when query-prefix + (setf input (concat query-prefix input))) (unless (or (string-empty-p input) (equal last-input input)) ;; (debug-message "RUN-QUERY:%S RUNNING" input) diff --git a/org-ql.info b/org-ql.info index c120823..f2cf801 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1033,6 +1033,10 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog ‘org-ql-find’). • Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ‘org-ql-find’). + • Use of ‘org-ql-find’ with ‘:query-prefix’ argument prevented + selection of results. (#351 + (https://github.com/alphapapa/org-ql/issues/351). Thanks to Daniel + Fleischer (https://github.com/danielfleischer) for reporting.)  File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog @@ -1774,37 +1778,37 @@ Node: Links37257 Node: Tips37944 Node: Changelog38268 Node: 072-pre39053 -Node: 07139446 -Node: 0740259 -Node: 06343183 -Node: 06243714 -Node: 06144019 -Node: 0644587 -Node: 05247641 -Node: 05147941 -Node: 0548364 -Node: 04949895 -Node: 04850177 -Node: 04750526 -Node: 04650935 -Node: 04551343 -Node: 04451704 -Node: 04352063 -Node: 04252266 -Node: 04152427 -Node: 0452674 -Node: 03256775 -Node: 03157178 -Node: 0357375 -Node: 02360675 -Node: 02260909 -Node: 02161189 -Node: 0261394 -Node: 0165472 -Node: Notes65573 -Node: Comparison with Org Agenda searches65735 -Node: org-sidebar66624 -Node: License66903 +Node: 07139697 +Node: 0740510 +Node: 06343434 +Node: 06243965 +Node: 06144270 +Node: 0644838 +Node: 05247892 +Node: 05148192 +Node: 0548615 +Node: 04950146 +Node: 04850428 +Node: 04750777 +Node: 04651186 +Node: 04551594 +Node: 04451955 +Node: 04352314 +Node: 04252517 +Node: 04152678 +Node: 0452925 +Node: 03257026 +Node: 03157429 +Node: 0357626 +Node: 02360926 +Node: 02261160 +Node: 02161440 +Node: 0261645 +Node: 0165723 +Node: Notes65824 +Node: Comparison with Org Agenda searches65986 +Node: org-sidebar66875 +Node: License67154  End Tag Table From 8412d1a23d135cf80f850e6a49f9bbbebcb60100 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 22 Sep 2023 22:08:57 -0500 Subject: [PATCH 43/72] Tidy: Indentation For Emacs 29.1. --- org-ql-completing-read.el | 258 +++++++++++++++++++------------------- 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index aa6b887..1c7aa71 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -111,145 +111,145 @@ single predicate)." (cl-labels (;; (debug-message ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) (action - () (font-lock-ensure (point-at-bol) (point-at-eol)) - ;; FIXME: We want the fontified heading, and `org-heading-components' returns it - ;; without properties, so we have to use `org-get-heading', which added additional - ;; optional arguments in a certain Org version, so in those versions, it will - ;; return priority cookies and comment strings. - (let ((heading (org-link-display-format (org-entry-get (point) "ITEM")))) - (when (gethash heading table) - ;; Disambiguate heading (even adding the path isn't enough, because that could - ;; also be duplicated). - (if-let ((suffix (gethash heading disambiguations))) - (setf heading (format "%s <%s>" heading (cl-incf suffix))) - (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) - (let ((marker (point-marker))) - (puthash (propertize heading 'org-marker marker) marker table)))) + () (font-lock-ensure (point-at-bol) (point-at-eol)) + ;; FIXME: We want the fontified heading, and `org-heading-components' returns it + ;; without properties, so we have to use `org-get-heading', which added additional + ;; optional arguments in a certain Org version, so in those versions, it will + ;; return priority cookies and comment strings. + (let ((heading (org-link-display-format (org-entry-get (point) "ITEM")))) + (when (gethash heading table) + ;; Disambiguate heading (even adding the path isn't enough, because that could + ;; also be duplicated). + (if-let ((suffix (gethash heading disambiguations))) + (setf heading (format "%s <%s>" heading (cl-incf suffix))) + (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) + (let ((marker (point-marker))) + (puthash (propertize heading 'org-marker marker) marker table)))) (path (marker) - (org-with-point-at marker - (let* ((path (thread-first (org-get-outline-path nil t) - (org-format-outline-path window-width nil "") - (org-split-string ""))) - (formatted-path (if org-ql-completing-read-reverse-paths - (concat "\\" (string-join (reverse path) "\\")) - (concat "/" (string-join path "/"))))) - formatted-path))) + (org-with-point-at marker + (let* ((path (thread-first (org-get-outline-path nil t) + (org-format-outline-path window-width nil "") + (org-split-string ""))) + (formatted-path (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/"))))) + formatted-path))) (todo - (marker) (if-let (it (org-entry-get marker "TODO")) - (concat (propertize it 'face (org-get-todo-face it)) " ") - "")) + (marker) (if-let (it (org-entry-get marker "TODO")) + (concat (propertize it 'face (org-get-todo-face it)) " ") + "")) (affix (completions) - ;; (debug-message "AFFIX:%S" completions) - (cl-loop for completion in completions - for marker = (get-text-property 0 'org-marker completion) - for prefix = (todo marker) - for suffix = (concat (path marker) " " (snippet marker)) - collect (list completion prefix suffix))) + ;; (debug-message "AFFIX:%S" completions) + (cl-loop for completion in completions + for marker = (get-text-property 0 'org-marker completion) + for prefix = (todo marker) + for suffix = (concat (path marker) " " (snippet marker)) + collect (list completion prefix suffix))) (annotate (candidate) - ;; (debug-message "ANNOTATE:%S" candidate) - (while-no-input - ;; Using `while-no-input' here doesn't make it as responsive as, - ;; e.g. Helm while typing, but it seems to help a little when using the - ;; org-rifle-style snippets. - (or (snippet (get-text-property 0 'org-marker candidate)) ""))) + ;; (debug-message "ANNOTATE:%S" candidate) + (while-no-input + ;; Using `while-no-input' here doesn't make it as responsive as, + ;; e.g. Helm while typing, but it seems to help a little when using the + ;; org-rifle-style snippets. + (or (snippet (get-text-property 0 'org-marker candidate)) ""))) (snippet - (marker) (when-let - ((snippet - (org-with-point-at marker - (or (funcall org-ql-completing-read-snippet-function snippet-regexp) - (org-ql-completing-read--snippet-simple))))) - (propertize (concat " " snippet) - 'face 'org-ql-completing-read-snippet))) + (marker) (when-let + ((snippet + (org-with-point-at marker + (or (funcall org-ql-completing-read-snippet-function snippet-regexp) + (org-ql-completing-read--snippet-simple))))) + (propertize (concat " " snippet) + 'face 'org-ql-completing-read-snippet))) (group (candidate transform) - (pcase transform - (`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate)))) - (_ candidate))) + (pcase transform + (`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate)))) + (_ candidate))) (try (string _collection _pred point &optional _metadata) - ;; (debug-message "TRY: STRING:%S" string) - (cons string point)) + ;; (debug-message "TRY: STRING:%S" string) + (cons string point)) (all (string table pred _point) - ;; (debug-message "all: STRING:%S" string) - ;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred)) - (all-completions string table pred)) + ;; (debug-message "all: STRING:%S" string) + ;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred)) + (all-completions string table pred)) (collection (input _pred flag) - (pcase flag - ('metadata (list 'metadata - (cons 'group-function #'group) - (cons 'affixation-function #'affix) - (cons 'annotation-function #'annotate))) - (`t - ;; (debug-message "COLLECTION:t INPUT:%S KEYS:%S" - ;; input (hash-table-keys table)) - ;; It's not ideal to call `run-query' unconditionally here, but due to - ;; the complexity of the "Programmed Completion" API, it's basically - ;; necessary, and org-ql's caching should make it nearly free. - (run-query input) - (hash-table-keys table)) - ('lambda - ;; (debug-message "COLLECTION:lambda INPUT:%S KEYS:%S" - ;; input (hash-table-keys table)) - (if (not (hash-table-empty-p table)) - (when (gethash input table) - t) - (run-query input) - (when (gethash input table) - ;; (debug-message "COLLECTION:lambda INPUT:%S FOUND" input) - t))) - (`nil - ;; (debug-message "COLLECTION:nil INPUT:%S" input) - (if (not (hash-table-empty-p table)) - (when (gethash input table) - t) - (run-query input) - ;; (debug-message "COLLECTION:nil INPUT:%S KEYS:%S" - ;; input (hash-table-keys table)) - (cond ((hash-table-empty-p table) - nil) - ((gethash input table) - t) - (t - ;; FIXME: "it should return the longest common prefix - ;; substring of all matches otherwise"...but there's no - ;; function to compute that? At least returning an empty - ;; string doesn't seem to break anything. - input)))) - (`(boundaries . ,suffix) - ;; (debug-message "COLLECTION:boundaries INPUT:%S SUFFIX:%S KEYS:%S" - ;; input suffix (hash-table-keys table)) - ;; FIXME: This is unlikely to be correct, but I'm not even sure if it - ;; can be correct in this case since the input (e.g. "todo: foo") - ;; usually won't match a completion candidate directly. - `(boundaries 0 . ,(length suffix))))) + (pcase flag + ('metadata (list 'metadata + (cons 'group-function #'group) + (cons 'affixation-function #'affix) + (cons 'annotation-function #'annotate))) + (`t + ;; (debug-message "COLLECTION:t INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + ;; It's not ideal to call `run-query' unconditionally here, but due to + ;; the complexity of the "Programmed Completion" API, it's basically + ;; necessary, and org-ql's caching should make it nearly free. + (run-query input) + (hash-table-keys table)) + ('lambda + ;; (debug-message "COLLECTION:lambda INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + (if (not (hash-table-empty-p table)) + (when (gethash input table) + t) + (run-query input) + (when (gethash input table) + ;; (debug-message "COLLECTION:lambda INPUT:%S FOUND" input) + t))) + (`nil + ;; (debug-message "COLLECTION:nil INPUT:%S" input) + (if (not (hash-table-empty-p table)) + (when (gethash input table) + t) + (run-query input) + ;; (debug-message "COLLECTION:nil INPUT:%S KEYS:%S" + ;; input (hash-table-keys table)) + (cond ((hash-table-empty-p table) + nil) + ((gethash input table) + t) + (t + ;; FIXME: "it should return the longest common prefix + ;; substring of all matches otherwise"...but there's no + ;; function to compute that? At least returning an empty + ;; string doesn't seem to break anything. + input)))) + (`(boundaries . ,suffix) + ;; (debug-message "COLLECTION:boundaries INPUT:%S SUFFIX:%S KEYS:%S" + ;; input suffix (hash-table-keys table)) + ;; FIXME: This is unlikely to be correct, but I'm not even sure if it + ;; can be correct in this case since the input (e.g. "todo: foo") + ;; usually won't match a completion candidate directly. + `(boundaries 0 . ,(length suffix))))) (run-query (input) - ;; (debug-message "RUN-QUERY:%S" input) - (when query-prefix - (setf input (concat query-prefix input))) - (unless (or (string-empty-p input) - (equal last-input input)) - ;; (debug-message "RUN-QUERY:%S RUNNING" input) - (setf last-input input) - ;; Clear hash table each time the user changes the input. - (clrhash table) - (clrhash disambiguations) - (when query-filter - (setf input (funcall query-filter input))) - (pcase org-ql-completing-read-snippet-function - ('org-ql-completing-read--snippet-regexp - (setf query-tokens - ;; Remove any tokens that specify predicates or are too short. - (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) - (< (length it) org-ql-completing-read-snippet-minimum-token-length))) - (split-string input nil t (rx space))) - snippet-regexp - (when query-tokens - ;; Limiting each context word to 15 characters prevents - ;; excessively long, non-word strings from ending up in - ;; snippets, which can adversely affect performance. - (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) - bow (or ,@query-tokens) (0+ (not space)) - (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))))) - (org-ql-select buffers-files (org-ql--query-string-to-sexp input) - :action #'action)))) + ;; (debug-message "RUN-QUERY:%S" input) + (when query-prefix + (setf input (concat query-prefix input))) + (unless (or (string-empty-p input) + (equal last-input input)) + ;; (debug-message "RUN-QUERY:%S RUNNING" input) + (setf last-input input) + ;; Clear hash table each time the user changes the input. + (clrhash table) + (clrhash disambiguations) + (when query-filter + (setf input (funcall query-filter input))) + (pcase org-ql-completing-read-snippet-function + ('org-ql-completing-read--snippet-regexp + (setf query-tokens + ;; Remove any tokens that specify predicates or are too short. + (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) + (< (length it) org-ql-completing-read-snippet-minimum-token-length))) + (split-string input nil t (rx space))) + snippet-regexp + (when query-tokens + ;; Limiting each context word to 15 characters prevents + ;; excessively long, non-word strings from ending up in + ;; snippets, which can adversely affect performance. + (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) + bow (or ,@query-tokens) (0+ (not space)) + (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))))) + (org-ql-select buffers-files (org-ql--query-string-to-sexp input) + :action #'action)))) ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the ;; collection function while the user is typing, which can interrupt the machinery Org uses to ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being From be20dc3d5b47f4b01de3db571c936dc4c156e2cb Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 26 Sep 2023 13:41:07 -0500 Subject: [PATCH 44/72] Fix: (org-ql-find) Use org-with-point-at I keep pointing out to other people that they should use org-with-point-at, but I still have places in my own code where I need to use it, too! --- README.org | 1 + org-ql-find.el | 3 +-- org-ql.info | 63 +++++++++++++++++++++++++------------------------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.org b/README.org index cc926a5..c2dbe85 100644 --- a/README.org +++ b/README.org @@ -548,6 +548,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Use of ~org-ql-find~ with ~:query-prefix~ argument prevented selection of results. ([[https://github.com/alphapapa/org-ql/issues/351][#351]]. Thanks to [[https://github.com/danielfleischer][Daniel Fleischer]] for reporting.) ++ Handle narrowed buffers correctly in ~org-ql-find~. ** 0.7.1 diff --git a/org-ql-find.el b/org-ql-find.el index 9483c61..dd9fea9 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -83,8 +83,7 @@ single predicate)." :query-prefix query-prefix :query-filter query-filter :prompt prompt))) - (with-current-buffer (marker-buffer marker) - (goto-char marker) + (org-with-point-at marker (display-buffer (current-buffer) org-ql-find-display-buffer-action) (select-window (get-buffer-window (current-buffer))) (run-hook-with-args 'org-ql-find-goto-hook)))) diff --git a/org-ql.info b/org-ql.info index f2cf801..61ea89d 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1037,6 +1037,7 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog selection of results. (#351 (https://github.com/alphapapa/org-ql/issues/351). Thanks to Daniel Fleischer (https://github.com/danielfleischer) for reporting.) + • Handle narrowed buffers correctly in ‘org-ql-find’.  File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog @@ -1778,37 +1779,37 @@ Node: Links37257 Node: Tips37944 Node: Changelog38268 Node: 072-pre39053 -Node: 07139697 -Node: 0740510 -Node: 06343434 -Node: 06243965 -Node: 06144270 -Node: 0644838 -Node: 05247892 -Node: 05148192 -Node: 0548615 -Node: 04950146 -Node: 04850428 -Node: 04750777 -Node: 04651186 -Node: 04551594 -Node: 04451955 -Node: 04352314 -Node: 04252517 -Node: 04152678 -Node: 0452925 -Node: 03257026 -Node: 03157429 -Node: 0357626 -Node: 02360926 -Node: 02261160 -Node: 02161440 -Node: 0261645 -Node: 0165723 -Node: Notes65824 -Node: Comparison with Org Agenda searches65986 -Node: org-sidebar66875 -Node: License67154 +Node: 07139760 +Node: 0740573 +Node: 06343497 +Node: 06244028 +Node: 06144333 +Node: 0644901 +Node: 05247955 +Node: 05148255 +Node: 0548678 +Node: 04950209 +Node: 04850491 +Node: 04750840 +Node: 04651249 +Node: 04551657 +Node: 04452018 +Node: 04352377 +Node: 04252580 +Node: 04152741 +Node: 0452988 +Node: 03257089 +Node: 03157492 +Node: 0357689 +Node: 02360989 +Node: 02261223 +Node: 02161503 +Node: 0261708 +Node: 0165786 +Node: Notes65887 +Node: Comparison with Org Agenda searches66049 +Node: org-sidebar66938 +Node: License67217  End Tag Table From 56e203110b3823ff738379fcb910f78eb52d35c5 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 26 Sep 2023 20:48:59 -0500 Subject: [PATCH 45/72] Fix: (org-ql-completing-read) Warn about empty headings --- README.org | 1 + org-ql-completing-read.el | 22 ++++++++----- org-ql.info | 65 ++++++++++++++++++++------------------- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/README.org b/README.org index c2dbe85..052f8b9 100644 --- a/README.org +++ b/README.org @@ -549,6 +549,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Use of ~org-ql-find~ with ~:query-prefix~ argument prevented selection of results. ([[https://github.com/alphapapa/org-ql/issues/351][#351]]. Thanks to [[https://github.com/danielfleischer][Daniel Fleischer]] for reporting.) + Handle narrowed buffers correctly in ~org-ql-find~. ++ Warn about empty headings in ~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). ** 0.7.1 diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 1c7aa71..0c4e70e 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -117,14 +117,20 @@ single predicate)." ;; optional arguments in a certain Org version, so in those versions, it will ;; return priority cookies and comment strings. (let ((heading (org-link-display-format (org-entry-get (point) "ITEM")))) - (when (gethash heading table) - ;; Disambiguate heading (even adding the path isn't enough, because that could - ;; also be duplicated). - (if-let ((suffix (gethash heading disambiguations))) - (setf heading (format "%s <%s>" heading (cl-incf suffix))) - (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) - (let ((marker (point-marker))) - (puthash (propertize heading 'org-marker marker) marker table)))) + (if (string-empty-p heading) + ;; A heading's string can be empty, but we can't use one because it + ;; wouldn't be useful to the user; and if one is found, it's very + ;; likely to indicate an unnoticed mistake or corruption in the + ;; file: so display a warning and don't record it as a candidate. + (warn "Empty heading at %S in %S" (point) (buffer-name)) + (when (gethash heading table) + ;; Disambiguate heading (even adding the path isn't enough, because that could + ;; also be duplicated). + (if-let ((suffix (gethash heading disambiguations))) + (setf heading (format "%s <%s>" heading (cl-incf suffix))) + (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) + (let ((marker (point-marker))) + (puthash (propertize heading 'org-marker marker) marker table))))) (path (marker) (org-with-point-at marker (let* ((path (thread-first (org-get-outline-path nil t) diff --git a/org-ql.info b/org-ql.info index 61ea89d..066a184 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1038,6 +1038,9 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog (https://github.com/alphapapa/org-ql/issues/351). Thanks to Daniel Fleischer (https://github.com/danielfleischer) for reporting.) • Handle narrowed buffers correctly in ‘org-ql-find’. + • Warn about empty headings in ‘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).  File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog @@ -1779,37 +1782,37 @@ Node: Links37257 Node: Tips37944 Node: Changelog38268 Node: 072-pre39053 -Node: 07139760 -Node: 0740573 -Node: 06343497 -Node: 06244028 -Node: 06144333 -Node: 0644901 -Node: 05247955 -Node: 05148255 -Node: 0548678 -Node: 04950209 -Node: 04850491 -Node: 04750840 -Node: 04651249 -Node: 04551657 -Node: 04452018 -Node: 04352377 -Node: 04252580 -Node: 04152741 -Node: 0452988 -Node: 03257089 -Node: 03157492 -Node: 0357689 -Node: 02360989 -Node: 02261223 -Node: 02161503 -Node: 0261708 -Node: 0165786 -Node: Notes65887 -Node: Comparison with Org Agenda searches66049 -Node: org-sidebar66938 -Node: License67217 +Node: 07139972 +Node: 0740785 +Node: 06343709 +Node: 06244240 +Node: 06144545 +Node: 0645113 +Node: 05248167 +Node: 05148467 +Node: 0548890 +Node: 04950421 +Node: 04850703 +Node: 04751052 +Node: 04651461 +Node: 04551869 +Node: 04452230 +Node: 04352589 +Node: 04252792 +Node: 04152953 +Node: 0453200 +Node: 03257301 +Node: 03157704 +Node: 0357901 +Node: 02361201 +Node: 02261435 +Node: 02161715 +Node: 0261920 +Node: 0165998 +Node: Notes66099 +Node: Comparison with Org Agenda searches66261 +Node: org-sidebar67150 +Node: License67429  End Tag Table From f9d4f6241546166f98b5b3b74db4f4532620235a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 27 Sep 2023 00:21:21 -0500 Subject: [PATCH 46/72] Release: v0.7.2 --- README.org | 2 +- org-ql.el | 2 +- org-ql.info | 144 ++++++++++++++++++++++++++-------------------------- 3 files changed, 74 insertions(+), 74 deletions(-) diff --git a/README.org b/README.org index 052f8b9..6ff4a0f 100644 --- a/README.org +++ b/README.org @@ -542,7 +542,7 @@ 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. -** 0.7.2-pre +** 0.7.2 *Fixes* + Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). diff --git a/org-ql.el b/org-ql.el index 2a54768..9a3878b 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.2-pre +;; Version: 0.7.2 ;; 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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index 066a184..c1e5e13 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,7 +71,7 @@ Functions / Macros Changelog -* 0.7.2-pre: 072-pre. +* 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. @@ -992,7 +992,7 @@ releases. * Menu: -* 0.7.2-pre: 072-pre. +* 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. * 0.6.3: 063. @@ -1022,10 +1022,10 @@ releases. * 0.1: 01.  -File: README.info, Node: 072-pre, Next: 071, Up: Changelog +File: README.info, Node: 072, Next: 071, Up: Changelog -5.1 0.7.2-pre -============= +5.1 0.7.2 +========= *Fixes* • Timestamp predicates are more tolerant of partial input (e.g. @@ -1043,7 +1043,7 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog this purpose, and usually indicates unnoticed corruption).  -File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog +File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog 5.2 0.7.1 ========= @@ -1747,72 +1747,72 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1799 -Node: Screenshots1922 -Node: Installation2040 -Node: Quelpa2554 -Node: Helm support3082 -Node: Usage3485 -Node: Commands3883 -Node: org-ql-find4327 -Node: org-ql-refile4793 -Node: org-ql-search5116 -Node: helm-org-ql6812 -Node: org-ql-view7190 -Node: org-ql-view-sidebar7720 -Node: org-ql-view-recent-items8100 -Node: org-ql-sparse-tree8596 -Node: Queries9396 -Node: Non-sexp query syntax10513 -Node: General predicates12272 -Node: Ancestor/descendant predicates19259 -Node: Date/time predicates20387 -Node: Functions / Macros23511 -Node: Agenda-like views23809 -Ref: Function org-ql-block23971 -Node: Listing / acting-on results25232 -Ref: Caching25440 -Ref: Function org-ql-select26353 -Ref: Function org-ql-query28779 -Ref: Macro org-ql (deprecated)30553 -Node: Custom predicates30868 -Ref: Macro org-ql-defpred31092 -Node: Dynamic block34533 -Node: Links37257 -Node: Tips37944 -Node: Changelog38268 -Node: 072-pre39053 -Node: 07139972 -Node: 0740785 -Node: 06343709 -Node: 06244240 -Node: 06144545 -Node: 0645113 -Node: 05248167 -Node: 05148467 -Node: 0548890 -Node: 04950421 -Node: 04850703 -Node: 04751052 -Node: 04651461 -Node: 04551869 -Node: 04452230 -Node: 04352589 -Node: 04252792 -Node: 04152953 -Node: 0453200 -Node: 03257301 -Node: 03157704 -Node: 0357901 -Node: 02361201 -Node: 02261435 -Node: 02161715 -Node: 0261920 -Node: 0165998 -Node: Notes66099 -Node: Comparison with Org Agenda searches66261 -Node: org-sidebar67150 -Node: License67429 +Node: Contents1791 +Node: Screenshots1914 +Node: Installation2032 +Node: Quelpa2546 +Node: Helm support3074 +Node: Usage3477 +Node: Commands3875 +Node: org-ql-find4319 +Node: org-ql-refile4785 +Node: org-ql-search5108 +Node: helm-org-ql6804 +Node: org-ql-view7182 +Node: org-ql-view-sidebar7712 +Node: org-ql-view-recent-items8092 +Node: org-ql-sparse-tree8588 +Node: Queries9388 +Node: Non-sexp query syntax10505 +Node: General predicates12264 +Node: Ancestor/descendant predicates19251 +Node: Date/time predicates20379 +Node: Functions / Macros23503 +Node: Agenda-like views23801 +Ref: Function org-ql-block23963 +Node: Listing / acting-on results25224 +Ref: Caching25432 +Ref: Function org-ql-select26345 +Ref: Function org-ql-query28771 +Ref: Macro org-ql (deprecated)30545 +Node: Custom predicates30860 +Ref: Macro org-ql-defpred31084 +Node: Dynamic block34525 +Node: Links37249 +Node: Tips37936 +Node: Changelog38260 +Node: 07239037 +Node: 07139944 +Node: 0740753 +Node: 06343677 +Node: 06244208 +Node: 06144513 +Node: 0645081 +Node: 05248135 +Node: 05148435 +Node: 0548858 +Node: 04950389 +Node: 04850671 +Node: 04751020 +Node: 04651429 +Node: 04551837 +Node: 04452198 +Node: 04352557 +Node: 04252760 +Node: 04152921 +Node: 0453168 +Node: 03257269 +Node: 03157672 +Node: 0357869 +Node: 02361169 +Node: 02261403 +Node: 02161683 +Node: 0261888 +Node: 0165966 +Node: Notes66067 +Node: Comparison with Org Agenda searches66229 +Node: org-sidebar67118 +Node: License67397  End Tag Table From 0a0291288e17cd85b67cc95d21dc3dc875d6597b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 27 Sep 2023 13:36:18 -0500 Subject: [PATCH 47/72] Meta: v0.8-pre --- README.org | 4 ++++ org-ql.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 6ff4a0f..97cb1af 100644 --- a/README.org +++ b/README.org @@ -542,6 +542,10 @@ 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. +** 0.8-pre + +Nothing new yet. + ** 0.7.2 *Fixes* diff --git a/org-ql.el b/org-ql.el index 9a3878b..cf669c4 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.2 +;; Version: 0.8-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")) ;; Keywords: hypermedia, outlines, Org, agenda From 0e702ecb484673f8f8d85884f038fc0e84cb9bd3 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 4 Sep 2023 14:49:10 -0500 Subject: [PATCH 48/72] Change: Resolve Org element properties on 9.7+ See #364. --- org-ql-view.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/org-ql-view.el b/org-ql-view.el index d771d12..bbdada9 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -818,6 +818,20 @@ When opened, the link searches the buffer it's opened from." ;;;; Faces/properties +(defalias 'org-ql-view--resolve-element-properties + ;; It would be preferable to define this as an inline function, but + ;; that would mean that users would have to recompile org-ql when + ;; upgrading to Org 9.7 or else get weird errors. + ;; TODO(someday): Define `org-ql-view--resolve-element-properties' as inline. + (if (version<= "9.7" org-version) + (lambda (node) + "Resolve NODE's properties using `org-element-properties-resolve'." + ;; Silence warnings about `org-element-properties-resolve' + ;; being unresolved on earlier Org versions. + (with-no-warnings + (org-element-properties-resolve node 'force-undefer))) + #'identity)) + (defun org-ql-view--format-element (element) ;; This essentially needs to do what `org-agenda-format-item' does, ;; which is a lot. We are a long way from that, but it's a start. @@ -827,6 +841,7 @@ returned by `org-element-parse-buffer'. If ELEMENT is nil, return an empty string." (if (not element) "" + (setf element (org-ql-view--resolve-element-properties element)) (let* ((properties (cadr element)) ;; Remove the :parent property, which so bloats the size of ;; the properties list that it makes it essentially From 9e72bf694725adb9f1d256a4d52d6ceb7d71c6f1 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 12 Sep 2023 17:28:31 -0500 Subject: [PATCH 49/72] Fix: (org-ql-view--format-element) Check habit in source buffer See #364. --- org-ql-view.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org-ql-view.el b/org-ql-view.el index bbdada9..c81bcd7 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -892,7 +892,8 @@ return an empty string." (char-to-string) (format "[#%s]") (org-ql-view--add-priority-face))) - (habit-property (org-with-point-at (org-element-property :begin element) + (habit-property (org-with-point-at (or (org-element-property :org-hd-marker element) + (org-element-property :org-marker element)) (when (org-is-habit-p) (org-habit-parse-todo)))) (due-string (pcase (org-element-property :relative-due-date element) From 5c9d4cdb485da19546bd2a7eb5407ebe528ce1cc Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 27 Sep 2023 13:40:30 -0500 Subject: [PATCH 50/72] Docs: Update changelog --- README.org | 3 +- org-ql.info | 207 ++++++++++++++++++++++++++++------------------------ 2 files changed, 113 insertions(+), 97 deletions(-) diff --git a/README.org b/README.org index 97cb1af..3b50485 100644 --- a/README.org +++ b/README.org @@ -544,7 +544,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.8-pre -Nothing new yet. +*Compatibility* ++ 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.2 diff --git a/org-ql.info b/org-ql.info index c1e5e13..10eeb2f 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,6 +71,7 @@ Functions / Macros Changelog +* 0.8-pre: 08-pre. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -992,6 +993,7 @@ releases. * Menu: +* 0.8-pre: 08-pre. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -1022,9 +1024,21 @@ releases. * 0.1: 01.  -File: README.info, Node: 072, Next: 071, Up: Changelog +File: README.info, Node: 08-pre, Next: 072, Up: Changelog -5.1 0.7.2 +5.1 0.8-pre +=========== + +*Compatibility* + • Org v9.7’s ‘org-element’ API changes required some adjustments. + (#364 (https://github.com/alphapapa/org-ql/issues/364). Thanks to + several users for reporting, and to Ihor Radchenko + (https://github.com/yantar92) for his feedback.) + + +File: README.info, Node: 072, Next: 071, Prev: 08-pre, Up: Changelog + +5.2 0.7.2 ========= *Fixes* @@ -1045,7 +1059,7 @@ File: README.info, Node: 072, Next: 071, Up: Changelog  File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog -5.2 0.7.1 +5.3 0.7.1 ========= *Fixes* @@ -1064,7 +1078,7 @@ File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog  File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog -5.3 0.7 +5.4 0.7 ======= *Added* @@ -1124,7 +1138,7 @@ File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog  File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog -5.4 0.6.3 +5.5 0.6.3 ========= *Fixed* @@ -1140,7 +1154,7 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog  File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog -5.5 0.6.2 +5.6 0.6.2 ========= *Fixed* @@ -1151,7 +1165,7 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog  File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog -5.6 0.6.1 +5.7 0.6.1 ========= *Fixed* @@ -1169,7 +1183,7 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog  File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog -5.7 0.6 +5.8 0.6 ======= *Added* @@ -1236,7 +1250,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog  File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog -5.8 0.5.2 +5.9 0.5.2 ========= *Fixed* @@ -1247,8 +1261,8 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog  File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog -5.9 0.5.1 -========= +5.10 0.5.1 +========== *Fixed* • Custom sorting functions could corrupt the cache, causing items to @@ -1260,7 +1274,7 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog  File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog -5.10 0.5 +5.11 0.5 ======== *Added* @@ -1301,7 +1315,7 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog  File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog -5.11 0.4.9 +5.12 0.4.9 ========== *Fixed* @@ -1312,7 +1326,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog  File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog -5.12 0.4.8 +5.13 0.4.8 ========== *Fixed* @@ -1324,7 +1338,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog  File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog -5.13 0.4.7 +5.14 0.4.7 ========== *Fixed* @@ -1337,7 +1351,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog  File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog -5.14 0.4.6 +5.15 0.4.6 ========== *Fixed* @@ -1350,7 +1364,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog  File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog -5.15 0.4.5 +5.16 0.4.5 ========== *Fixed* @@ -1362,7 +1376,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.16 0.4.4 +5.17 0.4.4 ========== *Fixed* @@ -1374,7 +1388,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.17 0.4.3 +5.18 0.4.3 ========== *Fixed* @@ -1384,7 +1398,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.18 0.4.2 +5.19 0.4.2 ========== *Fixed* @@ -1393,7 +1407,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.19 0.4.1 +5.20 0.4.1 ========== *Fixed* @@ -1403,7 +1417,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.20 0.4 +5.21 0.4 ======== _Note:_ The next release, 0.5, may include changes which will require @@ -1484,7 +1498,7 @@ automatically, as they will be pushed to the ‘master’ branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.21 0.3.2 +5.22 0.3.2 ========== *Fixed* @@ -1497,7 +1511,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.22 0.3.1 +5.23 0.3.1 ========== *Fixed* @@ -1507,7 +1521,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.23 0.3 +5.24 0.3 ======== *Added* @@ -1575,7 +1589,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.24 0.2.3 +5.25 0.2.3 ========== *Fixed* @@ -1585,7 +1599,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.25 0.2.2 +5.26 0.2.2 ========== *Fixed* @@ -1596,7 +1610,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.26 0.2.1 +5.27 0.2.1 ========== *Fixed* @@ -1606,7 +1620,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.27 0.2 +5.28 0.2 ======== *Added* @@ -1689,7 +1703,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.28 0.1 +5.29 0.1 ======== First tagged release. @@ -1747,72 +1761,73 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1791 -Node: Screenshots1914 -Node: Installation2032 -Node: Quelpa2546 -Node: Helm support3074 -Node: Usage3477 -Node: Commands3875 -Node: org-ql-find4319 -Node: org-ql-refile4785 -Node: org-ql-search5108 -Node: helm-org-ql6804 -Node: org-ql-view7182 -Node: org-ql-view-sidebar7712 -Node: org-ql-view-recent-items8092 -Node: org-ql-sparse-tree8588 -Node: Queries9388 -Node: Non-sexp query syntax10505 -Node: General predicates12264 -Node: Ancestor/descendant predicates19251 -Node: Date/time predicates20379 -Node: Functions / Macros23503 -Node: Agenda-like views23801 -Ref: Function org-ql-block23963 -Node: Listing / acting-on results25224 -Ref: Caching25432 -Ref: Function org-ql-select26345 -Ref: Function org-ql-query28771 -Ref: Macro org-ql (deprecated)30545 -Node: Custom predicates30860 -Ref: Macro org-ql-defpred31084 -Node: Dynamic block34525 -Node: Links37249 -Node: Tips37936 -Node: Changelog38260 -Node: 07239037 -Node: 07139944 -Node: 0740753 -Node: 06343677 -Node: 06244208 -Node: 06144513 -Node: 0645081 -Node: 05248135 -Node: 05148435 -Node: 0548858 -Node: 04950389 -Node: 04850671 -Node: 04751020 -Node: 04651429 -Node: 04551837 -Node: 04452198 -Node: 04352557 -Node: 04252760 -Node: 04152921 -Node: 0453168 -Node: 03257269 -Node: 03157672 -Node: 0357869 -Node: 02361169 -Node: 02261403 -Node: 02161683 -Node: 0261888 -Node: 0165966 -Node: Notes66067 -Node: Comparison with Org Agenda searches66229 -Node: org-sidebar67118 -Node: License67397 +Node: Contents1810 +Node: Screenshots1933 +Node: Installation2051 +Node: Quelpa2565 +Node: Helm support3093 +Node: Usage3496 +Node: Commands3894 +Node: org-ql-find4338 +Node: org-ql-refile4804 +Node: org-ql-search5127 +Node: helm-org-ql6823 +Node: org-ql-view7201 +Node: org-ql-view-sidebar7731 +Node: org-ql-view-recent-items8111 +Node: org-ql-sparse-tree8607 +Node: Queries9407 +Node: Non-sexp query syntax10524 +Node: General predicates12283 +Node: Ancestor/descendant predicates19270 +Node: Date/time predicates20398 +Node: Functions / Macros23522 +Node: Agenda-like views23820 +Ref: Function org-ql-block23982 +Node: Listing / acting-on results25243 +Ref: Caching25451 +Ref: Function org-ql-select26364 +Ref: Function org-ql-query28790 +Ref: Macro org-ql (deprecated)30564 +Node: Custom predicates30879 +Ref: Macro org-ql-defpred31103 +Node: Dynamic block34544 +Node: Links37268 +Node: Tips37955 +Node: Changelog38279 +Node: 08-pre39075 +Node: 07239440 +Node: 07140362 +Node: 0741171 +Node: 06344095 +Node: 06244626 +Node: 06144931 +Node: 0645499 +Node: 05248553 +Node: 05148853 +Node: 0549278 +Node: 04950809 +Node: 04851091 +Node: 04751440 +Node: 04651849 +Node: 04552257 +Node: 04452618 +Node: 04352977 +Node: 04253180 +Node: 04153341 +Node: 0453588 +Node: 03257689 +Node: 03158092 +Node: 0358289 +Node: 02361589 +Node: 02261823 +Node: 02162103 +Node: 0262308 +Node: 0166386 +Node: Notes66487 +Node: Comparison with Org Agenda searches66649 +Node: org-sidebar67538 +Node: License67817  End Tag Table From 641ec0ac5094d075d46a95fc18747085bed45a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Antol=C3=ADn=20Camarena?= Date: Fri, 8 Sep 2023 13:55:36 -0600 Subject: [PATCH 51/72] Add category metadatum to org-ql-completing-read This is all that is needed to gain support for Embark actions on org-ql-find candidates. --- org-ql-completing-read.el | 1 + 1 file changed, 1 insertion(+) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 0c4e70e..e224e4b 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -180,6 +180,7 @@ single predicate)." (collection (input _pred flag) (pcase flag ('metadata (list 'metadata + (cons 'category 'org-heading) (cons 'group-function #'group) (cons 'affixation-function #'affix) (cons 'annotation-function #'annotate))) From a41dfe25ea2ae56dba66a13bf48749df63cf537d Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 27 Sep 2023 15:02:40 -0500 Subject: [PATCH 52/72] Docs: Update changelog, usage --- README.org | 9 ++++ org-ql.info | 144 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 93 insertions(+), 60 deletions(-) diff --git a/README.org b/README.org index 3b50485..fe5e9af 100644 --- a/README.org +++ b/README.org @@ -114,6 +114,8 @@ 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-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. + [[images/org-ql-find.png]] *** org-ql-refile @@ -146,6 +148,8 @@ Read ~QUERY~ and search with ~org-ql~. Interactively, prompt for these variable *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 [[https://github.com/oantolin/embark][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. + *** helm-org-ql /Note: This command uses [[#non-sexp-query-syntax][non-sexp queries]]. It is available separately in the package =helm-org-ql=./ @@ -544,7 +548,12 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.8-pre +*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]].) + *Compatibility* + + 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.2 diff --git a/org-ql.info b/org-ql.info index 10eeb2f..2101987 100644 --- a/org-ql.info +++ b/org-ql.info @@ -229,6 +229,11 @@ completion facilities with an Org QL query: • ‘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 +(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 +immediately, without having to visit the entry in its source Org buffer. +  File: README.info, Node: org-ql-refile, Next: org-ql-search, Prev: org-ql-find, Up: Commands @@ -282,6 +287,11 @@ 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 +(https://github.com/oantolin/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. +  File: README.info, Node: helm-org-ql, Next: org-ql-view, Prev: org-ql-search, Up: Commands @@ -1029,7 +1039,21 @@ File: README.info, Node: 08-pre, Next: 072, Up: Changelog 5.1 0.8-pre =========== -*Compatibility* +*Additions* + + • Function ‘org-ql-completing-read’, used by command ‘org-ql-find’, + now specifies the completion category as ‘org-heading’, providing + compatibility with Embark (https://github.com/oantolin/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 (https://github.com/alphapapa/org-ql/issues/299). + Thanks to Omar Antolín Camarena (https://github.com/oantolin), + Daniel Mendler (https://github.com/minad), and Akira Komamura + (https://github.com/akirak).) + + *Compatibility* + • Org v9.7’s ‘org-element’ API changes required some adjustments. (#364 (https://github.com/alphapapa/org-ql/issues/364). Thanks to several users for reporting, and to Ihor Radchenko @@ -1769,65 +1793,65 @@ Node: Helm support3093 Node: Usage3496 Node: Commands3894 Node: org-ql-find4338 -Node: org-ql-refile4804 -Node: org-ql-search5127 -Node: helm-org-ql6823 -Node: org-ql-view7201 -Node: org-ql-view-sidebar7731 -Node: org-ql-view-recent-items8111 -Node: org-ql-sparse-tree8607 -Node: Queries9407 -Node: Non-sexp query syntax10524 -Node: General predicates12283 -Node: Ancestor/descendant predicates19270 -Node: Date/time predicates20398 -Node: Functions / Macros23522 -Node: Agenda-like views23820 -Ref: Function org-ql-block23982 -Node: Listing / acting-on results25243 -Ref: Caching25451 -Ref: Function org-ql-select26364 -Ref: Function org-ql-query28790 -Ref: Macro org-ql (deprecated)30564 -Node: Custom predicates30879 -Ref: Macro org-ql-defpred31103 -Node: Dynamic block34544 -Node: Links37268 -Node: Tips37955 -Node: Changelog38279 -Node: 08-pre39075 -Node: 07239440 -Node: 07140362 -Node: 0741171 -Node: 06344095 -Node: 06244626 -Node: 06144931 -Node: 0645499 -Node: 05248553 -Node: 05148853 -Node: 0549278 -Node: 04950809 -Node: 04851091 -Node: 04751440 -Node: 04651849 -Node: 04552257 -Node: 04452618 -Node: 04352977 -Node: 04253180 -Node: 04153341 -Node: 0453588 -Node: 03257689 -Node: 03158092 -Node: 0358289 -Node: 02361589 -Node: 02261823 -Node: 02162103 -Node: 0262308 -Node: 0166386 -Node: Notes66487 -Node: Comparison with Org Agenda searches66649 -Node: org-sidebar67538 -Node: License67817 +Node: org-ql-refile5077 +Node: org-ql-search5400 +Node: helm-org-ql7331 +Node: org-ql-view7709 +Node: org-ql-view-sidebar8239 +Node: org-ql-view-recent-items8619 +Node: org-ql-sparse-tree9115 +Node: Queries9915 +Node: Non-sexp query syntax11032 +Node: General predicates12791 +Node: Ancestor/descendant predicates19778 +Node: Date/time predicates20906 +Node: Functions / Macros24030 +Node: Agenda-like views24328 +Ref: Function org-ql-block24490 +Node: Listing / acting-on results25751 +Ref: Caching25959 +Ref: Function org-ql-select26872 +Ref: Function org-ql-query29298 +Ref: Macro org-ql (deprecated)31072 +Node: Custom predicates31387 +Ref: Macro org-ql-defpred31611 +Node: Dynamic block35052 +Node: Links37776 +Node: Tips38463 +Node: Changelog38787 +Node: 08-pre39583 +Node: 07240645 +Node: 07141567 +Node: 0742376 +Node: 06345300 +Node: 06245831 +Node: 06146136 +Node: 0646704 +Node: 05249758 +Node: 05150058 +Node: 0550483 +Node: 04952014 +Node: 04852296 +Node: 04752645 +Node: 04653054 +Node: 04553462 +Node: 04453823 +Node: 04354182 +Node: 04254385 +Node: 04154546 +Node: 0454793 +Node: 03258894 +Node: 03159297 +Node: 0359494 +Node: 02362794 +Node: 02263028 +Node: 02163308 +Node: 0263513 +Node: 0167591 +Node: Notes67692 +Node: Comparison with Org Agenda searches67854 +Node: org-sidebar68743 +Node: License69022  End Tag Table From ab720689e9385795efa34d787fcfb7d0e5d0bb38 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 30 Sep 2023 20:09:12 -0500 Subject: [PATCH 53/72] Change: (org-ql-find) Interactively, search relevant buffers --- README.org | 1 + org-ql-find.el | 16 +++++++----- org-ql.info | 67 ++++++++++++++++++++++++++------------------------ 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/README.org b/README.org index fe5e9af..5a6febd 100644 --- a/README.org +++ b/README.org @@ -551,6 +551,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *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]].) ++ 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. *Compatibility* diff --git a/org-ql-find.el b/org-ql-find.el index dd9fea9..b5db3c8 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -54,8 +54,11 @@ See function `display-buffer'." (cl-defun org-ql-find (buffers-files &key query-prefix query-filter (prompt "Find entry: ")) "Go to an Org entry in BUFFERS-FILES selected by searching entries with `org-ql'. -Interactively, with universal prefix, select multiple buffers to -search with completion and PROMPT. +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. QUERY-PREFIX may be a string to prepend to the query (e.g. use \"heading:\" to only search headings, easily creating a custom @@ -75,10 +78,11 @@ single predicate)." 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))))) + (pcase major-mode + ((pred (derived-mode-p 'org-agenda-mode)) (or org-ql-view-buffers-files + org-agenda-contributing-files)) + ((pred (derived-mode-p 'org-mode)) (current-buffer)) + (_ (user-error "This is not an Org-related buffer: %S" (current-buffer))))))) (let ((marker (org-ql-completing-read buffers-files :query-prefix query-prefix :query-filter query-filter diff --git a/org-ql.info b/org-ql.info index 2101987..f9a2e71 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1051,6 +1051,9 @@ File: README.info, Node: 08-pre, Next: 072, Up: Changelog Thanks to Omar Antolín Camarena (https://github.com/oantolin), Daniel Mendler (https://github.com/minad), and Akira Komamura (https://github.com/akirak).) + • 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. *Compatibility* @@ -1820,38 +1823,38 @@ Node: Links37776 Node: Tips38463 Node: Changelog38787 Node: 08-pre39583 -Node: 07240645 -Node: 07141567 -Node: 0742376 -Node: 06345300 -Node: 06245831 -Node: 06146136 -Node: 0646704 -Node: 05249758 -Node: 05150058 -Node: 0550483 -Node: 04952014 -Node: 04852296 -Node: 04752645 -Node: 04653054 -Node: 04553462 -Node: 04453823 -Node: 04354182 -Node: 04254385 -Node: 04154546 -Node: 0454793 -Node: 03258894 -Node: 03159297 -Node: 0359494 -Node: 02362794 -Node: 02263028 -Node: 02163308 -Node: 0263513 -Node: 0167591 -Node: Notes67692 -Node: Comparison with Org Agenda searches67854 -Node: org-sidebar68743 -Node: License69022 +Node: 07240820 +Node: 07141742 +Node: 0742551 +Node: 06345475 +Node: 06246006 +Node: 06146311 +Node: 0646879 +Node: 05249933 +Node: 05150233 +Node: 0550658 +Node: 04952189 +Node: 04852471 +Node: 04752820 +Node: 04653229 +Node: 04553637 +Node: 04453998 +Node: 04354357 +Node: 04254560 +Node: 04154721 +Node: 0454968 +Node: 03259069 +Node: 03159472 +Node: 0359669 +Node: 02362969 +Node: 02263203 +Node: 02163483 +Node: 0263688 +Node: 0167766 +Node: Notes67867 +Node: Comparison with Org Agenda searches68029 +Node: org-sidebar68918 +Node: License69197  End Tag Table From 6d5b614fc5844420b3c3f5e0aec184e1e9027c04 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 2 Oct 2023 22:52:25 -0500 Subject: [PATCH 54/72] Fix: (org-ql-find) Interactive form Fixes silly mistake in ab720689e9385795efa34d787fcfb7d0e5d0bb38. --- org-ql-find.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/org-ql-find.el b/org-ql-find.el index b5db3c8..154f934 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -78,11 +78,10 @@ single predicate)." when (eq 'org-mode (buffer-local-value 'major-mode buffer)) collect (buffer-name buffer)) nil t)) - (pcase major-mode - ((pred (derived-mode-p 'org-agenda-mode)) (or org-ql-view-buffers-files - org-agenda-contributing-files)) - ((pred (derived-mode-p 'org-mode)) (current-buffer)) - (_ (user-error "This is not an Org-related buffer: %S" (current-buffer))))))) + (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 :query-prefix query-prefix :query-filter query-filter From ac2d43588aa96f0b7fe88f518d6fca4fd65b5aa0 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 19 Oct 2023 21:43:53 -0500 Subject: [PATCH 55/72] Add: (org-ql-find-path) --- README.org | 2 + org-ql-find.el | 7 +++ org-ql.info | 121 +++++++++++++++++++++++++------------------------ 3 files changed, 71 insertions(+), 59 deletions(-) diff --git a/README.org b/README.org index 5a6febd..d7d3587 100644 --- a/README.org +++ b/README.org @@ -111,6 +111,7 @@ Lisp code examples are in [[examples.org]]. 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~. @@ -552,6 +553,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + 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-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. *Compatibility* diff --git a/org-ql-find.el b/org-ql-find.el index 154f934..c1848ea 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -132,6 +132,13 @@ which see (but only the files are used)." (interactive) (org-ql-find (org-ql-search-directories-files))) +;;;###autoload +(defun org-ql-find-path () + "Call `org-ql-find' to search outline paths in the current buffer." + (interactive) + (let ((org-ql-default-predicate 'outline-path)) + (org-ql-find (current-buffer)))) + (provide 'org-ql-find) ;;; org-ql-find.el ends here diff --git a/org-ql.info b/org-ql.info index f9a2e71..fae9944 100644 --- a/org-ql.info +++ b/org-ql.info @@ -226,6 +226,7 @@ _Note: These commands use ._ 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’. @@ -1054,6 +1055,8 @@ File: README.info, Node: 08-pre, Next: 072, Up: Changelog • 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. *Compatibility* @@ -1796,65 +1799,65 @@ Node: Helm support3093 Node: Usage3496 Node: Commands3894 Node: org-ql-find4338 -Node: org-ql-refile5077 -Node: org-ql-search5400 -Node: helm-org-ql7331 -Node: org-ql-view7709 -Node: org-ql-view-sidebar8239 -Node: org-ql-view-recent-items8619 -Node: org-ql-sparse-tree9115 -Node: Queries9915 -Node: Non-sexp query syntax11032 -Node: General predicates12791 -Node: Ancestor/descendant predicates19778 -Node: Date/time predicates20906 -Node: Functions / Macros24030 -Node: Agenda-like views24328 -Ref: Function org-ql-block24490 -Node: Listing / acting-on results25751 -Ref: Caching25959 -Ref: Function org-ql-select26872 -Ref: Function org-ql-query29298 -Ref: Macro org-ql (deprecated)31072 -Node: Custom predicates31387 -Ref: Macro org-ql-defpred31611 -Node: Dynamic block35052 -Node: Links37776 -Node: Tips38463 -Node: Changelog38787 -Node: 08-pre39583 -Node: 07240820 -Node: 07141742 -Node: 0742551 -Node: 06345475 -Node: 06246006 -Node: 06146311 -Node: 0646879 -Node: 05249933 -Node: 05150233 -Node: 0550658 -Node: 04952189 -Node: 04852471 -Node: 04752820 -Node: 04653229 -Node: 04553637 -Node: 04453998 -Node: 04354357 -Node: 04254560 -Node: 04154721 -Node: 0454968 -Node: 03259069 -Node: 03159472 -Node: 0359669 -Node: 02362969 -Node: 02263203 -Node: 02163483 -Node: 0263688 -Node: 0167766 -Node: Notes67867 -Node: Comparison with Org Agenda searches68029 -Node: org-sidebar68918 -Node: License69197 +Node: org-ql-refile5153 +Node: org-ql-search5476 +Node: helm-org-ql7407 +Node: org-ql-view7785 +Node: org-ql-view-sidebar8315 +Node: org-ql-view-recent-items8695 +Node: org-ql-sparse-tree9191 +Node: Queries9991 +Node: Non-sexp query syntax11108 +Node: General predicates12867 +Node: Ancestor/descendant predicates19854 +Node: Date/time predicates20982 +Node: Functions / Macros24106 +Node: Agenda-like views24404 +Ref: Function org-ql-block24566 +Node: Listing / acting-on results25827 +Ref: Caching26035 +Ref: Function org-ql-select26948 +Ref: Function org-ql-query29374 +Ref: Macro org-ql (deprecated)31148 +Node: Custom predicates31463 +Ref: Macro org-ql-defpred31687 +Node: Dynamic block35128 +Node: Links37852 +Node: Tips38539 +Node: Changelog38863 +Node: 08-pre39659 +Node: 07240992 +Node: 07141914 +Node: 0742723 +Node: 06345647 +Node: 06246178 +Node: 06146483 +Node: 0647051 +Node: 05250105 +Node: 05150405 +Node: 0550830 +Node: 04952361 +Node: 04852643 +Node: 04752992 +Node: 04653401 +Node: 04553809 +Node: 04454170 +Node: 04354529 +Node: 04254732 +Node: 04154893 +Node: 0455140 +Node: 03259241 +Node: 03159644 +Node: 0359841 +Node: 02363141 +Node: 02263375 +Node: 02163655 +Node: 0263860 +Node: 0167938 +Node: Notes68039 +Node: Comparison with Org Agenda searches68201 +Node: org-sidebar69090 +Node: License69369  End Tag Table From daad25e079c5245289ac88313b423858d3793637 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 19 Oct 2023 21:45:22 -0500 Subject: [PATCH 56/72] Meta: v0.7.3-pre --- README.org | 4 ++ org-ql.el | 2 +- org-ql.info | 203 +++++++++++++++++++++++++++------------------------- 3 files changed, 112 insertions(+), 97 deletions(-) diff --git a/README.org b/README.org index 6ff4a0f..d454d6b 100644 --- a/README.org +++ b/README.org @@ -542,6 +542,10 @@ 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. +** 0.7.3-pre + +Nothing new yet. + ** 0.7.2 *Fixes* diff --git a/org-ql.el b/org-ql.el index 9a3878b..862d20f 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.2 +;; Version: 0.7.3-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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index c1e5e13..66fb70a 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,6 +71,7 @@ Functions / Macros Changelog +* 0.7.3-pre: 073-pre. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -992,6 +993,7 @@ releases. * Menu: +* 0.7.3-pre: 073-pre. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -1022,9 +1024,17 @@ releases. * 0.1: 01.  -File: README.info, Node: 072, Next: 071, Up: Changelog +File: README.info, Node: 073-pre, Next: 072, Up: Changelog -5.1 0.7.2 +5.1 0.7.3-pre +============= + +Nothing new yet. + + +File: README.info, Node: 072, Next: 071, Prev: 073-pre, Up: Changelog + +5.2 0.7.2 ========= *Fixes* @@ -1045,7 +1055,7 @@ File: README.info, Node: 072, Next: 071, Up: Changelog  File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog -5.2 0.7.1 +5.3 0.7.1 ========= *Fixes* @@ -1064,7 +1074,7 @@ File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog  File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog -5.3 0.7 +5.4 0.7 ======= *Added* @@ -1124,7 +1134,7 @@ File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog  File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog -5.4 0.6.3 +5.5 0.6.3 ========= *Fixed* @@ -1140,7 +1150,7 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog  File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog -5.5 0.6.2 +5.6 0.6.2 ========= *Fixed* @@ -1151,7 +1161,7 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog  File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog -5.6 0.6.1 +5.7 0.6.1 ========= *Fixed* @@ -1169,7 +1179,7 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog  File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog -5.7 0.6 +5.8 0.6 ======= *Added* @@ -1236,7 +1246,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog  File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog -5.8 0.5.2 +5.9 0.5.2 ========= *Fixed* @@ -1247,8 +1257,8 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog  File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog -5.9 0.5.1 -========= +5.10 0.5.1 +========== *Fixed* • Custom sorting functions could corrupt the cache, causing items to @@ -1260,7 +1270,7 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog  File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog -5.10 0.5 +5.11 0.5 ======== *Added* @@ -1301,7 +1311,7 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog  File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog -5.11 0.4.9 +5.12 0.4.9 ========== *Fixed* @@ -1312,7 +1322,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog  File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog -5.12 0.4.8 +5.13 0.4.8 ========== *Fixed* @@ -1324,7 +1334,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog  File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog -5.13 0.4.7 +5.14 0.4.7 ========== *Fixed* @@ -1337,7 +1347,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog  File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog -5.14 0.4.6 +5.15 0.4.6 ========== *Fixed* @@ -1350,7 +1360,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog  File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog -5.15 0.4.5 +5.16 0.4.5 ========== *Fixed* @@ -1362,7 +1372,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.16 0.4.4 +5.17 0.4.4 ========== *Fixed* @@ -1374,7 +1384,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.17 0.4.3 +5.18 0.4.3 ========== *Fixed* @@ -1384,7 +1394,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.18 0.4.2 +5.19 0.4.2 ========== *Fixed* @@ -1393,7 +1403,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.19 0.4.1 +5.20 0.4.1 ========== *Fixed* @@ -1403,7 +1413,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.20 0.4 +5.21 0.4 ======== _Note:_ The next release, 0.5, may include changes which will require @@ -1484,7 +1494,7 @@ automatically, as they will be pushed to the ‘master’ branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.21 0.3.2 +5.22 0.3.2 ========== *Fixed* @@ -1497,7 +1507,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.22 0.3.1 +5.23 0.3.1 ========== *Fixed* @@ -1507,7 +1517,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.23 0.3 +5.24 0.3 ======== *Added* @@ -1575,7 +1585,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.24 0.2.3 +5.25 0.2.3 ========== *Fixed* @@ -1585,7 +1595,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.25 0.2.2 +5.26 0.2.2 ========== *Fixed* @@ -1596,7 +1606,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.26 0.2.1 +5.27 0.2.1 ========== *Fixed* @@ -1606,7 +1616,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.27 0.2 +5.28 0.2 ======== *Added* @@ -1689,7 +1699,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.28 0.1 +5.29 0.1 ======== First tagged release. @@ -1747,72 +1757,73 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1791 -Node: Screenshots1914 -Node: Installation2032 -Node: Quelpa2546 -Node: Helm support3074 -Node: Usage3477 -Node: Commands3875 -Node: org-ql-find4319 -Node: org-ql-refile4785 -Node: org-ql-search5108 -Node: helm-org-ql6804 -Node: org-ql-view7182 -Node: org-ql-view-sidebar7712 -Node: org-ql-view-recent-items8092 -Node: org-ql-sparse-tree8588 -Node: Queries9388 -Node: Non-sexp query syntax10505 -Node: General predicates12264 -Node: Ancestor/descendant predicates19251 -Node: Date/time predicates20379 -Node: Functions / Macros23503 -Node: Agenda-like views23801 -Ref: Function org-ql-block23963 -Node: Listing / acting-on results25224 -Ref: Caching25432 -Ref: Function org-ql-select26345 -Ref: Function org-ql-query28771 -Ref: Macro org-ql (deprecated)30545 -Node: Custom predicates30860 -Ref: Macro org-ql-defpred31084 -Node: Dynamic block34525 -Node: Links37249 -Node: Tips37936 -Node: Changelog38260 -Node: 07239037 -Node: 07139944 -Node: 0740753 -Node: 06343677 -Node: 06244208 -Node: 06144513 -Node: 0645081 -Node: 05248135 -Node: 05148435 -Node: 0548858 -Node: 04950389 -Node: 04850671 -Node: 04751020 -Node: 04651429 -Node: 04551837 -Node: 04452198 -Node: 04352557 -Node: 04252760 -Node: 04152921 -Node: 0453168 -Node: 03257269 -Node: 03157672 -Node: 0357869 -Node: 02361169 -Node: 02261403 -Node: 02161683 -Node: 0261888 -Node: 0165966 -Node: Notes66067 -Node: Comparison with Org Agenda searches66229 -Node: org-sidebar67118 -Node: License67397 +Node: Contents1813 +Node: Screenshots1936 +Node: Installation2054 +Node: Quelpa2568 +Node: Helm support3096 +Node: Usage3499 +Node: Commands3897 +Node: org-ql-find4341 +Node: org-ql-refile4807 +Node: org-ql-search5130 +Node: helm-org-ql6826 +Node: org-ql-view7204 +Node: org-ql-view-sidebar7734 +Node: org-ql-view-recent-items8114 +Node: org-ql-sparse-tree8610 +Node: Queries9410 +Node: Non-sexp query syntax10527 +Node: General predicates12286 +Node: Ancestor/descendant predicates19273 +Node: Date/time predicates20401 +Node: Functions / Macros23525 +Node: Agenda-like views23823 +Ref: Function org-ql-block23985 +Node: Listing / acting-on results25246 +Ref: Caching25454 +Ref: Function org-ql-select26367 +Ref: Function org-ql-query28793 +Ref: Macro org-ql (deprecated)30567 +Node: Custom predicates30882 +Ref: Macro org-ql-defpred31106 +Node: Dynamic block34547 +Node: Links37271 +Node: Tips37958 +Node: Changelog38282 +Node: 073-pre39081 +Node: 07239193 +Node: 07140116 +Node: 0740925 +Node: 06343849 +Node: 06244380 +Node: 06144685 +Node: 0645253 +Node: 05248307 +Node: 05148607 +Node: 0549032 +Node: 04950563 +Node: 04850845 +Node: 04751194 +Node: 04651603 +Node: 04552011 +Node: 04452372 +Node: 04352731 +Node: 04252934 +Node: 04153095 +Node: 0453342 +Node: 03257443 +Node: 03157846 +Node: 0358043 +Node: 02361343 +Node: 02261577 +Node: 02161857 +Node: 0262062 +Node: 0166140 +Node: Notes66241 +Node: Comparison with Org Agenda searches66403 +Node: org-sidebar67292 +Node: License67571  End Tag Table From 4476759dc97b87b7601cea9b1368d0a48e42cea3 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 19 Oct 2023 21:47:34 -0500 Subject: [PATCH 57/72] Fix: (org-ql--outline-path) Disable case-fold-search --- README.org | 3 ++- org-ql.el | 7 +++--- org-ql.info | 70 ++++++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/README.org b/README.org index d454d6b..c2376c6 100644 --- a/README.org +++ b/README.org @@ -544,7 +544,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.7.3-pre -Nothing new yet. +*Fixes* ++ Disable ~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.) ** 0.7.2 diff --git a/org-ql.el b/org-ql.el index 862d20f..b4d8cd9 100644 --- a/org-ql.el +++ b/org-ql.el @@ -624,9 +624,10 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)." "Return outline path for heading at point." (save-excursion (let ((heading (save-match-data - (if (looking-at org-complex-heading-regexp) - (or (match-string 4) "") - "")))) + (let (case-fold-search) + (if (looking-at org-complex-heading-regexp) + (or (match-string-no-properties 4) "") + ""))))) (if (org-up-heading-safe) ;; MAYBE: It seems wrong to call the cache function from ;; inside this function, like a violation of separation of diff --git a/org-ql.info b/org-ql.info index 66fb70a..cae7ef3 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1029,7 +1029,11 @@ File: README.info, Node: 073-pre, Next: 072, Up: Changelog 5.1 0.7.3-pre ============= -Nothing new yet. +*Fixes* + • Disable ‘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.)  File: README.info, Node: 072, Next: 071, Prev: 073-pre, Up: Changelog @@ -1792,38 +1796,38 @@ Node: Links37271 Node: Tips37958 Node: Changelog38282 Node: 073-pre39081 -Node: 07239193 -Node: 07140116 -Node: 0740925 -Node: 06343849 -Node: 06244380 -Node: 06144685 -Node: 0645253 -Node: 05248307 -Node: 05148607 -Node: 0549032 -Node: 04950563 -Node: 04850845 -Node: 04751194 -Node: 04651603 -Node: 04552011 -Node: 04452372 -Node: 04352731 -Node: 04252934 -Node: 04153095 -Node: 0453342 -Node: 03257443 -Node: 03157846 -Node: 0358043 -Node: 02361343 -Node: 02261577 -Node: 02161857 -Node: 0262062 -Node: 0166140 -Node: Notes66241 -Node: Comparison with Org Agenda searches66403 -Node: org-sidebar67292 -Node: License67571 +Node: 07239410 +Node: 07140333 +Node: 0741142 +Node: 06344066 +Node: 06244597 +Node: 06144902 +Node: 0645470 +Node: 05248524 +Node: 05148824 +Node: 0549249 +Node: 04950780 +Node: 04851062 +Node: 04751411 +Node: 04651820 +Node: 04552228 +Node: 04452589 +Node: 04352948 +Node: 04253151 +Node: 04153312 +Node: 0453559 +Node: 03257660 +Node: 03158063 +Node: 0358260 +Node: 02361560 +Node: 02261794 +Node: 02162074 +Node: 0262279 +Node: 0166357 +Node: Notes66458 +Node: Comparison with Org Agenda searches66620 +Node: org-sidebar67509 +Node: License67788  End Tag Table From 09c35915043a69c73fa08dfc73a2bc7f5823698c Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 19 Oct 2023 21:50:30 -0500 Subject: [PATCH 58/72] Fix: Saving of org-ql-view views It didn't seem that calling custom-save-all was necessary in the past, but it appears that it is now. Closes #378. Reported-by: Pentaquark1 --- README.org | 1 + org-ql-view.el | 6 +++-- org-ql.info | 67 ++++++++++++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/README.org b/README.org index c2376c6..4bc9605 100644 --- a/README.org +++ b/README.org @@ -546,6 +546,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Disable ~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.) ++ Saving of ~org-ql-view~ views. ([[https://github.com/alphapapa/org-ql/issues/378][#378]]. Thanks to [[https://github.com/Pentaquark1][Pentaquark1]] for reporting.) ** 0.7.2 diff --git a/org-ql-view.el b/org-ql-view.el index d771d12..ea568d4 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -352,7 +352,8 @@ update search arguments." (yes-or-no-p (format "Overwrite view \"%s\"?" name))) (setf (map-elt org-ql-views name nil #'equal) plist) (customize-set-variable 'org-ql-views org-ql-views) - (customize-mark-to-save 'org-ql-views)))) + (customize-mark-to-save 'org-ql-views) + (custom-save-all)))) (defun org-ql-view-delete () "Delete current view (with confirmation)." @@ -362,7 +363,8 @@ update search arguments." (--remove (equal (car it) org-ql-view-title) org-ql-views)) (customize-set-variable 'org-ql-views org-ql-views) - (customize-mark-to-save 'org-ql-views))) + (customize-mark-to-save 'org-ql-views) + (custom-save-all))) (defun org-ql-view-customize () "Customize view at point in `org-ql-view-sidebar' buffer." diff --git a/org-ql.info b/org-ql.info index cae7ef3..891b2e0 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1034,6 +1034,9 @@ File: README.info, Node: 073-pre, Next: 072, Up: Changelog paths. (Headings that started with a word that is also a to-do keyword but with different capitalization would be matched incorrectly.) + • Saving of ‘org-ql-view’ views. (#378 + (https://github.com/alphapapa/org-ql/issues/378). Thanks to + Pentaquark1 (https://github.com/Pentaquark1) for reporting.)  File: README.info, Node: 072, Next: 071, Prev: 073-pre, Up: Changelog @@ -1796,38 +1799,38 @@ Node: Links37271 Node: Tips37958 Node: Changelog38282 Node: 073-pre39081 -Node: 07239410 -Node: 07140333 -Node: 0741142 -Node: 06344066 -Node: 06244597 -Node: 06144902 -Node: 0645470 -Node: 05248524 -Node: 05148824 -Node: 0549249 -Node: 04950780 -Node: 04851062 -Node: 04751411 -Node: 04651820 -Node: 04552228 -Node: 04452589 -Node: 04352948 -Node: 04253151 -Node: 04153312 -Node: 0453559 -Node: 03257660 -Node: 03158063 -Node: 0358260 -Node: 02361560 -Node: 02261794 -Node: 02162074 -Node: 0262279 -Node: 0166357 -Node: Notes66458 -Node: Comparison with Org Agenda searches66620 -Node: org-sidebar67509 -Node: License67788 +Node: 07239591 +Node: 07140514 +Node: 0741323 +Node: 06344247 +Node: 06244778 +Node: 06145083 +Node: 0645651 +Node: 05248705 +Node: 05149005 +Node: 0549430 +Node: 04950961 +Node: 04851243 +Node: 04751592 +Node: 04652001 +Node: 04552409 +Node: 04452770 +Node: 04353129 +Node: 04253332 +Node: 04153493 +Node: 0453740 +Node: 03257841 +Node: 03158244 +Node: 0358441 +Node: 02361741 +Node: 02261975 +Node: 02162255 +Node: 0262460 +Node: 0166538 +Node: Notes66639 +Node: Comparison with Org Agenda searches66801 +Node: org-sidebar67690 +Node: License67969  End Tag Table From de80f9a7645176a973434132320eb11683019e2a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 23 Oct 2023 01:23:48 -0500 Subject: [PATCH 59/72] Comment: Add TODO --- org-ql-find.el | 1 + 1 file changed, 1 insertion(+) diff --git a/org-ql-find.el b/org-ql-find.el index dd9fea9..e3b9a49 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -41,6 +41,7 @@ (defcustom org-ql-find-goto-hook '(org-show-entry org-reveal) "Functions called when selecting an entry." + ;; TODO: Add common choices, including `org-tree-to-indirect-buffer'. :type 'hook) (defcustom org-ql-find-display-buffer-action '(display-buffer-same-window) From 631cd80ce870b5bec6609eea8f0f4123876bf1cf Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 23 Oct 2023 01:23:54 -0500 Subject: [PATCH 60/72] Fix: (org-ql-find) Go to selected entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #380. Reported-by: Omar Antolín Camarena --- README.org | 1 + org-ql-find.el | 9 ++++--- org-ql.info | 67 ++++++++++++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/README.org b/README.org index 4bc9605..4ad1187 100644 --- a/README.org +++ b/README.org @@ -547,6 +547,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Fixes* + Disable ~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.) + Saving of ~org-ql-view~ views. ([[https://github.com/alphapapa/org-ql/issues/378][#378]]. Thanks to [[https://github.com/Pentaquark1][Pentaquark1]] for reporting.) ++ Command ~org-ql-find~ didn't move point to the selected entry. ([[https://github.com/alphapapa/org-ql/issues/380][#380]]. Thanks to [[https://github.com/oantolin][Omar Antolín Camarena]] for reporting.) ** 0.7.2 diff --git a/org-ql-find.el b/org-ql-find.el index e3b9a49..768f0af 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -84,10 +84,11 @@ single predicate)." :query-prefix query-prefix :query-filter query-filter :prompt prompt))) - (org-with-point-at marker - (display-buffer (current-buffer) org-ql-find-display-buffer-action) - (select-window (get-buffer-window (current-buffer))) - (run-hook-with-args 'org-ql-find-goto-hook)))) + (set-buffer (marker-buffer marker)) + (goto-char marker) + (display-buffer (current-buffer) org-ql-find-display-buffer-action) + (select-window (get-buffer-window (current-buffer))) + (run-hook-with-args 'org-ql-find-goto-hook))) ;;;###autoload (defun org-ql-refile (marker) diff --git a/org-ql.info b/org-ql.info index 891b2e0..eef7814 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1037,6 +1037,9 @@ File: README.info, Node: 073-pre, Next: 072, Up: Changelog • Saving of ‘org-ql-view’ views. (#378 (https://github.com/alphapapa/org-ql/issues/378). Thanks to Pentaquark1 (https://github.com/Pentaquark1) for reporting.) + • Command ‘org-ql-find’ didn’t move point to the selected entry. + (#380 (https://github.com/alphapapa/org-ql/issues/380). Thanks to + Omar Antolín Camarena (https://github.com/oantolin) for reporting.)  File: README.info, Node: 072, Next: 071, Prev: 073-pre, Up: Changelog @@ -1799,38 +1802,38 @@ Node: Links37271 Node: Tips37958 Node: Changelog38282 Node: 073-pre39081 -Node: 07239591 -Node: 07140514 -Node: 0741323 -Node: 06344247 -Node: 06244778 -Node: 06145083 -Node: 0645651 -Node: 05248705 -Node: 05149005 -Node: 0549430 -Node: 04950961 -Node: 04851243 -Node: 04751592 -Node: 04652001 -Node: 04552409 -Node: 04452770 -Node: 04353129 -Node: 04253332 -Node: 04153493 -Node: 0453740 -Node: 03257841 -Node: 03158244 -Node: 0358441 -Node: 02361741 -Node: 02261975 -Node: 02162255 -Node: 0262460 -Node: 0166538 -Node: Notes66639 -Node: Comparison with Org Agenda searches66801 -Node: org-sidebar67690 -Node: License67969 +Node: 07239813 +Node: 07140736 +Node: 0741545 +Node: 06344469 +Node: 06245000 +Node: 06145305 +Node: 0645873 +Node: 05248927 +Node: 05149227 +Node: 0549652 +Node: 04951183 +Node: 04851465 +Node: 04751814 +Node: 04652223 +Node: 04552631 +Node: 04452992 +Node: 04353351 +Node: 04253554 +Node: 04153715 +Node: 0453962 +Node: 03258063 +Node: 03158466 +Node: 0358663 +Node: 02361963 +Node: 02262197 +Node: 02162477 +Node: 0262682 +Node: 0166760 +Node: Notes66861 +Node: Comparison with Org Agenda searches67023 +Node: org-sidebar67912 +Node: License68191  End Tag Table From 28c4215704031e05190c17932b5e683bb462d9e5 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 23 Oct 2023 18:52:04 -0500 Subject: [PATCH 61/72] Release: v0.7.3 --- README.org | 2 +- org-ql.el | 2 +- org-ql.info | 146 ++++++++++++++++++++++++++-------------------------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/README.org b/README.org index 4ad1187..b8893e0 100644 --- a/README.org +++ b/README.org @@ -542,7 +542,7 @@ 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. -** 0.7.3-pre +** 0.7.3 *Fixes* + Disable ~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.) diff --git a/org-ql.el b/org-ql.el index b4d8cd9..1bf1900 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.7.3-pre +;; Version: 0.7.3 ;; 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")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index eef7814..94eb443 100644 --- a/org-ql.info +++ b/org-ql.info @@ -71,7 +71,7 @@ Functions / Macros Changelog -* 0.7.3-pre: 073-pre. +* 0.7.3: 073. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -993,7 +993,7 @@ releases. * Menu: -* 0.7.3-pre: 073-pre. +* 0.7.3: 073. * 0.7.2: 072. * 0.7.1: 071. * 0.7: 07. @@ -1024,10 +1024,10 @@ releases. * 0.1: 01.  -File: README.info, Node: 073-pre, Next: 072, Up: Changelog +File: README.info, Node: 073, Next: 072, Up: Changelog -5.1 0.7.3-pre -============= +5.1 0.7.3 +========= *Fixes* • Disable ‘case-fold-search’ when collecting headings in outline @@ -1042,7 +1042,7 @@ File: README.info, Node: 073-pre, Next: 072, Up: Changelog Omar Antolín Camarena (https://github.com/oantolin) for reporting.)  -File: README.info, Node: 072, Next: 071, Prev: 073-pre, Up: Changelog +File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog 5.2 0.7.2 ========= @@ -1767,73 +1767,73 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1813 -Node: Screenshots1936 -Node: Installation2054 -Node: Quelpa2568 -Node: Helm support3096 -Node: Usage3499 -Node: Commands3897 -Node: org-ql-find4341 -Node: org-ql-refile4807 -Node: org-ql-search5130 -Node: helm-org-ql6826 -Node: org-ql-view7204 -Node: org-ql-view-sidebar7734 -Node: org-ql-view-recent-items8114 -Node: org-ql-sparse-tree8610 -Node: Queries9410 -Node: Non-sexp query syntax10527 -Node: General predicates12286 -Node: Ancestor/descendant predicates19273 -Node: Date/time predicates20401 -Node: Functions / Macros23525 -Node: Agenda-like views23823 -Ref: Function org-ql-block23985 -Node: Listing / acting-on results25246 -Ref: Caching25454 -Ref: Function org-ql-select26367 -Ref: Function org-ql-query28793 -Ref: Macro org-ql (deprecated)30567 -Node: Custom predicates30882 -Ref: Macro org-ql-defpred31106 -Node: Dynamic block34547 -Node: Links37271 -Node: Tips37958 -Node: Changelog38282 -Node: 073-pre39081 -Node: 07239813 -Node: 07140736 -Node: 0741545 -Node: 06344469 -Node: 06245000 -Node: 06145305 -Node: 0645873 -Node: 05248927 -Node: 05149227 -Node: 0549652 -Node: 04951183 -Node: 04851465 -Node: 04751814 -Node: 04652223 -Node: 04552631 -Node: 04452992 -Node: 04353351 -Node: 04253554 -Node: 04153715 -Node: 0453962 -Node: 03258063 -Node: 03158466 -Node: 0358663 -Node: 02361963 -Node: 02262197 -Node: 02162477 -Node: 0262682 -Node: 0166760 -Node: Notes66861 -Node: Comparison with Org Agenda searches67023 -Node: org-sidebar67912 -Node: License68191 +Node: Contents1805 +Node: Screenshots1928 +Node: Installation2046 +Node: Quelpa2560 +Node: Helm support3088 +Node: Usage3491 +Node: Commands3889 +Node: org-ql-find4333 +Node: org-ql-refile4799 +Node: org-ql-search5122 +Node: helm-org-ql6818 +Node: org-ql-view7196 +Node: org-ql-view-sidebar7726 +Node: org-ql-view-recent-items8106 +Node: org-ql-sparse-tree8602 +Node: Queries9402 +Node: Non-sexp query syntax10519 +Node: General predicates12278 +Node: Ancestor/descendant predicates19265 +Node: Date/time predicates20393 +Node: Functions / Macros23517 +Node: Agenda-like views23815 +Ref: Function org-ql-block23977 +Node: Listing / acting-on results25238 +Ref: Caching25446 +Ref: Function org-ql-select26359 +Ref: Function org-ql-query28785 +Ref: Macro org-ql (deprecated)30559 +Node: Custom predicates30874 +Ref: Macro org-ql-defpred31098 +Node: Dynamic block34539 +Node: Links37263 +Node: Tips37950 +Node: Changelog38274 +Node: 07339065 +Node: 07239785 +Node: 07140704 +Node: 0741513 +Node: 06344437 +Node: 06244968 +Node: 06145273 +Node: 0645841 +Node: 05248895 +Node: 05149195 +Node: 0549620 +Node: 04951151 +Node: 04851433 +Node: 04751782 +Node: 04652191 +Node: 04552599 +Node: 04452960 +Node: 04353319 +Node: 04253522 +Node: 04153683 +Node: 0453930 +Node: 03258031 +Node: 03158434 +Node: 0358631 +Node: 02361931 +Node: 02262165 +Node: 02162445 +Node: 0262650 +Node: 0166728 +Node: Notes66829 +Node: Comparison with Org Agenda searches66991 +Node: org-sidebar67880 +Node: License68159  End Tag Table From deada67e1d2ecd95f19c73d65ca258d08e27ac87 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 5 Feb 2023 21:30:32 -0600 Subject: [PATCH 62/72] WIP: org-ql-open-link Need to tidy up and generalize org-ql-completing-read a bit more, but this is basically working, and should be very useful. --- org-ql-completing-read.el | 31 +++++++++++++++++++++++++++ org-ql-find.el | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index e224e4b..d3c3f2a 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -75,10 +75,38 @@ For an experience like `org-rifle', use a newline." ;;;; Functions +(defun org-ql-completing-read-action (table) + "Default action for `org-ql-completing-read'." + (font-lock-ensure (point-at-bol) (point-at-eol)) + (let* ((path (thread-first (org-get-outline-path t t) + (org-format-outline-path window-width nil "") + (org-split-string ""))) + (path (if org-ql-completing-read-reverse-paths + (string-join (nreverse path) "\\") + (string-join path "/")))) + (puthash path (point-marker) table) + path)) + +(defun org-ql-completing-read-annotate (candidate table) + "FIXME: Docstring." + (while-no-input + ;; Using `while-no-input' here doesn't make it as + ;; responsive as, e.g. Helm while typing, but it seems to + ;; help a little when using the org-rifle-style snippets. + (or (org-ql-completing-read-snippet (gethash candidate table)) ""))) + +(defun org-ql-completing-read-snippet (marker) + (org-with-point-at marker + (or (funcall org-ql-completing-read-snippet-function snippet-regexp) + (org-ql-completing-read--snippet-simple)))) + ;;;;; Completing read ;;;###autoload (cl-defun org-ql-completing-read (buffers-files &key query-prefix query-filter + (action #'org-ql-completing-read-action) + (annotate #'org-ql-completing-read-annotate) + (collection-filter #'identity) (prompt "Find entry: ")) "Return marker at Org entry in BUFFERS-FILES selected with `org-ql'. PROMPT is shown to the user. @@ -266,6 +294,9 @@ single predicate)." ;; `completing-read' machinery, which interrupts it, so we must work around this problem by ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling ;; `completing-read'. + (funcall collection-filter + (org-ql-select buffers-files (org-ql--query-string-to-sexp str) + :action #'action))))))) (unless (listp buffers-files) ;; Since we map across this argument, we ensure it's a list. (setf buffers-files (list buffers-files))) diff --git a/org-ql-find.el b/org-ql-find.el index 1b85b77..34e39ee 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -141,6 +141,50 @@ which see (but only the files are used)." (let ((org-ql-default-predicate 'outline-path)) (org-ql-find (current-buffer)))) +;;;###autoload +(cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter + (prompt "Open link: ")) + "FIXME: Docstring." + (interactive + ;; FIXME: Factor this out. + (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)) + (progn + (unless (eq major-mode 'org-mode) + (user-error "This is not an Org buffer: %S" (current-buffer))) + (current-buffer))))) + (let* ((org-ql-completing-read-snippet-function nil) + (marker (org-ql-completing-read buffers-files + :query-prefix "rifle:" + :query-filter (lambda (input) + (replace-regexp-in-string (rx (1+ space)) "," input t t)) + :prompt prompt + :collection-filter #'flatten-list + :action (lambda (table) + (save-excursion + (cl-loop while (re-search-forward org-link-any-re (org-entry-end-position) t) + for link = (string-trim (match-string 0)) + do (progn + (set-text-properties 0 (length link) '(face org-link) link) + (setf link (org-link-display-format link)) + (puthash link (copy-marker (match-beginning 0)) table)) + collect link))) + :annotate (lambda (candidate table) + (org-with-point-at (gethash candidate table) + (concat " " + (org-format-outline-path (reverse (org-get-outline-path 'with-self)) + nil nil "\\") + "::" + (abbreviate-file-name (buffer-file-name)))))))) + (org-with-point-at marker + (org-open-at-point marker)))) + (provide 'org-ql-find) ;;; org-ql-find.el ends here From 28f5aa3100497f2ff847cb825628b1f03509dc82 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 16 Mar 2023 07:11:11 -0500 Subject: [PATCH 63/72] WIP: Many improvements Now need to do some kind of sorting... --- org-ql-completing-read.el | 106 +++++++++++++++++++------------------- org-ql-find.el | 40 +++++++------- 2 files changed, 74 insertions(+), 72 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index d3c3f2a..127a866 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -73,41 +73,46 @@ For an experience like `org-rifle', use a newline." (defface org-ql-completing-read-snippet '((t (:inherit font-lock-comment-face))) "Snippets.") +(defvar org-ql-completing-read-input-regexp nil + "Current regexp for `org-ql-completing-read' input. +To be used in, e.g. annotation functions.") + ;;;; Functions -(defun org-ql-completing-read-action (table) - "Default action for `org-ql-completing-read'." +(defun org-ql-completing-read-action () + "Default action for `org-ql-completing-read'. +Returns (STRING . MARKER) cons." (font-lock-ensure (point-at-bol) (point-at-eol)) - (let* ((path (thread-first (org-get-outline-path t t) - (org-format-outline-path window-width nil "") - (org-split-string ""))) - (path (if org-ql-completing-read-reverse-paths - (string-join (nreverse path) "\\") - (string-join path "/")))) - (puthash path (point-marker) table) - path)) + (cons (org-entry-get nil "ITEM") (point-marker))) -(defun org-ql-completing-read-annotate (candidate table) - "FIXME: Docstring." +(defun org-ql-completing-read-snippet (marker) (while-no-input ;; Using `while-no-input' here doesn't make it as ;; responsive as, e.g. Helm while typing, but it seems to ;; help a little when using the org-rifle-style snippets. - (or (org-ql-completing-read-snippet (gethash candidate table)) ""))) - -(defun org-ql-completing-read-snippet (marker) - (org-with-point-at marker - (or (funcall org-ql-completing-read-snippet-function snippet-regexp) - (org-ql-completing-read--snippet-simple)))) + (org-with-point-at marker + (or (funcall org-ql-completing-read-snippet-function) + (org-ql-completing-read--snippet-simple))))) ;;;;; Completing read ;;;###autoload -(cl-defun org-ql-completing-read (buffers-files &key query-prefix query-filter - (action #'org-ql-completing-read-action) - (annotate #'org-ql-completing-read-annotate) - (collection-filter #'identity) - (prompt "Find entry: ")) +(cl-defun org-ql-completing-read + (buffers-files &key query-prefix query-filter + (action #'org-ql-completing-read-action) + (annotate #'org-ql-completing-read-snippet) + (snippet #'org-ql-completing-read-snippet) + (path (lambda (marker) + (org-with-point-at marker + (let* ((path (thread-first (org-get-outline-path nil t) + (org-format-outline-path (window-width) nil "") + (org-split-string ""))) + (formatted-path (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/"))))) + formatted-path)))) + (action-filter #'list) + (prompt "Find entry: ")) "Return marker at Org entry in BUFFERS-FILES selected with `org-ql'. PROMPT is shown to the user. @@ -135,7 +140,7 @@ single predicate)." (let ((table (make-hash-table :test #'equal)) (disambiguations (make-hash-table :test #'equal)) (window-width (window-width)) - last-input org-outline-path-cache query-tokens snippet-regexp) + last-input org-outline-path-cache query-tokens) (cl-labels (;; (debug-message ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) (action @@ -177,7 +182,7 @@ single predicate)." (cl-loop for completion in completions for marker = (get-text-property 0 'org-marker completion) for prefix = (todo marker) - for suffix = (concat (path marker) " " (snippet marker)) + for suffix = (concat (funcall path marker) " " (funcall snippet marker)) collect (list completion prefix suffix))) (annotate (candidate) ;; (debug-message "ANNOTATE:%S" candidate) @@ -268,35 +273,30 @@ single predicate)." (clrhash disambiguations) (when query-filter (setf input (funcall query-filter input))) - (pcase org-ql-completing-read-snippet-function - ('org-ql-completing-read--snippet-regexp - (setf query-tokens - ;; Remove any tokens that specify predicates or are too short. - (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) - (< (length it) org-ql-completing-read-snippet-minimum-token-length))) - (split-string input nil t (rx space))) - snippet-regexp - (when query-tokens - ;; Limiting each context word to 15 characters prevents - ;; excessively long, non-word strings from ending up in - ;; snippets, which can adversely affect performance. - (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) - bow (or ,@query-tokens) (0+ (not space)) - (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))))) + (setf query-tokens + ;; Remove any tokens that specify predicates or are too short. + (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) + (< (length it) org-ql-completing-read-snippet-minimum-token-length))) + (split-string input nil t (rx space))) + org-ql-completing-read-input-regexp + (when query-tokens + ;; Limiting each context word to 15 characters prevents + ;; excessively long, non-word strings from ending up in + ;; snippets, which can adversely affect performance. + (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) + bow (or ,@query-tokens) (0+ (not space)) + (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))) + ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the + ;; collection function while the user is typing, which can interrupt the machinery Org uses to + ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being + ;; left in fundamental-mode, unprepared to be used as an Org buffer, which breaks many things + ;; and is very confusing for the user. Ideally, of course, we would solve this in + ;; `org-ql-select', and we already attempt to, but that function is called by the + ;; `completing-read' machinery, which interrupts it, so we must work around this problem by + ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling + ;; `completing-read'. (org-ql-select buffers-files (org-ql--query-string-to-sexp input) :action #'action)))) - ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the - ;; collection function while the user is typing, which can interrupt the machinery Org uses to - ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being - ;; left in fundamental-mode, unprepared to be used as an Org buffer, which breaks many things - ;; and is very confusing for the user. Ideally, of course, we would solve this in - ;; `org-ql-select', and we already attempt to, but that function is called by the - ;; `completing-read' machinery, which interrupts it, so we must work around this problem by - ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling - ;; `completing-read'. - (funcall collection-filter - (org-ql-select buffers-files (org-ql--query-string-to-sexp str) - :action #'action))))))) (unless (listp buffers-files) ;; Since we map across this argument, we ensure it's a list. (setf buffers-files (list buffers-files))) @@ -318,7 +318,7 @@ single predicate)." (car (hash-table-values table)) (user-error "No results for input")))))) -(defun org-ql-completing-read--snippet-simple (&optional _regexp) +(defun org-ql-completing-read--snippet-simple () "Return a snippet of the current entry. Returns up to `org-ql-completing-read-snippet-length' characters." (save-excursion diff --git a/org-ql-find.el b/org-ql-find.el index 34e39ee..c750f17 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -159,31 +159,33 @@ which see (but only the files are used)." (unless (eq major-mode 'org-mode) (user-error "This is not an Org buffer: %S" (current-buffer))) (current-buffer))))) - (let* ((org-ql-completing-read-snippet-function nil) - (marker (org-ql-completing-read buffers-files - :query-prefix "rifle:" - :query-filter (lambda (input) - (replace-regexp-in-string (rx (1+ space)) "," input t t)) + (let* ((marker (org-ql-completing-read buffers-files + :query-prefix query-prefix + :query-filter query-filter :prompt prompt - :collection-filter #'flatten-list - :action (lambda (table) + :action-filter #'identity + :action (lambda () (save-excursion - (cl-loop while (re-search-forward org-link-any-re (org-entry-end-position) t) + (cl-loop with limit = (org-entry-end-position) + while (re-search-forward org-link-any-re limit t) for link = (string-trim (match-string 0)) do (progn (set-text-properties 0 (length link) '(face org-link) link) - (setf link (org-link-display-format link)) - (puthash link (copy-marker (match-beginning 0)) table)) - collect link))) - :annotate (lambda (candidate table) - (org-with-point-at (gethash candidate table) - (concat " " - (org-format-outline-path (reverse (org-get-outline-path 'with-self)) - nil nil "\\") - "::" - (abbreviate-file-name (buffer-file-name)))))))) + (setf link (org-link-display-format link))) + collect (cons link (copy-marker (match-beginning 0)))))) + :snippet (lambda (&rest _) + "") + :path (lambda (marker) + (org-with-point-at marker + (let* ((path (thread-first (org-get-outline-path t t) + (org-format-outline-path (window-width) nil "") + (org-split-string ""))) + (formatted-path (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/"))))) + formatted-path)))))) (org-with-point-at marker - (org-open-at-point marker)))) + (org-open-at-point)))) (provide 'org-ql-find) From e030627aeb75d654e42e3e250ff108f950946a75 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 16 Mar 2023 07:39:29 -0500 Subject: [PATCH 64/72] WIP: Add display-sort-function --- org-ql-completing-read.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 127a866..0456a29 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -216,7 +216,16 @@ single predicate)." (cons 'category 'org-heading) (cons 'group-function #'group) (cons 'affixation-function #'affix) - (cons 'annotation-function #'annotate))) + (cons 'annotation-function #'annotate) + (cons 'display-sort-function + (lambda (strings) + (let ((quoted-tokens (mapcar #'regexp-quote query-tokens))) + (sort strings + (lambda (a b) + (cl-labels ((matches + (s) (cl-loop for token in quoted-tokens + count (string-match-p token s)))) + (> (matches a) (matches b)))))))))) (`t ;; (debug-message "COLLECTION:t INPUT:%S KEYS:%S" ;; input (hash-table-keys table)) From 6c18f133e9d29796fac0af75cc10e0ba8900b173 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 16 Mar 2023 07:44:10 -0500 Subject: [PATCH 65/72] Tidy: Function, docstrings, commented code --- org-ql-completing-read.el | 69 +++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 0456a29..e787972 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -86,6 +86,11 @@ Returns (STRING . MARKER) cons." (cons (org-entry-get nil "ITEM") (point-marker))) (defun org-ql-completing-read-snippet (marker) + "Return snippet for entry at MARKER. +Returns value returned by function +`org-ql-completing-read-snippet-function' or +`org-ql-completing-read--snippet-simple', whichever returns a +value, or nil." (while-no-input ;; Using `while-no-input' here doesn't make it as ;; responsive as, e.g. Helm while typing, but it seems to @@ -94,6 +99,17 @@ Returns (STRING . MARKER) cons." (or (funcall org-ql-completing-read-snippet-function) (org-ql-completing-read--snippet-simple))))) +(defun org-ql-completing-read-path (marker) + "Return formatted outline path for entry at MARKER." + (org-with-point-at marker + (let* ((path (thread-first (org-get-outline-path nil t) + (org-format-outline-path (window-width) nil "") + (org-split-string ""))) + (formatted-path (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/"))))) + formatted-path))) + ;;;;; Completing read ;;;###autoload @@ -102,18 +118,10 @@ Returns (STRING . MARKER) cons." (action #'org-ql-completing-read-action) (annotate #'org-ql-completing-read-snippet) (snippet #'org-ql-completing-read-snippet) - (path (lambda (marker) - (org-with-point-at marker - (let* ((path (thread-first (org-get-outline-path nil t) - (org-format-outline-path (window-width) nil "") - (org-split-string ""))) - (formatted-path (if org-ql-completing-read-reverse-paths - (concat "\\" (string-join (reverse path) "\\")) - (concat "/" (string-join path "/"))))) - formatted-path)))) + (path #'org-ql-completing-read-path) (action-filter #'list) (prompt "Find entry: ")) - "Return marker at Org entry in BUFFERS-FILES selected with `org-ql'. + "Return marker at entry in BUFFERS-FILES selected with `org-ql'. PROMPT is shown to the user. QUERY-PREFIX may be a string to prepend to the query entered by @@ -139,31 +147,34 @@ single predicate)." ;; (message "ORG-QL-COMPLETING-READ: Starts.") (let ((table (make-hash-table :test #'equal)) (disambiguations (make-hash-table :test #'equal)) - (window-width (window-width)) last-input org-outline-path-cache query-tokens) (cl-labels (;; (debug-message ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) - (action - () (font-lock-ensure (point-at-bol) (point-at-eol)) - ;; FIXME: We want the fontified heading, and `org-heading-components' returns it + (action () + (font-lock-ensure (point-at-bol) (point-at-eol)) + ;; FIXME: We want the fontified string, and `org-heading-components' returns it ;; without properties, so we have to use `org-get-heading', which added additional ;; optional arguments in a certain Org version, so in those versions, it will ;; return priority cookies and comment strings. - (let ((heading (org-link-display-format (org-entry-get (point) "ITEM")))) - (if (string-empty-p heading) - ;; A heading's string can be empty, but we can't use one because it - ;; wouldn't be useful to the user; and if one is found, it's very - ;; likely to indicate an unnoticed mistake or corruption in the - ;; file: so display a warning and don't record it as a candidate. - (warn "Empty heading at %S in %S" (point) (buffer-name)) - (when (gethash heading table) - ;; Disambiguate heading (even adding the path isn't enough, because that could - ;; also be duplicated). - (if-let ((suffix (gethash heading disambiguations))) - (setf heading (format "%s <%s>" heading (cl-incf suffix))) - (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) - (let ((marker (point-marker))) - (puthash (propertize heading 'org-marker marker) marker table))))) + + ;; This function needs to handle multiple candidates per + ;; call, so we loop over a list of values by default. + (pcase-dolist (`(,string . ,marker) (funcall action-filter (funcall action))) + (when string + (if (string-empty-p string) + ;; A heading's string can be empty, but we can't use one because it + ;; wouldn't be useful to the user; and if one is found, it's very + ;; likely to indicate an unnoticed mistake or corruption in the + ;; file: so display a warning and don't record it as a candidate. + (warn "Empty heading at %S" marker) + (when (gethash string table) + ;; Disambiguate string (even adding the path isn't enough, because that could + ;; also be duplicated). + (if-let ((suffix (gethash string disambiguations))) + (setf string (format "%s <%s>" string (cl-incf suffix))) + (setf string (format "%s <%s>" string (puthash string 2 disambiguations))))) + (puthash (propertize string 'org-marker marker) marker table))))) + (path (marker) (org-with-point-at marker (let* ((path (thread-first (org-get-outline-path nil t) From 3f08d45ace858f184dcc96511df05738ffcd1d89 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 22 Sep 2023 22:03:30 -0500 Subject: [PATCH 66/72] Fix: (org-ql-completing-read-action) Format link --- org-ql-completing-read.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index e787972..7870247 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -83,7 +83,7 @@ To be used in, e.g. annotation functions.") "Default action for `org-ql-completing-read'. Returns (STRING . MARKER) cons." (font-lock-ensure (point-at-bol) (point-at-eol)) - (cons (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) "Return snippet for entry at MARKER. From 9aba73a28b7c09822f016caae41408b8963ac104 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 22 Sep 2023 22:57:28 -0500 Subject: [PATCH 67/72] WIP --- org-ql-completing-read.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 7870247..d67ca86 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -147,6 +147,7 @@ single predicate)." ;; (message "ORG-QL-COMPLETING-READ: Starts.") (let ((table (make-hash-table :test #'equal)) (disambiguations (make-hash-table :test #'equal)) + (window-width (window-width)) last-input org-outline-path-cache query-tokens) (cl-labels (;; (debug-message ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) @@ -206,7 +207,7 @@ single predicate)." (marker) (when-let ((snippet (org-with-point-at marker - (or (funcall org-ql-completing-read-snippet-function snippet-regexp) + (or (funcall org-ql-completing-read-snippet-function org-ql-completing-read-input-regexp) (org-ql-completing-read--snippet-simple))))) (propertize (concat " " snippet) 'face 'org-ql-completing-read-snippet))) From 7ecb4a8b10bcfebc50107df6892faf10987c9478 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 22 Sep 2023 22:58:05 -0500 Subject: [PATCH 68/72] Tidy --- org-ql-completing-read.el | 5 ----- 1 file changed, 5 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index d67ca86..23a5aea 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -153,11 +153,6 @@ single predicate)." ;; (f &rest args) (apply #'message (concat "ORG-QL-COMPLETING-READ: " f) args)) (action () (font-lock-ensure (point-at-bol) (point-at-eol)) - ;; FIXME: We want the fontified string, and `org-heading-components' returns it - ;; without properties, so we have to use `org-get-heading', which added additional - ;; optional arguments in a certain Org version, so in those versions, it will - ;; return priority cookies and comment strings. - ;; This function needs to handle multiple candidates per ;; call, so we loop over a list of values by default. (pcase-dolist (`(,string . ,marker) (funcall action-filter (funcall action))) From 40b25ac3193a5ce4dc79e24537270c754b42647a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 22 Sep 2023 23:12:06 -0500 Subject: [PATCH 69/72] Fix: (org-ql-completing-read-snippet) while-no-input --- org-ql-completing-read.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 23a5aea..7807c64 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -91,13 +91,17 @@ Returns value returned by function `org-ql-completing-read-snippet-function' or `org-ql-completing-read--snippet-simple', whichever returns a value, or nil." - (while-no-input - ;; Using `while-no-input' here doesn't make it as - ;; responsive as, e.g. Helm while typing, but it seems to - ;; help a little when using the org-rifle-style snippets. - (org-with-point-at marker - (or (funcall org-ql-completing-read-snippet-function) - (org-ql-completing-read--snippet-simple))))) + (pcase (while-no-input + ;; Using `while-no-input' here doesn't make it as + ;; responsive as, e.g. Helm while typing, but it seems to + ;; help a little when using the org-rifle-style snippets. + (org-with-point-at marker + (or (funcall org-ql-completing-read-snippet-function) + (org-ql-completing-read--snippet-simple)))) + (`t + ;; Interrupted: return nil (which can be concatted). + nil) + (else else))) (defun org-ql-completing-read-path (marker) "Return formatted outline path for entry at MARKER." From a802579f865b7975eb67345ea6091a0a2dd9b6d2 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 25 Oct 2023 03:19:29 -0500 Subject: [PATCH 70/72] Tidy --- org-ql-completing-read.el | 40 +++++++++++++++++++-------------------- org-ql-find.el | 7 ++++++- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 7807c64..8284502 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -81,7 +81,7 @@ To be used in, e.g. annotation functions.") (defun org-ql-completing-read-action () "Default action for `org-ql-completing-read'. -Returns (STRING . MARKER) cons." +Returns (STRING . MARKER) cons for entry at point." (font-lock-ensure (point-at-bol) (point-at-eol)) (cons (org-link-display-format (org-entry-get nil "ITEM")) (point-marker))) @@ -98,21 +98,19 @@ value, or nil." (org-with-point-at marker (or (funcall org-ql-completing-read-snippet-function) (org-ql-completing-read--snippet-simple)))) - (`t - ;; Interrupted: return nil (which can be concatted). + (`t ;; Interrupted: return nil (which can be concatted). nil) (else else))) (defun org-ql-completing-read-path (marker) "Return formatted outline path for entry at MARKER." (org-with-point-at marker - (let* ((path (thread-first (org-get-outline-path nil t) - (org-format-outline-path (window-width) nil "") - (org-split-string ""))) - (formatted-path (if org-ql-completing-read-reverse-paths - (concat "\\" (string-join (reverse path) "\\")) - (concat "/" (string-join path "/"))))) - formatted-path))) + (let ((path (thread-first (org-get-outline-path nil t) + (org-format-outline-path (window-width) nil "") + (org-split-string "")))) + (if org-ql-completing-read-reverse-paths + (concat "\\" (string-join (reverse path) "\\")) + (concat "/" (string-join path "/")))))) ;;;;; Completing read @@ -166,7 +164,7 @@ single predicate)." ;; wouldn't be useful to the user; and if one is found, it's very ;; likely to indicate an unnoticed mistake or corruption in the ;; file: so display a warning and don't record it as a candidate. - (warn "Empty heading at %S" marker) + (display-warning 'org-ql-completing-read (format-message "Empty heading at %S" marker)) (when (gethash string table) ;; Disambiguate string (even adding the path isn't enough, because that could ;; also be duplicated). @@ -297,7 +295,7 @@ single predicate)." ;; Remove any tokens that specify predicates or are too short. (--select (not (or (string-match-p (rx bos (1+ (not (any ":"))) ":") it) (< (length it) org-ql-completing-read-snippet-minimum-token-length))) - (split-string input nil t (rx space))) + (split-string input nil t (rx blank))) org-ql-completing-read-input-regexp (when query-tokens ;; Limiting each context word to 15 characters prevents @@ -306,20 +304,20 @@ single predicate)." (rx-to-string `(seq (optional (repeat 1 3 (repeat 1 15 (not space)) (0+ space))) bow (or ,@query-tokens) (0+ (not space)) (optional (repeat 1 3 (0+ space) (repeat 1 15 (not space)))))))) - ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the - ;; collection function while the user is typing, which can interrupt the machinery Org uses to - ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being - ;; left in fundamental-mode, unprepared to be used as an Org buffer, which breaks many things - ;; and is very confusing for the user. Ideally, of course, we would solve this in - ;; `org-ql-select', and we already attempt to, but that function is called by the - ;; `completing-read' machinery, which interrupts it, so we must work around this problem by - ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling - ;; `completing-read'. (org-ql-select buffers-files (org-ql--query-string-to-sexp input) :action #'action)))) (unless (listp buffers-files) ;; Since we map across this argument, we ensure it's a list. (setf buffers-files (list buffers-files))) + ;; NOTE: It seems that the `completing-read' machinery can call, abort, and re-call the + ;; collection function while the user is typing, which can interrupt the machinery Org uses to + ;; prepare an Org buffer when an Org file is loaded. This results in, e.g. the buffer being + ;; left in fundamental-mode, unprepared to be used as an Org buffer, which breaks many things + ;; and is very confusing for the user. Ideally, of course, we would solve this in + ;; `org-ql-select', and we already attempt to, but that function is called by the + ;; `completing-read' machinery, which interrupts it, so we must work around this problem by + ;; ensuring all of the BUFFERS-FILES are loaded and initialized before calling + ;; `completing-read'. (mapc #'org-ql--ensure-buffer buffers-files) (let* ((completion-styles '(org-ql-completing-read)) (completion-styles-alist (list (list 'org-ql-completing-read #'try #'all "Org QL Find"))) diff --git a/org-ql-find.el b/org-ql-find.el index c750f17..394b3a4 100644 --- a/org-ql-find.el +++ b/org-ql-find.el @@ -144,7 +144,12 @@ which see (but only the files are used)." ;;;###autoload (cl-defun org-ql-open-link (buffers-files &key query-prefix query-filter (prompt "Open link: ")) - "FIXME: Docstring." + "Open a link selected with `org-ql-completing-read'. +Links found in entries matching the input query are offered as +candidates, and the selected one is opened with +`org-open-at-point'. Arguments BUFFERS-FILES, QUERY-FILTER, +QUERY-PREFIX, and PROMPT are passed to `org-ql-completing-read', +which see." (interactive ;; FIXME: Factor this out. (list (if current-prefix-arg From 58d29d0fff1160a0d9c6c95d46a8467c5309b0f8 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 25 Oct 2023 03:21:03 -0500 Subject: [PATCH 71/72] Comment: Add FIXME --- org-ql-completing-read.el | 1 + 1 file changed, 1 insertion(+) diff --git a/org-ql-completing-read.el b/org-ql-completing-read.el index 8284502..3f25345 100644 --- a/org-ql-completing-read.el +++ b/org-ql-completing-read.el @@ -118,6 +118,7 @@ value, or nil." (cl-defun org-ql-completing-read (buffers-files &key query-prefix query-filter (action #'org-ql-completing-read-action) + ;; FIXME: Unused argument. (annotate #'org-ql-completing-read-snippet) (snippet #'org-ql-completing-read-snippet) (path #'org-ql-completing-read-path) From 2319fc9d8baf98883a7aea833c86104d9e4e6a0b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 25 Oct 2023 03:29:03 -0500 Subject: [PATCH 72/72] Docs: Update changelog, Usage --- README.org | 7 ++ org-ql.info | 183 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 113 insertions(+), 77 deletions(-) diff --git a/README.org b/README.org index cf3cbb7..bdc2e99 100644 --- a/README.org +++ b/README.org @@ -119,6 +119,12 @@ Note that these commands are compatible with [[https://github.com/oantolin/embar [[images/org-ql-find.png]] +*** org-ql-open-link + +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. + *** org-ql-refile 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. @@ -554,6 +560,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + 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-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-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.) *Compatibility* diff --git a/org-ql.info b/org-ql.info index cc86437..d187c05 100644 --- a/org-ql.info +++ b/org-ql.info @@ -48,6 +48,7 @@ Usage Commands * org-ql-find:: +* org-ql-open-link:: * org-ql-refile:: * org-ql-search:: * helm-org-ql:: @@ -207,6 +208,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage * Menu: * org-ql-find:: +* org-ql-open-link:: * org-ql-refile:: * org-ql-search:: * helm-org-ql:: @@ -216,7 +218,7 @@ File: README.info, Node: Commands, Next: Queries, Up: Usage * org-ql-sparse-tree::  -File: README.info, Node: org-ql-find, Next: org-ql-refile, Up: Commands +File: README.info, Node: org-ql-find, Next: org-ql-open-link, Up: Commands 4.1.1 org-ql-find ----------------- @@ -237,9 +239,28 @@ 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.  -File: README.info, Node: org-ql-refile, Next: org-ql-search, Prev: org-ql-find, Up: Commands +File: README.info, Node: org-ql-open-link, Next: org-ql-refile, Prev: org-ql-find, Up: Commands -4.1.2 org-ql-refile +4.1.2 org-ql-open-link +---------------------- + +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. + + +File: README.info, Node: org-ql-refile, Next: org-ql-search, Prev: org-ql-open-link, Up: Commands + +4.1.3 org-ql-refile ------------------- This command refiles the current Org entry to one selected by searching @@ -249,7 +270,7 @@ with Org QL completion. It searches files listed in  File: README.info, Node: org-ql-search, Next: helm-org-ql, Prev: org-ql-refile, Up: Commands -4.1.3 org-ql-search +4.1.4 org-ql-search ------------------- _Note: This command supports both sexp queries and ._ @@ -297,7 +318,7 @@ entry in its source Org buffer.  File: README.info, Node: helm-org-ql, Next: org-ql-view, Prev: org-ql-search, Up: Commands -4.1.4 helm-org-ql +4.1.5 helm-org-ql ----------------- _Note: This command uses . It is available separately in the package @@ -311,7 +332,7 @@ _Note: This command uses . It is available separately in the package  File: README.info, Node: org-ql-view, Next: org-ql-view-sidebar, Prev: helm-org-ql, Up: Commands -4.1.5 org-ql-view +4.1.6 org-ql-view ----------------- Choose and display a view stored in ‘org-ql-views’. @@ -326,7 +347,7 @@ Choose and display a view stored in ‘org-ql-views’.  File: README.info, Node: org-ql-view-sidebar, Next: org-ql-view-recent-items, Prev: org-ql-view, Up: Commands -4.1.6 org-ql-view-sidebar +4.1.7 org-ql-view-sidebar ------------------------- Show a sidebar window listing views stored in ‘org-ql-views’ for easy @@ -336,7 +357,7 @@ point, and press ‘c’ to customize the view at point.  File: README.info, Node: org-ql-view-recent-items, Next: org-ql-sparse-tree, Prev: org-ql-view-sidebar, Up: Commands -4.1.7 org-ql-view-recent-items +4.1.8 org-ql-view-recent-items ------------------------------ Show items in ‘FILES’ from last ‘DAYS’ days with timestamps of ‘TYPE’. @@ -347,7 +368,7 @@ returned by the function ‘org-agenda-files’.  File: README.info, Node: org-ql-sparse-tree, Prev: org-ql-view-recent-items, Up: Commands -4.1.8 org-ql-sparse-tree +4.1.9 org-ql-sparse-tree ------------------------ Arguments: ‘(query &key keep-previous (buffer (current-buffer)))’ @@ -1059,6 +1080,13 @@ File: README.info, Node: 08-pre, Next: 073, Up: Changelog agenda/view 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.) *Compatibility* @@ -1811,74 +1839,75 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1824 -Node: Screenshots1947 -Node: Installation2065 -Node: Quelpa2579 -Node: Helm support3107 -Node: Usage3510 -Node: Commands3908 -Node: org-ql-find4352 -Node: org-ql-refile5167 -Node: org-ql-search5490 -Node: helm-org-ql7421 -Node: org-ql-view7799 -Node: org-ql-view-sidebar8329 -Node: org-ql-view-recent-items8709 -Node: org-ql-sparse-tree9205 -Node: Queries10005 -Node: Non-sexp query syntax11122 -Node: General predicates12881 -Node: Ancestor/descendant predicates19868 -Node: Date/time predicates20996 -Node: Functions / Macros24120 -Node: Agenda-like views24418 -Ref: Function org-ql-block24580 -Node: Listing / acting-on results25841 -Ref: Caching26049 -Ref: Function org-ql-select26962 -Ref: Function org-ql-query29388 -Ref: Macro org-ql (deprecated)31162 -Node: Custom predicates31477 -Ref: Macro org-ql-defpred31701 -Node: Dynamic block35142 -Node: Links37866 -Node: Tips38553 -Node: Changelog38877 -Node: 08-pre39687 -Node: 07341020 -Node: 07241755 -Node: 07142674 -Node: 0743483 -Node: 06346407 -Node: 06246938 -Node: 06147243 -Node: 0647811 -Node: 05250865 -Node: 05151167 -Node: 0551592 -Node: 04953123 -Node: 04853405 -Node: 04753754 -Node: 04654163 -Node: 04554571 -Node: 04454932 -Node: 04355291 -Node: 04255494 -Node: 04155655 -Node: 0455902 -Node: 03260003 -Node: 03160406 -Node: 0360603 -Node: 02363903 -Node: 02264137 -Node: 02164417 -Node: 0264622 -Node: 0168700 -Node: Notes68801 -Node: Comparison with Org Agenda searches68963 -Node: org-sidebar69852 -Node: License70131 +Node: Contents1845 +Node: Screenshots1968 +Node: Installation2086 +Node: Quelpa2600 +Node: Helm support3128 +Node: Usage3531 +Node: Commands3929 +Node: org-ql-find4394 +Node: org-ql-open-link5212 +Node: org-ql-refile6067 +Node: org-ql-search6395 +Node: helm-org-ql8326 +Node: org-ql-view8704 +Node: org-ql-view-sidebar9234 +Node: org-ql-view-recent-items9614 +Node: org-ql-sparse-tree10110 +Node: Queries10910 +Node: Non-sexp query syntax12027 +Node: General predicates13786 +Node: Ancestor/descendant predicates20773 +Node: Date/time predicates21901 +Node: Functions / Macros25025 +Node: Agenda-like views25323 +Ref: Function org-ql-block25485 +Node: Listing / acting-on results26746 +Ref: Caching26954 +Ref: Function org-ql-select27867 +Ref: Function org-ql-query30293 +Ref: Macro org-ql (deprecated)32067 +Node: Custom predicates32382 +Ref: Macro org-ql-defpred32606 +Node: Dynamic block36047 +Node: Links38771 +Node: Tips39458 +Node: Changelog39782 +Node: 08-pre40592 +Node: 07342357 +Node: 07243092 +Node: 07144011 +Node: 0744820 +Node: 06347744 +Node: 06248275 +Node: 06148580 +Node: 0649148 +Node: 05252202 +Node: 05152504 +Node: 0552929 +Node: 04954460 +Node: 04854742 +Node: 04755091 +Node: 04655500 +Node: 04555908 +Node: 04456269 +Node: 04356628 +Node: 04256831 +Node: 04156992 +Node: 0457239 +Node: 03261340 +Node: 03161743 +Node: 0361940 +Node: 02365240 +Node: 02265474 +Node: 02165754 +Node: 0265959 +Node: 0170037 +Node: Notes70138 +Node: Comparison with Org Agenda searches70300 +Node: org-sidebar71189 +Node: License71468  End Tag Table