Fix: Handle the buffer argument properly; Restore org-overview call

This commit is contained in:
Akira Komamura 2019-08-24 19:46:21 +09:00
parent 2cd612d1ba
commit 6b0ff77981

View file

@ -1016,24 +1016,31 @@ 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."
(interactive (list (read-minibuffer "Query: "))) (interactive (list (read-minibuffer "Query: ")))
(unless keep-previous (unless (bufferp buffer)
(org-remove-occur-highlights nil nil t)) (user-error "BUFFER should be a single buffer"))
;; (push (cons regexp callback) org-occur-parameters) (with-current-buffer buffer
(let ((result (org-ql-select buffer query (unless keep-previous
:action (org-remove-occur-highlights nil nil t))
(lambda () (when (or (not keep-previous) ; do not want to keep
(when org-highlight-sparse-tree-matches (not org-occur-highlights)) ; no previous matches
(org-highlight-new-match (match-beginning 0) (match-end 0))) ;; hide everything
(org-show-context 'occur-tree) (org-overview))
t)))) ;; (push (cons regexp callback) org-occur-parameters)
(when org-remove-highlights-with-change (let ((result (org-ql-select buffer query
(add-hook 'before-change-functions 'org-remove-occur-highlights :action
nil 'local)) (lambda ()
(unless org-sparse-tree-open-archived-trees (when org-highlight-sparse-tree-matches
(org-hide-archived-subtrees (point-min) (point-max))) (org-highlight-new-match (match-beginning 0) (match-end 0)))
(run-hooks 'org-occur-hook) (org-show-context 'occur-tree)
(when (called-interactively-p 'interactive) t))))
(message "%d match(es) for query %s" (length result) query)))) (when org-remove-highlights-with-change
(add-hook 'before-change-functions 'org-remove-occur-highlights
nil 'local))
(unless org-sparse-tree-open-archived-trees
(org-hide-archived-subtrees (point-min) (point-max)))
(run-hooks 'org-occur-hook)
(when (called-interactively-p 'interactive)
(message "%d match(es) for query %s" (length result) query)))))
;;;; Footer ;;;; Footer