unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Speed up project-kill-buffers
@ 2021-05-03  9:43 Philip Kaludercic
  2021-05-03 12:46 ` Stefan Monnier
  2021-05-03 21:43 ` Dmitry Gutov
  0 siblings, 2 replies; 26+ messages in thread
From: Philip Kaludercic @ 2021-05-03  9:43 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]


Hi,

I've noticed that sometimes project-kill-buffers is noticeably slow, and
it seems like it's has to do with project--buffer-list working on remote
files. The function goes through every buffer and calls
(project-current), even if the buffer is related to a remote file that
cannot be part of the current project.

The patch I attach below is a simple fix to avoid checking files that
cannot be part of the current project. Or are there any edge-cases that
this code approach breaks?

-- 
	Philip K.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-Tramp-buffers-when-possible.patch --]
[-- Type: text/x-diff, Size: 1246 bytes --]

From 8b45502da8281826fa2da02a317546bc99f51069 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Mon, 3 May 2021 11:35:41 +0200
Subject: [PATCH] Avoid Tramp buffers when possible

* project.el (project--buffer-list): Add file-remote-p check
---
 lisp/progmodes/project.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d47d9d77e6..33827136a1 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1120,11 +1120,14 @@ project-kill-buffer-conditions
 
 (defun project--buffer-list (pr)
   "Return the list of all buffers in project PR."
-  (let (bufs)
+  (let ((remote-project-p (file-remote-p (project-root pr)))
+        bufs)
     (dolist (buf (buffer-list))
-      (when (equal pr
-                   (with-current-buffer buf
-                     (project-current)))
+      (when (and (let ((remote (file-remote-p (buffer-local-value 'default-directory buf))))
+                   (if remote-project-p remote (not remote)))
+                 (equal pr
+                        (with-current-buffer buf
+                          (project-current))))
         (push buf bufs)))
     (nreverse bufs)))
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-08-09  3:01 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).