From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: cape and boundaries (was: typing slows down dramatically when typing digits in emails) Date: Thu, 22 Dec 2022 16:29:23 -0500 Message-ID: References: <874jtouam0.fsf@ucl.ac.uk> <87bknvzqje.fsf@ucl.ac.uk> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35296"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Daniel Mendler To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:V2XIpoYcJR+nFXxBBtuBCivCpd0= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 22 22:30:18 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8T8q-00095F-JK for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 22 Dec 2022 22:30:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8T8G-0001u7-3O; Thu, 22 Dec 2022 16:29:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8T8E-0001sR-EL for help-gnu-emacs@gnu.org; Thu, 22 Dec 2022 16:29:38 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8T8C-0002Zb-Ny for help-gnu-emacs@gnu.org; Thu, 22 Dec 2022 16:29:38 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1p8T88-0008FK-Ag for help-gnu-emacs@gnu.org; Thu, 22 Dec 2022 22:29:32 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141905 Archived-At: --=-=-= Content-Type: text/plain 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% - # >>> 5311 79% - complete-with-action >>> 5311 79% - # >>> 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 >> # 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=cape.patch 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 --=-=-=--