From 83d899b66f2aa4744498baa6866f3bdec2d238be Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Thu, 16 Apr 2026 14:59:31 +0200 Subject: Properly implement dabbrev-capf bugfix backport `dabbrev-capf' does not call `user-error'; in actuality it merely includes in its return value a function, which calls `user-error'. That function is what needs to be advised to neuter that incorrect use of `user-error'. Also use `condition-case' instead of `cl-letf'. Closes #5559. Suggested-by: Stefan Monnier --- lisp/magit-base.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lisp/magit-base.el b/lisp/magit-base.el index 53916cf..0c50e72 100644 --- a/lisp/magit-base.el +++ b/lisp/magit-base.el @@ -1048,13 +1048,16 @@ setting `imenu--index-alist' to nil before calling that function." (static-if (version< emacs-version "31.1") (define-advice dabbrev-capf (:around (fn) git-commit) "Backport bugfix from debbug#80645 / a7d05207214 / 31.1. -See #5551 and #5556." - (cl-letf (((symbol-function #'user-error) - (lambda (format &rest args) - (unless (string-prefix-p "No dynamic expansion" format) - (signal 'user-error - (list (apply #'format-message format args))))))) - (funcall fn)))) + See #5551, #5556 and #5558 (I wish I had not rushed this)." + (pcase-let ((`(,beg ,end ,table . ,rest) (funcall fn))) + `( ,beg ,end + ,(lambda (&rest args) + (condition-case err + (apply table args) + (user-error + (unless (string-prefix-p "No dynamic expansion" (cadr err)) + (signal (car err) (cdr err)))))) + ,@rest)))) ;;; Kludges for Custom -- cgit v1.0