emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Speed up project-kill-buffers


From: Philip Kaludercic
Subject: [PATCH] Speed up project-kill-buffers
Date: Mon, 03 May 2021 11:43:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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.

>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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]