From d79cb8952c7bd557f43603309742a8b842d4bb87 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 23 Jul 2024 21:22:29 +0200 Subject: [PATCH] crm.el: Workaround issue with nil completion table --- lisp/emacs-lisp/crm.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el index ca98d640a5e..c6e40d6fa27 100644 --- a/lisp/emacs-lisp/crm.el +++ b/lisp/emacs-lisp/crm.el @@ -385,9 +385,15 @@ that fails this command prompts you for the separator to use." (cons 'metadata (cons (cons 'adjust-base-function (lambda (base) - (funcall (or (alist-get 'adjust-base-function md) - #'identity) - (substring base beg)))) + ;; When TABLE is nil and point is after + ;; separator, we may get empty `base' from + ;; `completion-all-sorted-completions', + ;; because `completion-all-completions' + ;; returns nil with no base length. + (if (string-empty-p base) base + (funcall (or (alist-get 'adjust-base-function md) + #'identity) + (substring base beg))))) (cdr-safe md))))) ('nil (let ((comp (complete-with-action a table (substring s beg) p))) (if (stringp comp) (concat (substring s 0 beg) comp) comp))) -- 2.39.2