[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cape and boundaries (was: typing slows down dramatically when typing dig
From: |
Stefan Monnier |
Subject: |
cape and boundaries (was: typing slows down dramatically when typing digits in emails) |
Date: |
Thu, 22 Dec 2022 16:29:23 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eric S Fraga [2022-12-22 10:22:29] wrote:
> On Wednesday, 21 Dec 2022 at 23:09, Stefan Monnier via Users list for the
> GNU Emacs text editor wrote:
>>> 5311 79% - completion-boundaries
>>> 5311 79% - #<compiled 0x1f4100e4f6213ad7>
>>> 5311 79% - complete-with-action
>>> 5311 79% - #<compiled 0xfe6876f217f45e4>
>>> 4776 71% - cape--dabbrev-list
>>> 4776 71% - dabbrev--find-all-expansions
>>> 4704 70% - dabbrev--find-expansion
>>> 4671 70% - dabbrev--try-find
>>> 2959 44% - dabbrev--search
>>
>>`completion-boundaries` should not need to perform a `dabbrev--search`.
>> Which version of Emacs is that?
>
> It's Emacs from git, up to date as of yesterday morning.
>
>> It would be useful to figure out what is this
>> #<compiled 0x1f4100e4f6213ad7> function (presumably a completion-table)
>> and how it calls `complete-with-action` because normally it should call
>> it with an argument of the form `(boundaries . N)` which should cause
>> `complete-with-action` to return nil immediately.
>
> Any suggestion on how to do this? I guess I would need to disable
> native compilation and re-build?
Oh, I forgot that `complete-with-action` actually won't return immediately
if the completion table it's passed as argument is itself a function.
I'm not sure if the patch below will make much difference (there's
a chance the `dabbrev--search` will still take place, just via some
other call), but at least I think it's "Right".
Daniel, WDYT?
Stefan
diff --git a/cape.el b/cape.el
index dfb1e7a95c..f10decb5ff 100644
--- a/cape.el
+++ b/cape.el
@@ -199,13 +199,17 @@ VALID is the input comparator, see `cape--input-valid-p'."
(end (copy-marker end t))
(table nil))
(lambda (str pred action)
- (let ((new-input (buffer-substring-no-properties beg end)))
- (when (or (eq input 'init) (not (cape--input-valid-p input new-input
valid)))
- ;; NOTE: 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)))
- (complete-with-action action table str pred))))
+ (if (or (eq action 'metadata) (eq (car-safe action) 'boundaries))
+ nil
+ (let ((new-input (buffer-substring-no-properties beg end)))
+ (when (or (eq input 'init)
+ (not (cape--input-valid-p input new-input valid)))
+ ;; NOTE: 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)))
+ (complete-with-action action table str pred)))))
;;;; Capfs