Remove the callback and use keys rather than optional positional arguments
This commit is contained in:
parent
5f37b7260b
commit
f309f42527
1 changed files with 6 additions and 13 deletions
19
org-ql.el
19
org-ql.el
|
|
@ -1003,7 +1003,7 @@ A and B are Org headline elements."
|
||||||
|
|
||||||
;;;; Functions/Occur
|
;;;; Functions/Occur
|
||||||
|
|
||||||
(defun org-ql-occur (query &optional keep-previous callback)
|
(cl-defun org-ql-occur (query &key keep-previous)
|
||||||
"Make a compact tree which shows all matches of the query.
|
"Make a compact tree which shows all matches of the query.
|
||||||
|
|
||||||
QUERY is an `org-ql' query sexp (quoted, since this is a
|
QUERY is an `org-ql' query sexp (quoted, since this is a
|
||||||
|
|
@ -1014,12 +1014,7 @@ defined in `org-show-context-detail', which see.
|
||||||
|
|
||||||
When optional argument KEEP-PREVIOUS is non-nil, highlighting and
|
When optional argument KEEP-PREVIOUS is non-nil, highlighting and
|
||||||
exposing done by a previous call to `org-occur' or `org-ql-occur'
|
exposing done by a previous call to `org-occur' or `org-ql-occur'
|
||||||
will be kept, to allow stacking of calls to this command.
|
will be kept, to allow stacking of calls to this command."
|
||||||
|
|
||||||
Optional argument CALLBACK can be a function of no argument. In this case,
|
|
||||||
it is called with point at the end of the match, match data being set
|
|
||||||
accordingly. Current match is shown only if the return value is non-nil.
|
|
||||||
The function must neither move point nor alter narrowing."
|
|
||||||
(interactive (list (read-minibuffer "Query: ")))
|
(interactive (list (read-minibuffer "Query: ")))
|
||||||
(unless keep-previous
|
(unless keep-previous
|
||||||
(org-remove-occur-highlights nil nil t))
|
(org-remove-occur-highlights nil nil t))
|
||||||
|
|
@ -1027,12 +1022,10 @@ The function must neither move point nor alter narrowing."
|
||||||
(let ((result (org-ql-query (current-buffer) query
|
(let ((result (org-ql-query (current-buffer) query
|
||||||
:action
|
:action
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when (or (not callback)
|
(when org-highlight-sparse-tree-matches
|
||||||
(funcall callback))
|
(org-highlight-new-match (match-beginning 0) (match-end 0)))
|
||||||
(when org-highlight-sparse-tree-matches
|
(org-show-context 'occur-tree)
|
||||||
(org-highlight-new-match (match-beginning 0) (match-end 0)))
|
t))))
|
||||||
(org-show-context 'occur-tree)
|
|
||||||
t)))))
|
|
||||||
(when org-remove-highlights-with-change
|
(when org-remove-highlights-with-change
|
||||||
(add-hook 'before-change-functions 'org-remove-occur-highlights
|
(add-hook 'before-change-functions 'org-remove-occur-highlights
|
||||||
nil 'local))
|
nil 'local))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue