* lisp/simple.el (next-error-find-buffer-function): New defcustom.
(next-error-last-buffer): Make variable buffer-local.
(next-error-buffer-on-selected-frame): New function.
(next-error-find-buffer): Use next-error-find-buffer-function
at the first step instead of ad-hoc logic of using one window
on the selected frame.
(next-error, next-error-internal): Set default value of
next-error-last-buffer. Display message with the name of last
next-error buffer.
(next-error-select-buffer): New command.
(Bug#20489)