From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#58839: [Patch] Re: bug#58839: 29.0.50; project-kill-buffer fails when Eglot is running Date: Wed, 02 Nov 2022 07:29:58 +0000 Message-ID: <87wn8dbyq1.fsf@posteo.net> References: <87sfj8umwb.fsf@posteo.net> <871qqq7l9p.fsf@posteo.net> <87eduqwekz.fsf@gmail.com> <87wn8invbx.fsf@posteo.net> <877d0iw8iq.fsf@gmail.com> <837d0hhlke.fsf@gnu.org> <46ff0065-5645-ef1e-2621-242fb6a73f98@yandex.ru> <87v8o0uxn5.fsf@gmail.com> <787a4362-7ff5-7dbb-9118-16e4bee5f328@yandex.ru> <87edunvhf2.fsf@gmail.com> <6d4d9e72-1bae-4d64-b7c1-c2b9c11e396f@yandex.ru> <87tu3jgdbv.fsf@posteo.net> <87h6zihq3q.fsf@posteo.net> <877d0ehlnb.fsf@posteo.net> <87edumg4fd.fsf@posteo.net> <874jvig2rp.fsf@posteo.net> <87edulu8ly.fsf@gmail.com> 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="1606"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 58839@debbugs.gnu.org, Dmitry Gutov To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 02 08:31:20 2022 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 1oq8DV-0000BQ-Uz for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Nov 2022 08:31:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oq8DL-000336-4X; Wed, 02 Nov 2022 03:31:07 -0400 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 1oq8DG-00031f-A9 for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 03:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oq8DG-0003Ss-0B for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 03:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oq8DF-00013y-RP for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 03:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Nov 2022 07:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58839 X-GNU-PR-Package: emacs Original-Received: via spool by 58839-submit@debbugs.gnu.org id=B58839.16673742084004 (code B ref 58839); Wed, 02 Nov 2022 07:31:01 +0000 Original-Received: (at 58839) by debbugs.gnu.org; 2 Nov 2022 07:30:08 +0000 Original-Received: from localhost ([127.0.0.1]:44821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oq8CN-00012W-OS for submit@debbugs.gnu.org; Wed, 02 Nov 2022 03:30:08 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:35065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oq8CM-00010W-Kg for 58839@debbugs.gnu.org; Wed, 02 Nov 2022 03:30:07 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 40ED8240101 for <58839@debbugs.gnu.org>; Wed, 2 Nov 2022 08:29:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667374200; bh=jy9zFtFpB2mdtCFIsUzVAtH85CIH4/+iMLHUrPnmG6c=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=XJ5iAdUTJdkzFt8NjNbPXyD6PT8pct25g6YuuZq+efnCFgL7YhXXiE53B32PH579L uYQ7bBGGo3vjv8EMY7N4w8GoFPK4jLnzVUjO+8Q8Ko++ZWSawTq5WGN2l9cW0CZvSH ewJN1eXU7lk8gVrxfXN4BAOlzmwD7KYVZf3USEG81zyitNHBEHuoRaUasXNAJquBdj mFW7M7jogIgy+0IWVieyNQ7nEWat1/e/mYXq35dWjCsdQcaREndppClkmFv++qLNk2 5n10Z+X48AsVb8aoLrQ1C2n8chd6bcU/r34FsKWsRWjY9Dhx/B/q502T4dQbI6pDJ9 M1R/OuItgLeiA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N2JSQ4LqMz9rxH; Wed, 2 Nov 2022 08:29:58 +0100 (CET) In-Reply-To: <87edulu8ly.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Wed, 02 Nov 2022 07:19:05 +0000") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB 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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246843 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > Philip Kaludercic writes: > >>> Yes, do that, but use byte-compile instead, not eval. >> I have tried both, and it doesn't appear to be a particular advantage >> one way or another. That being said, this approach is *a lot* faster, >> to the point that I first assumed it was broken: > > Yes, this approach is always going to be much faster than the "naive" > approach. Now I've taken your code as a starting point, simplified it, > and I get a reasonable/typical 3.5x speedup when I use a > byte-compilation strategy, so one of us isn't measuring > > ```elisp > (defun translate-buffer-condition-1 (condition) > (pcase-exhaustive condition > ((or 't 'nil) > condition) > ((pred stringp) > `(string-match-p ,condition (buffer-name buffer))) > ((pred functionp) > `(,condition buffer)) This would break the current behaviour, because `buffer-match-p' requires the function be called with an additional argument if possible. This is fundamental for `display-buffer-alist' to work. > (`(major-mode . ,mode) > `(eq (buffer-local-value 'major-mode buffer) > ',mode)) > (`(derived-mode . ,mode) > `(provided-mode-derived-p > (buffer-local-value 'major-mode buffer) > ',mode)) > (`(not . ,cond) > `(not ,(translate-buffer-condition-1 cond))) > (`(or . ,conds) > `(or ,@(mapcar #'translate-buffer-condition-1 conds))) > (`(and . ,conds) > `(and ,@(mapcar #'translate-buffer-condition-1 conds))))) > > (defun translate-buffer-condition (condition) > `(lambda (buffer) ,(translate-buffer-condition-1 condition))) > > (defvar sample-condition > '(and (or buffer-file-name > (derived-mode . compilation-mode) > (derived-mode . dired-mode) > (derived-mode . diff-mode) > (derived-mode . comint-mode) > (derived-mode . eshell-mode) > (derived-mode . change-log-mode)) > "\\*.+\\*" > (not . "\\` "))) > > (defvar form (translate-buffer-condition sample-condition)) > (defvar compiled (byte-compile form)) > > (benchmark-run 100000 (funcall (eval form) (current-buffer))) ;; (0.39740= 4883 3 0.18942550900000032) > (benchmark-run 100000 (funcall compiled (current-buffer))) ;; (0.11365183= 6 0 0.0) > ``` > > I couldn't understand the need for a hash table or special symbol vars > or what that "arg" was, so I took it out, but it shouldn't make a > difference. The hash table makes a significant different, try evaluating (benchmark-run 100000 (funcall (byte-compile compiled) (current-buffer))= ) ;; (0.113651836 0 0.0) I have created a new bug report for this issue bug#58950, so that this one can return to the topic of project.el. The fresh symbols are used to keep the code clean and avoid possible naming conflicts.=20