Fix: (org-ql--select) Don't search buffers without headings
Especially important when using org-ql-search to search "all" Org buffers.
This commit is contained in:
parent
76debff1c5
commit
b634647e46
2 changed files with 18 additions and 9 deletions
|
|
@ -385,6 +385,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
|
||||||
*Fixed*
|
*Fixed*
|
||||||
+ Handle date ranges in date-based selectors. (Thanks to [[https://github.com/codygman][Cody Goodman]], [[https://github.com/swflint][Samuel W. Flint]], and [[https://github.com/vikasrawal][Vikas Rawal]].)
|
+ Handle date ranges in date-based selectors. (Thanks to [[https://github.com/codygman][Cody Goodman]], [[https://github.com/swflint][Samuel W. Flint]], and [[https://github.com/vikasrawal][Vikas Rawal]].)
|
||||||
+ Don't overwrite bindings in =org-agenda-mode-map=.
|
+ Don't overwrite bindings in =org-agenda-mode-map=.
|
||||||
|
+ Don't search buffers without headings, and show a message if the user attempts it.
|
||||||
|
|
||||||
*Compatibility*
|
*Compatibility*
|
||||||
+ Fixes for compatibility with Org 9.2. (Thanks to [[https://github.com/ataias][Ataias Pereira Reis]] and [[https://github.com/dakra][Daniel Kraus]].)
|
+ Fixes for compatibility with Org 9.2. (Thanks to [[https://github.com/ataias][Ataias Pereira Reis]] and [[https://github.com/dakra][Daniel Kraus]].)
|
||||||
|
|
|
||||||
26
org-ql.el
26
org-ql.el
|
|
@ -487,15 +487,23 @@ If NARROW is non-nil, buffer will not be widened."
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(when (org-before-first-heading-p)
|
(when (org-before-first-heading-p)
|
||||||
(outline-next-heading))
|
(outline-next-heading))
|
||||||
;; `cl-loop' makes this double-while much clearer than the expanded form.
|
(if (not (org-at-heading-p))
|
||||||
(cond (preamble-re (cl-loop while (re-search-forward preamble-re nil t)
|
(progn
|
||||||
do (outline-back-to-heading 'invisible-ok)
|
;; No headings in buffer: return nil.
|
||||||
when (funcall predicate)
|
(unless (string-prefix-p " " (buffer-name))
|
||||||
collect (funcall action)
|
;; Not a special, hidden buffer: show message, because if a user accidentally
|
||||||
do (outline-next-heading)))
|
;; searches a buffer without headings, he might be confused.
|
||||||
(t (cl-loop when (funcall predicate)
|
(message "org-ql: No headings in buffer: %s" (current-buffer)))
|
||||||
collect (funcall action)
|
nil)
|
||||||
while (outline-next-heading)))))))
|
;; `cl-loop' makes this double-while much clearer than the expanded form.
|
||||||
|
(cond (preamble-re (cl-loop while (re-search-forward preamble-re nil t)
|
||||||
|
do (outline-back-to-heading 'invisible-ok)
|
||||||
|
when (funcall predicate)
|
||||||
|
collect (funcall action)
|
||||||
|
do (outline-next-heading)))
|
||||||
|
(t (cl-loop when (funcall predicate)
|
||||||
|
collect (funcall action)
|
||||||
|
while (outline-next-heading))))))))
|
||||||
(--each orig-fns
|
(--each orig-fns
|
||||||
;; Restore original function mappings.
|
;; Restore original function mappings.
|
||||||
(fset (plist-get it :name) (plist-get it :fn))))))
|
(fset (plist-get it :name) (plist-get it :fn))))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue