Skip to content

Commit

Permalink
Merge: v0.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Aug 29, 2024
2 parents b0cb761 + 20c0e5a commit fcb4e3e
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 147 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.8

*Fixes*
+ Remove text properties from to-do keywords before displaying them in an ~org-ql-view~ buffer. (Such text properties could cause them to, e.g. display with extra leading spaces, depending on which other modes might be enabled in the source Org buffer.)
+ Binding of ~completion-styles-alist~ in ~org-ql-completing-read~. (This fixes compatibility with Helm's ~helm~ completion style, as well as default Emacs completion in recursive minibuffers. [[https://github.com/alphapapa/org-ql/issues/337][#337]]. Thanks to [[https://github.com/progfolio][Nicholas Vollmer]], [[https://github.com/9viz][viz]], and [[https://github.com/karthink][Karthik Chikmagalur]] for reporting and suggesting fixes.)
+ Use of the context snippet function for ~org-ql-completing-read~. ([[https://github.com/alphapapa/org-ql/issues/419][#419]]. Thanks to [[https://github.com/tpeacock19][tpeacock19]] for reporting.)

** 0.8.7

*Fixes*
Expand Down
39 changes: 16 additions & 23 deletions org-ql-completing-read.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@
:type 'boolean)

(defcustom org-ql-completing-read-snippet-function #'org-ql-completing-read--snippet-simple
;; TODO: I'd like to make the -regexp one the default, but with
;; default Emacs completion affixation, it can sometimes be a bit
;; slow, and I don't want that to be a user's first impression. It
;; may be possible to further optimize the -regexp one so that it
;; can be used by default. In the meantime, the -simple one seems
;; fast enough for general use.
;; TODO(v0.9): Performance of completion annotations seems to be
;; much improved now (whether due to changes in Emacs, Vertico, or
;; both, I don't know). It may be reasonable to make the context
;; snippet the default now.
"Function used to annotate results in `org-ql-completing-read'.
Function is called at entry beginning. (When set to
`org-ql-completing-read--snippet-regexp', it is called with a
Expand Down Expand Up @@ -109,11 +107,13 @@ value, or nil."
;; 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)
(or (funcall org-ql-completing-read-snippet-function
org-ql-completing-read-input-regexp)
(org-ql-completing-read--snippet-simple))))
(`t ;; Interrupted: return nil (which can be concatted).
nil)
(else else)))
(else (propertize (concat " " else)
'face 'org-ql-completing-read-snippet))))

(defun org-ql-completing-read-path (marker)
"Return formatted outline path for entry at MARKER."
Expand Down Expand Up @@ -219,15 +219,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 candidate)) "")))
(snippet (marker)
(when-let
((snippet
(org-with-point-at marker
(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)))
(or (funcall snippet (get-text-property 0 'org-marker candidate)) "")))
(group (candidate transform)
(pcase transform
(`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate))))
Expand Down Expand Up @@ -341,7 +333,8 @@ single predicate)."
;; `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")))
(completion-styles-alist (cons (list 'org-ql-completing-read #'try #'all "Org QL Find")
completion-styles-alist))
(selected
(minibuffer-with-setup-hook
(lambda ()
Expand Down Expand Up @@ -373,7 +366,7 @@ single predicate)."
(car (hash-table-values table))
(user-error "No results for input"))))))

(defun org-ql-completing-read--snippet-simple ()
(defun org-ql-completing-read--snippet-simple (&optional _input-regexp)
"Return a snippet of the current entry.
Returns up to `org-ql-completing-read-snippet-length' characters."
(save-excursion
Expand All @@ -387,15 +380,15 @@ Returns up to `org-ql-completing-read-snippet-length' characters."
t t)
50 nil nil t))))))

(defun org-ql-completing-read--snippet-regexp (regexp)
"Return a snippet of the current entry's matches for REGEXP."
(defun org-ql-completing-read--snippet-regexp (&optional input-regexp)
"Return a snippet of the current entry's matches for INPUT-REGEXP."
;; REGEXP may be nil if there are no qualifying tokens in the query.
(when regexp
(when input-regexp
(save-excursion
(org-end-of-meta-data t)
(unless (org-at-heading-p)
(let* ((end (org-entry-end-position))
(snippets (cl-loop while (re-search-forward regexp end t)
(snippets (cl-loop while (re-search-forward input-regexp end t)
concat (match-string 0) concat ""
do (goto-char (match-end 0)))))
(unless (string-empty-p snippets)
Expand Down
3 changes: 2 additions & 1 deletion org-ql-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ return an empty string."
(title (--> (org-ql-view--add-faces element)
(org-element-property :raw-value it)))
(todo-keyword (-some--> (org-element-property :todo-keyword element)
(org-ql-view--add-todo-face it)))
(org-ql-view--add-todo-face
(substring-no-properties it))))
(tag-list (if org-use-tag-inheritance
;; MAYBE: Use our own variable instead of `org-use-tag-inheritance'.
(if-let ((marker (or (org-element-property :org-hd-marker element)
Expand Down
2 changes: 1 addition & 1 deletion org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ defined in `org-ql-predicates' by calling `org-ql-defpred'."
(byte-compile 'org-ql--query-preamble)))

(cl-defmacro org-ql-defpred (name args docstring &key body preambles normalizers coalesce)
"Define an Org QL selector predicate `org-ql--predicate-NAME'.
"Define an Org QL selector predicate \\=`org-ql--predicate-NAME'.
NAME may be a symbol or a list of symbols: if a list, the first
is used as NAME and the rest are aliases. A function is only
created for NAME, not for aliases, so a normalizer should be used
Expand Down
Loading

0 comments on commit fcb4e3e

Please sign in to comment.