Skip to content

Commit

Permalink
Merge: v0.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Sep 5, 2024
2 parents 831a1d4 + 76c7345 commit d146b08
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 144 deletions.
7 changes: 7 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ Simple links may also be written manually in either sexp or non-sexp form, like:

Tagged v0.6.2, fixing a compilation warning.

** 0.8.9

*Fixes*
+ Predicate ~property~ when called with argument form ~(property "PROPERTY-NAME" :inherit t)~. ([[https://github.com/alphapapa/org-ql/issues/460][#460]]. Thanks to [[https://github.com/Stewmath][Stewmath]] for reporting.)
+ Predicate ~level~'s preamble optimizer allows expressions in place of the numeric argument. (See [[https://github.com/alphapapa/org-ql/issues/460][#460]]. Thanks to [[https://github.com/Stewmath][Stewmath]] for reporting.)
+ Reading of view settings from Org links in upcoming Emacs version. ([[https://github.com/alphapapa/org-ql/issues/461][#461]]. Thanks to [[https://github.com/snogge][Ola Nilsson]] for help debugging, and for maintaining [[https://github.com/jorgenschaefer/emacs-buttercup][Buttercup]].)

** 0.8.8

*Fixes*
Expand Down
8 changes: 4 additions & 4 deletions org-ql-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,19 @@ purposes of compatibility with changes in Org 9.4."
(query (url-unhex-string query))
(params (when params (url-parse-query-string params)))
;; `url-parse-query-string' returns "improper" alists, which makes this awkward.
(sort (when-let* ((stored-string (alist-get "sort" params nil nil #'string=))
(sort (when-let* ((stored-string (car (alist-get "sort" params nil nil #'string=)))
(read-value (read stored-string)))
;; Ensure the value is either a symbol or list of symbols (which excludes lambdas).
(unless (or (symbolp read-value) (cl-every #'symbolp read-value))
(error "CAUTION: Link not opened because unsafe sort parameter detected: %s"
read-value))
read-value))
(org-super-agenda-allow-unsafe-groups nil) ; Disallow unsafe group selectors.
(groups (--when-let (alist-get "super-groups" params nil nil #'string=)
(groups (--when-let (car (alist-get "super-groups" params nil nil #'string=))
(read it)))
(title (--when-let (alist-get "title" params nil nil #'string=)
(title (--when-let (car (alist-get "title" params nil nil #'string=))
(read it)))
(buffers-files (--if-let (alist-get "buffers-files" params nil nil #'string=)
(buffers-files (--if-let (car (alist-get "buffers-files" params nil nil #'string=))
(org-ql-view--expand-buffers-files (read it))
(current-buffer))))
(unless (or (bufferp buffers-files)
Expand Down
60 changes: 45 additions & 15 deletions org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
;; is "h:" while the user is typing.
(list :regexp (rx bol (1+ "*") " ")
:case-fold t))
(`(,predicate-names ,comparator-or-num ,num)
((and `(,predicate-names ,comparator-or-num ,num)
(guard (numberp num)))
(let ((repeat (pcase comparator-or-num
('< `(repeat 1 ,(1- num) "*"))
('<= `(repeat 1 ,num "*"))
Expand All @@ -1546,7 +1547,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
((pred integerp) `(repeat ,comparator-or-num ,num "*")))))
(list :regexp (rx-to-string `(seq bol ,repeat " ") t)
:case-fold t)))
(`(,predicate-names ,num)
((and `(,predicate-names ,num)
(guard (numberp num)))
(list :regexp (rx-to-string `(seq bol (repeat ,num "*") " ") t)
:case-fold t)))
;; NOTE: It might be necessary to take into account `org-odd-levels'; see docstring for
Expand Down Expand Up @@ -1802,34 +1804,62 @@ interpreted as nil or non-nil)."
;; predicate test for whether an entry has local
;; properties when no arguments are given.
(list 'property ""))
(`(,predicate-names ,property ,value . ,plist)
(`(,predicate-names ,property)
;; Convert keyword property arguments to strings. Non-sexp
;; queries result in keyword property arguments (because to do
;; otherwise would require ugly special-casing in the parsing).
(when (keywordp property)
(setf property (substring (symbol-name property) 1)))
(list 'property property value
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
((listp org-use-property-inheritance) ''selective)
(t org-use-property-inheritance)))))
(list 'property property))
(`(,predicate-names ,property . ,rest)
(pcase rest
(`(,value)
;; Convert keyword property arguments to strings. Non-sexp
;; queries result in keyword property arguments (because to do
;; otherwise would require ugly special-casing in the parsing).
(when (keywordp property)
(setf property (substring (symbol-name property) 1)))
(list 'property property value))
((and `(,value . ,plist)
(guard (not (keywordp value))))
;; Convert keyword property arguments to strings. Non-sexp
;; queries result in keyword property arguments (because to do
;; otherwise would require ugly special-casing in the parsing).
(when (keywordp property)
(setf property (substring (symbol-name property) 1)))
(list 'property property value
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
((listp org-use-property-inheritance) ''selective)
(t org-use-property-inheritance))))
((and plist (guard (keywordp (car rest))))
;; Convert keyword property arguments to strings. Non-sexp
;; queries result in keyword property arguments (because to do
;; otherwise would require ugly special-casing in the parsing).
(when (keywordp property)
(setf property (substring (symbol-name property) 1)))
(list 'property property nil
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
((listp org-use-property-inheritance) ''selective)
(t org-use-property-inheritance)))))))
;; MAYBE: Should case folding be disabled for properties? What about values?
;; MAYBE: Support (property) without args.

;; NOTE: When inheritance is enabled, the preamble can't be used,
;; which will make the search slower.
:preambles ((`(,predicate-names ,property ,value . ,(map :inherit))
:preambles (((and `(,predicate-names ,property ,value)
(guard (atom value)))
;; We do NOT return nil, because the predicate still needs to be tested,
;; because the regexp could match a string not inside a property drawer.
(list :regexp (unless inherit
(rx-to-string `(seq bol (0+ space) ":" ,property ":"
(1+ space) ,value (0+ space) eol)))
(list :regexp (rx-to-string `(seq bol (0+ space) ":" ,property ":"
(1+ space) ,value (0+ space) eol))
:query query))
(`(,predicate-names ,property . ,(map :inherit))
;; We do NOT return nil, because the predicate still needs to be tested,
((and `(,predicate-names ,property ,value . ,plist)
(guard (keywordp (car plist))))
;; WE do NOT return nil, because the predicate still needs to be tested,
;; because the regexp could match a string not inside a property drawer.
;; NOTE: The preamble only matches if there appears to be a value.
;; A line like ":ID: " without any other text does not match.
(list :regexp (unless inherit
(list :regexp (unless (plist-get plist :inherit)
(rx-to-string `(seq bol (0+ space) ":" ,property ":" (1+ space)
(minimal-match (1+ not-newline)) eol)))
:query query)))
Expand All @@ -1841,7 +1871,7 @@ interpreted as nil or non-nil)."
;; Check that PROPERTY exists
(org-ql--value-at
(point) (lambda ()
(org-entry-get (point) property))))
(org-entry-get (point) property inherit))))
(_
;; Check that PROPERTY has VALUE.

Expand Down
Loading

0 comments on commit d146b08

Please sign in to comment.