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*
|
||||
+ 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 search buffers without headings, and show a message if the user attempts it.
|
||||
|
||||
*Compatibility*
|
||||
+ 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))
|
||||
(when (org-before-first-heading-p)
|
||||
(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)))))))
|
||||
(if (not (org-at-heading-p))
|
||||
(progn
|
||||
;; No headings in buffer: return nil.
|
||||
(unless (string-prefix-p " " (buffer-name))
|
||||
;; Not a special, hidden buffer: show message, because if a user accidentally
|
||||
;; searches a buffer without headings, he might be confused.
|
||||
(message "org-ql: No headings in buffer: %s" (current-buffer)))
|
||||
nil)
|
||||
;; `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
|
||||
;; Restore original function mappings.
|
||||
(fset (plist-get it :name) (plist-get it :fn))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue