From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Speed up project-kill-buffers Date: Tue, 25 May 2021 04:30:57 +0300 Message-ID: <07c39e36-83f6-b139-68d5-5b3fc68217bd@yandex.ru> References: <87mttcgnke.fsf@posteo.net> <871raoezl0.fsf@posteo.net> <86r1ihig9p.fsf@stephe-leake.org> <25bc7f1c-92e5-6b13-a6a4-d48b64b32ad3@yandex.ru> <86im3i76xa.fsf@stephe-leake.org> <86pmxmz45m.fsf@stephe-leake.org> <86lf89zjkh.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4302"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 Cc: Philip Kaludercic , Stefan Monnier , emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 25 04:14:09 2021 Return-path: Envelope-to: ged-emacs-devel@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 1llMa9-0000wy-1y for ged-emacs-devel@m.gmane-mx.org; Tue, 25 May 2021 04:14:09 +0200 Original-Received: from localhost ([::1]:53718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llMa8-0003NT-0c for ged-emacs-devel@m.gmane-mx.org; Mon, 24 May 2021 22:14:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llLuT-0001mq-O6 for emacs-devel@gnu.org; Mon, 24 May 2021 21:31:05 -0400 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:36778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llLuP-0008B4-98 for emacs-devel@gnu.org; Mon, 24 May 2021 21:31:05 -0400 Original-Received: by mail-wr1-x42b.google.com with SMTP id n4so4421368wrw.3 for ; Mon, 24 May 2021 18:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gun4vs1RrpC0SFSBBd7wAvhijU4XOAf7+NEwkQDEMTM=; b=dYFC7UMdqkCCJg68iFBXcnnKbFEjxipV8TJO8dlPD9m9WYdmH9ma15EicQqS9Pf+7k etLXy24cu00XEjR7tsNr5vJZJ7DdHBQM2P90SGJpAQkojGahPgptGLArApkoiy67o7qO LEFNcu01WDZoC63JllnNSsuJOsq3hJnKD25CCMEKipqxsMRdkeGIxdIVFevyKR2dPMFk MsZTGOD59kLsrbmeK2CVXvY2wwP9fbEfgEyE8ASGodvx5wkbTdl/uBhBJRHpQcgHXyAV 3fsJ5EM9CDCo8V2wVYiaGstnZgLY1DZBLdAji/nW2P0CMpd8MxXkU36buK37gJA82ZZA D9Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gun4vs1RrpC0SFSBBd7wAvhijU4XOAf7+NEwkQDEMTM=; b=W1zNi4lVE/gnOlCo/+K5wj0Lc2WGCsrZmpN/BE0L3xAgV/14vT76UhwCShyBcXu8MJ ySCnH5QP+dUbDT4OVPCw8gOsIRY+ANzpQOmnmc197qdeiorNZIcoUwv3CQHsZqfrVob/ 7ifLPALfxafaGnvUVqujgx1rmuzIhGxBhuLG+ORjJ+t43i2Yxh4yHGrv5NznBeDqSvM4 rJdTYS6z2kpNIYWR/QyjCES+WxH1pf6+wDbWtbiwFL36IYUiues4JHHf7P2y8E1AVcAP Aej3+P20arJTZFgiGGKenRWSsN8fQY/xltndg6G28C4DZA68s59c+gRvibAx+/0fLXxh bmEg== X-Gm-Message-State: AOAM533uoWGQBNADXGSm/Y+wePw1nRKQ5ayHg+PxEC7Lbh25v+vS2l7S xukEMhuPjH4C1jdacfMH5xG0162Bsf4= X-Google-Smtp-Source: ABdhPJx/cF55wWhGG7Wdd+LDi4YgeDxdjE0zRukA/Tzfv+S4XKgL3EJ1d2m+XZGATbtiSWMJ76yCug== X-Received: by 2002:a5d:648e:: with SMTP id o14mr23919060wri.27.1621906258968; Mon, 24 May 2021 18:30:58 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id d14sm7637874wra.5.2021.05.24.18.30.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 18:30:58 -0700 (PDT) In-Reply-To: <86lf89zjkh.fsf@stephe-leake.org> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269825 Archived-At: On 20.05.2021 15:16, Stephen Leake wrote: > Stephen Leake writes: > >> Hmm. I just found project-kill-buffer-conditions; maybe I could >> customize that; it allows arbitrary predicate functions. It would be >> more efficient if the predicate function were also passed the project >> object, so it doesn't have to call project-current again (hmm - shades >> of project-delete-this-buffer-p :). > > This works for wisi projects, but not for the elisp project (it signals > an error): I suppose if you set project-find-functions to a local value in emacs-lisp-mode buffers (which is IMO unusual), you could also set project-kill-buffer-conditions to a different local value in those buffers? > (defun wisi-prj-kill-buffer-condition (buffer) > "Return non-nil if BUFFER should be killed. > For `project-kill-buffer-conditions'." > (let* ((source-path (wisi-prj-source-path (project-current))) Are those just project sources or dependency dirs as well? > (buf-file-name (buffer-file-name buffer)) > (done (not (buffer-file-name buffer))) > (result nil) > dir) > (while (and source-path > (not done)) > (setq dir (pop source-path)) > (when (and dir > (file-in-directory-p buf-file-name dir)) > (setq done t) > (setq result t))) > result)) On the face of it, project-kill-buffer-conditions could use a PROJECT argument to improve efficiency, but if you have a var which points to the global project, your 'project-current' probably works very quickly. So there wouldn't be much actual speedup in your case. You can prove me wrong with (benchmark 1 '...) or (benchmark-progn ...).