From 8d3bc554664d1a86265c15bd45cebbbacd6aa0ed Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Thu, 13 Apr 2023 10:13:13 +0200 Subject: Improve cape--cached-table --- cape.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cape.el b/cape.el index 9f1ed7d..f897f62 100644 --- a/cape.el +++ b/cape.el @@ -233,19 +233,18 @@ became invalid." (lambda (str pred action) ;; Bail out early for `metadata' and `boundaries'. This is a pointless ;; move because of caching, but we do it anyway in the hope that the - ;; resulting profiler output looks less confusing, since the weight of the - ;; expensive FUN computation is moved to the `all-completions' action. - ;; Computing `all-completions' must surely be most expensive, so nobody - ;; will suspect a thing. + ;; profiler report looks less confusing, since the weight of the expensive + ;; FUN computation is moved to the `all-completions' action. Computing + ;; `all-completions' must surely be most expensive, so nobody will suspect + ;; a thing. (unless (or (eq action 'metadata) (eq (car-safe action) 'boundaries)) (let ((new-input (buffer-substring-no-properties beg end))) (when (or (eq input 'init) (not (or (string-match-p "\\s-" new-input) ;; Support Orderless (funcall valid input new-input)))) - ;; We have to make sure that the completion table is interruptible. - ;; An interruption should not happen between the setqs. - (setq table (funcall fun new-input) - input new-input))) + (let ((new-table (funcall fun new-input)) + (throw-on-input nil)) ;; No interrupt during state update + (setq table new-table input new-input)))) (complete-with-action action table str pred))))) ;;;; Capfs -- cgit v1.0