From: Eshel Yaron Date: Tue, 23 Jul 2024 19:22:29 +0000 (+0200) Subject: crm.el: Workaround issue with nil completion table X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d79cb8952c7bd557f43603309742a8b842d4bb87;p=emacs.git crm.el: Workaround issue with nil completion table --- 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)))