diff --git a/lisp/simple.el b/lisp/simple.el index 0fe8a1025c..646236879c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -199,7 +199,7 @@ next-error-buffer-p (and extra-test-inclusive (funcall extra-test-inclusive)))))) -(defcustom next-error-find-buffer-function #'ignore +(defcustom next-error-find-buffer-function '(ignore) "Function called to find a `next-error' capable buffer. This functions takes the same three arguments as the function `next-error-find-buffer', and should return the buffer to be @@ -208,12 +208,13 @@ next-error-find-buffer-function If the function returns nil, `next-error-find-buffer' will try to use the buffer it used previously, and failing that all other buffers." - :type '(choice (const :tag "No default" ignore) - (const :tag "Single next-error capable buffer on selected frame" - next-error-buffer-on-selected-frame) - (const :tag "Current buffer if next-error capable and outside navigation" - next-error-no-navigation-try-current) - (function :tag "Other function")) + :type '(repeat + (choice (const :tag "No default" ignore) + (const :tag "Single next-error capable buffer on selected frame" + next-error-buffer-on-selected-frame) + (const :tag "Current buffer if next-error capable and outside navigation" + next-error-no-navigation-try-current) + (function :tag "Other function"))) :group 'next-error :version "28.1") @@ -275,9 +276,13 @@ next-error-find-buffer that buffer is rejected." (or ;; 1. If a customizable function returns a buffer, use it. - (funcall next-error-find-buffer-function avoid-current - extra-test-inclusive - extra-test-exclusive) + (or (and (functionp next-error-find-buffer-function) + (funcall next-error-find-buffer-function avoid-current + extra-test-inclusive extra-test-exclusive)) + (and (listp next-error-find-buffer-function) + (run-hook-with-args-until-success + 'next-error-find-buffer-function avoid-current + extra-test-inclusive extra-test-exclusive))) ;; 2. If next-error-last-buffer is an acceptable buffer, use that. (if (and next-error-last-buffer (next-error-buffer-p next-error-last-buffer avoid-current