org-search-view: Fix searching across inlinetasks

* lisp/org-agenda.el (org-search-view): Consider that
`outline-next-heading' may move to inlinetask.

* testing/examples/agenda-search.org: New test file.

* testing/lisp/test-org-agenda.el (test-org-agenda/org-search-view):
New test.

Reported-by: Alain.Cochard@unistra.fr
Link: https://orgmode.org/list/25514.763.379510.806150@gargle.gargle.HOWL
This commit is contained in:
Ihor Radchenko 2022-12-27 13:00:50 +03:00
parent ecfb55af0a
commit fc4bbb28f8
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 36 additions and 2 deletions

View File

@ -4678,7 +4678,7 @@ is active."
(org-agenda-text-search-extra-files org-agenda-text-search-extra-files)
regexp rtn rtnall files file pos inherited-tags
marker category level tags c neg re boolean
ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str)
ee txt beg end last-search-end words regexps+ regexps- hdl-only buffer beg1 str)
(unless (and (not edit-at)
(stringp string)
(string-match "\\S-" string))
@ -4817,6 +4817,7 @@ is active."
(throw 'nextfile t))
(goto-char (max (point-min) (1- (point))))
(while (re-search-forward regexp nil t)
(setq last-search-end (point))
(org-back-to-heading t)
(while (and (not (zerop org-agenda-search-view-max-outline-level))
(> (org-reduced-level (org-outline-level))
@ -4878,7 +4879,7 @@ is active."
'priority 1000
'type "search")
(push txt ee)
(goto-char (1- end))))))))))
(goto-char (max (1- end) last-search-end))))))))))
(setq rtn (nreverse ee))
(setq rtnall (append rtnall rtn)))
(org-agenda--insert-overriding-header

View File

@ -0,0 +1,8 @@
* Test heading with text
foo
* Test heading with inlinetask
foo
****************** inline
text inside inlinetask
****************** END
bar

View File

@ -115,6 +115,31 @@ See https://list.orgmode.org/20220101200103.GB29829@itccanarias.org/T/#t."
(should (= 2 (count-lines (point-min) (point-max)))))
(org-test-agenda--kill-all-agendas))
(ert-deftest test-org-agenda/org-search-view ()
"Test `org-search-view' specifications."
(cl-assert (not org-agenda-sticky) nil "precondition violation")
(cl-assert (not (org-test-agenda--agenda-buffers))
nil "precondition violation")
;; Search a string.
(let ((org-agenda-files `(,(expand-file-name "examples/agenda-search.org"
org-test-dir))))
(org-search-view nil "foo")
(set-buffer org-agenda-buffer-name)
(should (= 4 (count-lines (point-min) (point-max)))))
;; Search past inlinetask.
(let ((org-agenda-files `(,(expand-file-name "examples/agenda-search.org"
org-test-dir))))
(org-search-view nil "bar")
(set-buffer org-agenda-buffer-name)
(should (= 3 (count-lines (point-min) (point-max)))))
;; Search inside inlinetask.
(let ((org-agenda-files `(,(expand-file-name "examples/agenda-search.org"
org-test-dir))))
(org-search-view nil "text inside inlinetask")
(set-buffer org-agenda-buffer-name)
(should (= 3 (count-lines (point-min) (point-max)))))
(org-test-agenda--kill-all-agendas))
(ert-deftest test-org-agenda/property-timestamp ()
"Match timestamps inside property drawer.
See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com"