Todd Goldfinger <goldf...@gmail.com> writes:

> Michael,

Hi Todd,

> That function is in a gzip file on my system. I copied to the scratch
> buffer and manually applied the patch. So it does fix the problem!

Great, so this is solved.

> However, it still seems to be a bit slow to respond, and when I
> checked the messages buffer, I saw the following a few dozen times.
> From a quick glance, the customizations that get written look to be
> the same as before.
>
> Saving file /mnt/home/share/.emacs.d/init.el...
> Wrote /mnt/home/share/.emacs.d/init.el

Good point. The customization shall be saved only when needed. I've
reworked the patch, see appended.

> Todd

Best regards, Michael.

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 9f868ccdaa0..7df455954d8 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4624,25 +4624,29 @@ tramp-add-hops
   "Add ad-hoc proxy definitions to `tramp-default-proxies-alist'."
   (when-let ((hops (tramp-file-name-hop vec))
 	     (item vec))
-    (dolist (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit)))
-      (let* ((host-port (tramp-file-name-host-port item))
-	     (user-domain (tramp-file-name-user-domain item))
-	     (proxy (concat
-		     tramp-prefix-format proxy tramp-postfix-host-format))
-	     (entry
-	      (list (and (stringp host-port)
-			 (tramp-compat-rx bol (literal host-port) eol))
-		    (and (stringp user-domain)
-			 (tramp-compat-rx bol (literal user-domain) eol))
-		    (propertize proxy 'tramp-ad-hoc t))))
-	(tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry)
-	;; Add the hop.
-	(add-to-list 'tramp-default-proxies-alist entry)
-	(setq item (tramp-dissect-file-name proxy))))
-    ;; Save the new value.
-    (when tramp-save-ad-hoc-proxies
-      (customize-save-variable
-       'tramp-default-proxies-alist tramp-default-proxies-alist))))
+    (let (signal-hook-function changed)
+      (dolist
+	  (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit)))
+	(let* ((host-port (tramp-file-name-host-port item))
+	       (user-domain (tramp-file-name-user-domain item))
+	       (proxy (concat
+		       tramp-prefix-format proxy tramp-postfix-host-format))
+	       (entry
+		(list (and (stringp host-port)
+			   (tramp-compat-rx bol (literal host-port) eol))
+		      (and (stringp user-domain)
+			   (tramp-compat-rx bol (literal user-domain) eol))
+		      (propertize proxy 'tramp-ad-hoc t))))
+	  ;; Add the hop.
+	  (unless (member entry tramp-default-proxies-alist)
+	    (tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry)
+	    (add-to-list 'tramp-default-proxies-alist entry)
+	    (setq changed t))
+	  (setq item (tramp-dissect-file-name proxy))))
+      ;; Save the new value.
+      (when (and tramp-save-ad-hoc-proxies changed)
+	(customize-save-variable
+	 'tramp-default-proxies-alist tramp-default-proxies-alist)))))

 (defun tramp-compute-multi-hops (vec)
   "Expands VEC according to `tramp-default-proxies-alist'."

Reply via email to