From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#50459: 28.0.50; Python shell completion is incompatible with flex, orderless, etc. Date: Fri, 10 Sep 2021 13:50:33 +0200 Message-ID: <87zgskejjq.fsf@gmail.com> References: <87wnnsl1d1.fsf@gmail.com> <87czpijixk.fsf@gmail.com> <877dfqjfwu.fsf@gmail.com> <87mtolr91a.fsf@gmail.com> <877dfopsoa.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32474"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 50459@debbugs.gnu.org, Gregory Heytings , Michael Albinus , joaotavora@gmail.com To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 10 14:23:51 2021 Return-path: Envelope-to: geb-bug-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 1mOfZO-0008EL-Sn for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Sep 2021 14:23:50 +0200 Original-Received: from localhost ([::1]:42276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOfZM-0000bK-Ek for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Sep 2021 08:23:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOf3g-0002FO-JX for bug-gnu-emacs@gnu.org; Fri, 10 Sep 2021 07:51:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOf3e-0005Uh-Kj for bug-gnu-emacs@gnu.org; Fri, 10 Sep 2021 07:51:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOf3e-0004Th-Fa for bug-gnu-emacs@gnu.org; Fri, 10 Sep 2021 07:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Sep 2021 11:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50459 X-GNU-PR-Package: emacs Original-Received: via spool by 50459-submit@debbugs.gnu.org id=B50459.163127464217186 (code B ref 50459); Fri, 10 Sep 2021 11:51:02 +0000 Original-Received: (at 50459) by debbugs.gnu.org; 10 Sep 2021 11:50:42 +0000 Original-Received: from localhost ([127.0.0.1]:37120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOf3K-0004T8-GA for submit@debbugs.gnu.org; Fri, 10 Sep 2021 07:50:42 -0400 Original-Received: from mail-wm1-f42.google.com ([209.85.128.42]:53823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOf3J-0004Sv-6Y for 50459@debbugs.gnu.org; Fri, 10 Sep 2021 07:50:41 -0400 Original-Received: by mail-wm1-f42.google.com with SMTP id i3so1011319wmq.3 for <50459@debbugs.gnu.org>; Fri, 10 Sep 2021 04:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=hG6PROL6ZaFVoQ9FSuDWLR0BZkf40qaZAK4UgLUJiE4=; b=Zrj3Ty5OS7CewZr9e8XtOz3h3G4lEDW5vC138bbEjo5YvKmxBZvSHlqx/273hvOgZo O+7OL2UWH5rNS8nEpKwx1rYu3DggEsFjh4EPAn4fj9P6MNlSyfTfIL+Dd2yHl8janHjq dKXUB5St57beXdvP6fI4Pe+HgvNEb5G/Fzm+Q2JZH/8SNI1NiXLUFcA89J83LZvX0KZK oGZO5uK876VQJC3CnOf+3r86F3DAN8C1A21js6Gepw8m7ASAbCDT4sjSv/vEKLMaSpuN rhl2TrZuoTxYJBtNa9U/XH+hedsQefDH72a4O4uqxi+EQjMkv6xxrh1NaBRy5iZiO9/S YRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=hG6PROL6ZaFVoQ9FSuDWLR0BZkf40qaZAK4UgLUJiE4=; b=vYOYPtk5+DveVrk8aFGh/JxHH9Wxpcu+VUlIXPzb459zsRmwfrRUORHlmC1jU14/Rt lskjcimgYzChUz+bEQGGhFV0jEu04UvQCiqcc8i8VpQtoFTBq0o3DAeOTLb7FpvQ9rXA OS6IKzshQak2Tcb0iBvPL4nboIJeq8g9K3K7O//Sq/Tlnr9iegzxoUpFAD893BLN3qux U+g340LL7jeyF+lP4Cjg1XDfOmQzypxOkCyYiKUscSIjAEwqtEwjJsUKIwADbQw0En8F 7x87wVoaNNa0/mmdcQOXsti2GK1GUTrBj01vb4xwsvc1baHQ6QkpbKtzJc1KrdKHwoyJ lamA== X-Gm-Message-State: AOAM532sP4YJlf6ON/kwfvwUnbzwGJYCQYDlZUdzysGO/kUHmctsHYgg AMneZ9sIDK0n+RqJVuKQKgc= X-Google-Smtp-Source: ABdhPJzr7AWCMKVY6vlFQ6upXRvUgWbTZTcSI37bzUNngoghM/ZPfSAufsa+nx0h8mv48jpCp0rQtQ== X-Received: by 2002:a05:600c:4ba2:: with SMTP id e34mr2387347wmp.50.1631274635240; Fri, 10 Sep 2021 04:50:35 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::b1d]) by smtp.gmail.com with ESMTPSA id t18sm4284829wrp.97.2021.09.10.04.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 04:50:34 -0700 (PDT) In-Reply-To: <877dfopsoa.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 10 Sep 2021 13:37:57 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214000 Archived-At: On Fri, 10 Sep 2021 at 13:37, Lars Ingebrigtsen wrote: > Augusto Stoffel writes: > >> To alleviate this, the completion-at-point function could implement some >> sort of caching. The difficult question is when to invalidate the >> cache. I've attached one possiblility as a draft patch. If the >> approach seems reasonable, then I'll format it properly. > > Would it be possible to do caching at a lower level instead of in > python-mode? I'm not an expert in this either, but I think the caching mechanism would be pretty particular to the circumstances of each completion table, so it indeed belongs here. Maybe Jo=C3=A3o can say more? Since this comint-based completion is not super smart (it's not context-dependent at all), the rather naive caching invalidation used here seems sufficient to me. > >> As a side effect, the patch also solves the original issue described in >> this ticket. > > [...] > >> - (list start end >> - (completion-table-dynamic >> - (apply-partially >> - completion-fn >> - process import-statement))))) >> + (let ((re (or (car python-shell--capf-cache) regexp-unmatchable)) >> + (prefix (buffer-substring-no-properties start end))) >> + (unless (string-match re prefix) >> + (setq python-shell--capf-cache >> + (cons (concat "\\`" (regexp-quote prefix) >> "\\(?:\\sw\\|\\s_\\)*\\'") >> + (funcall completion-fn process import-statement prefix))))) >> + (list start end (cdr python-shell--capf-cache)))) > > I'm not sure I understand this patch -- it's not using > `completion-table-dynamic' at all now? (But my understanding of the > completion functions in Emacs is pretty lacking.) That's true: the logic here is that the completions are computed eagerly, and then cached until still valid. So if you type foo.bar.baz the inferior process is contacted 3 times: after the , and after each dot. Before, a lazy table was returned, but the inferior would be contacted after each character anyway (if using Company or similar).