branch: externals/mct commit eca1ea9a255e6051fe0dda2d41885943ecb3be00 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Fix Emacs 29 regression for out-of-bounds motion MCT accepts a numeric argument for motions inside the Completions buffer. The issue has been how to handle those cases where the ARGth motion would exceed the boundaries. For example, if we are on line 3 and have a -10 motion, the point will be placed in the minibuffer instead of trying to cycle back to the minibuffer, then the bottom of the Completion, and then move however many remaining places backward. Just switching to the minibuffer when the ARG is out-of-bounds makes the code easier and we save the user from the trouble of having to target the minibuffer with precision (the last point in the Completions is still relevant, such as when using mct-edit-completion). Anyhow, Emacs 29 changes how the next-completion/previous-completion work, where they now return an out-of-bounds error, so we have to make some adjustments. My tests suggest that this patch addresses the underlying problem, while it has no regressions on Emacs 27. --- mct.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mct.el b/mct.el index 475700092a..18a340fec4 100644 --- a/mct.el +++ b/mct.el @@ -653,13 +653,19 @@ the minibuffer." (mct--next-completion count)) (setq this-command 'next-line)))) +(defun mct--motion-below-point-min-p (arg) + "Return non-nil if backward ARG motion exceeds `point-min'." + (let ((line (- (line-number-at-pos) arg))) + (or (< line 1) + (= (save-excursion (previous-completion arg) (point)) (point-min))))) + (defun mct--top-of-completions-p (arg) "Test if point is at the notional top of the Completions. ARG is a numeric argument for `previous-completion', as described in `mct-previous-completion-or-mini'." (or (bobp) (mct--completions-line-boundary (mct--first-completion-point)) - (= (save-excursion (previous-completion arg) (point)) (point-min)) + (mct--motion-below-point-min-p arg) ;; FIXME 2021-12-27: Why do we need this now? Regression upstream? (eq (line-number-at-pos) 1)))