I think I found a solution but here are the steps in case others have the same problem:

* First, I open an org file in Emacs.
* I then create a sparse tree using a regular expression.
* I then type M-g M-n to move to the next occurrence of my search string but it doesn't work.  I get a message saying "user-error: Moved past last grep hit".
* I kill the pre-existing "*grep*" buffer in Emacs.
* I then try M-g M-n again and it works.

Writing out these steps got me thinking that there might be an option in compilation mode to switch buffers when finding next error.  I looked in the compilation mode section of the Emacs manual and found next-error-select-buffer that switches buffers when searching for errors.  I also just realized that you mentioned next-error-find-buffer-function configuration variable in an earlier post.  I'll try that as well.

You can consider my question answered.  Thanks for the help.

On Sunday, January 1, 2023 at 06:24:39 AM MST, Ihor Radchenko <yantar92@posteo.net> wrote:


Eric Chun <eyc8@yahoo.com> writes:

> I'm assuming "current buffer" is the buffer which I can currently type input into.  The current buffer is not finding next occurrence of search string by pressing M-g M-n.  Is this expected?

Could you please elaborate?
What exactly you did and what do you expect to happen?
(see https://orgmode.org/manual/Feedback.html#Feedback)


--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>