]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't loop so much in gud-query-cmdline on remote systems
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jan 2022 13:55:35 +0000 (14:55 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jan 2022 13:57:17 +0000 (14:57 +0100)
* lisp/progmodes/gud.el (gud-query-cmdline): Avoid looping over
large numbers of files on remote systems (bug#21528).

lisp/progmodes/gud.el

index b42279415bc6a3e096fb544e5558135896800bbe..7092ca2041fdc431cadafa648f40730faa28a4c7 100644 (file)
@@ -759,13 +759,18 @@ The option \"--fullname\" must be included in this value."
         (concat (or cmd-name (symbol-name minor-mode))
                 " "
                 (or init
-                    (let ((file nil))
-                      (dolist (f (directory-files default-directory) file)
-                        (if (and (file-executable-p f)
-                                 (not (file-directory-p f))
-                                 (or (not file)
-                                     (file-newer-than-file-p f file)))
-                            (setq file f)))))))
+                    (let ((file nil)
+                           (files (directory-files default-directory)))
+                       ;; On remote systems, this may be slow, so avoid it.
+                       (when (or (not (file-remote-p default-directory))
+                                 (length< files 50))
+                        (dolist (f files)
+                          (if (and (file-executable-p f)
+                                   (not (file-directory-p f))
+                                   (or (not file)
+                                       (file-newer-than-file-p f file)))
+                              (setq file f)))
+                            file)))))
      gud-minibuffer-local-map nil
      hist-sym)))