unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stephen Leake <stephen_leake@stephe-leake.org>
Cc: Philip Kaludercic <philipk@posteo.net>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: Re: [PATCH] Speed up project-kill-buffers
Date: Tue, 25 May 2021 04:30:57 +0300	[thread overview]
Message-ID: <07c39e36-83f6-b139-68d5-5b3fc68217bd@yandex.ru> (raw)
In-Reply-To: <86lf89zjkh.fsf@stephe-leake.org>

On 20.05.2021 15:16, Stephen Leake wrote:
> Stephen Leake <stephen_leake@stephe-leake.org> 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 ...).



  reply	other threads:[~2021-05-25  1:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03  9:43 [PATCH] Speed up project-kill-buffers Philip Kaludercic
2021-05-03 12:46 ` Stefan Monnier
2021-05-03 13:06   ` Philip Kaludercic
2021-05-03 13:24     ` Stefan Monnier
2021-05-03 17:25       ` Philip Kaludercic
2021-05-03 21:12         ` Dmitry Gutov
2021-05-08 12:03       ` Stephen Leake
2021-05-08 12:30         ` Philip Kaludercic
2021-05-08 13:05           ` Philip Kaludercic
2021-05-08 17:01           ` Dmitry Gutov
2021-05-08 17:10         ` Dmitry Gutov
2021-05-16 20:36           ` Stephen Leake
2021-05-16 21:58             ` Dmitry Gutov
2021-05-19 23:37               ` Stephen Leake
2021-05-20 12:16                 ` Stephen Leake
2021-05-25  1:30                   ` Dmitry Gutov [this message]
2021-05-30 17:19                     ` Stephen Leake
2021-05-25  1:24                 ` Dmitry Gutov
2021-05-30 17:51                   ` Stephen Leake
2021-08-09  3:01                     ` Dmitry Gutov
2021-05-03 21:43 ` Dmitry Gutov
2021-05-03 22:45   ` Stefan Monnier
2021-05-03 22:46     ` Dmitry Gutov
2021-05-04  6:25       ` tomas
2021-05-04 10:40         ` Dmitry Gutov
2021-05-04 11:26           ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07c39e36-83f6-b139-68d5-5b3fc68217bd@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=philipk@posteo.net \
    --cc=stephen_leake@stephe-leake.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).