all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jimmy Wong <wyuenho@gmail.com>
Cc: 63300@debbugs.gnu.org
Subject: bug#63300: 29.0.90; Tramp keeps customizing variables on every connection
Date: Tue, 06 Jun 2023 13:46:52 +0200	[thread overview]
Message-ID: <87y1kwq0cz.fsf@gmx.de> (raw)
In-Reply-To: <3aba5090-3ed7-4a2b-b65c-872880e2bf76@Spark> (Jimmy Wong's message of "Sun, 4 Jun 2023 17:55:42 +0100")

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

Jimmy Wong <wyuenho@gmail.com> writes:

Hi,

> Actually, I take it back. customize-save-variable only saves variables
> that have the saved-value symbol property set. This property is
> normally set by customize when it is saved to the custom file.
> Something in Tramp is setting this property without saving the
> variable values to the custom file or going through customize. In
> fact, you can see it via M-x customize-option
> connection-local-criteria-alist. The value will be shown as SAVED.

This property is set as well in custom-set-variables.

> In addition, setting `enable-connection-local-variables` to nil early
> in early-init.el has no effect, the variable is still set on load.

This is a different game. enable-connection-local-variables has no
effect on setting / saving connection-local-criteria-alist and
connection-local-profile-alist. e-c-l-v is used only in
hack-connection-local-variables in order to control, whether
connection-local variables shall be set as buffer-local variables. And
the documentation is clear about, that it isn't intended to be used on
user level, see (info "(elisp) Applying Connection Local Variables")

--8<---------------cut here---------------start------------->8---
 -- Variable: enable-connection-local-variables
     If ‘nil’, connection-local variables are ignored.  This variable
     shall be changed temporarily only in special modes.
--8<---------------cut here---------------end--------------->8---

> Both of this behavior violate what is documented in the docstring and
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Properties.html.

No.

> If you must, enable-conneciton-local-variables should be respected,
> and if you must, set the theme-value property on these
> connection-local variables instead of saved-value so custom-save-all
> will not save them.

No.

In connection-local-set-profiles and connection-local-set-profile-variables
it should be checked, whether the saved-value property is set. If not,
it shall be reset to nil, after custom-set-variables has been called.

The appended patch shall do the trick. Could you, please, test?

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2160 bytes --]

diff --git a/lisp/files-x.el b/lisp/files-x.el
index 548d9efc193..bae535da550 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -674,15 +674,18 @@ connection-local-set-profiles
   (dolist (profile profiles)
     (unless (assq profile connection-local-profile-alist)
       (error "No such connection profile `%s'" (symbol-name profile))))
-  (let* ((criteria (connection-local-normalize-criteria criteria))
+  (let* ((saved-value (get 'connection-local-criteria-alist 'saved-value))
+         (criteria (connection-local-normalize-criteria criteria))
          (slot (assoc criteria connection-local-criteria-alist)))
     (if slot
         (setcdr slot (delete-dups (append (cdr slot) profiles)))
       (setq connection-local-criteria-alist
             (cons (cons criteria (delete-dups profiles))
-		  connection-local-criteria-alist))))
-  (custom-set-variables
-   `(connection-local-criteria-alist ',connection-local-criteria-alist now)))
+		  connection-local-criteria-alist)))
+    (custom-set-variables
+     `(connection-local-criteria-alist ',connection-local-criteria-alist now))
+    (unless saved-value
+      (put 'connection-local-criteria-alist 'saved-value nil))))

 (defsubst connection-local-get-profile-variables (profile)
   "Return the connection-local variable list for PROFILE."
@@ -701,9 +704,12 @@ connection-local-set-profile-variables
 variables are set in the server's process buffer according to the
 VARIABLES list of the connection profile.  The list is processed
 in order."
-  (setf (alist-get profile connection-local-profile-alist) variables)
-  (custom-set-variables
-   `(connection-local-profile-alist ',connection-local-profile-alist now)))
+  (let ((saved-value (get 'connection-local-profile-alist 'saved-value)))
+    (setf (alist-get profile connection-local-profile-alist) variables)
+    (custom-set-variables
+     `(connection-local-profile-alist ',connection-local-profile-alist now))
+    (unless saved-value
+      (put 'connection-local-profile-alist 'saved-value nil))))

 ;;;###autoload
 (defun connection-local-update-profile-variables (profile variables)

      parent reply	other threads:[~2023-06-06 11:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 10:42 bug#63300: 29.0.90; Tramp keeps customizing variables on every connection Jimmy Yuen Ho Wong
2023-06-04  8:59 ` Michael Albinus
2023-06-04 11:30   ` Jimmy Wong
2023-06-04 11:42     ` Michael Albinus
2023-06-04 11:44       ` Jimmy Wong
2023-06-04 11:56         ` Michael Albinus
2023-06-04 11:59       ` Jimmy Wong
2023-06-04 12:05         ` Michael Albinus
2023-06-04 12:16           ` Jimmy Wong
2023-06-04 12:21             ` Michael Albinus
2023-06-04 12:22               ` Jimmy Wong
2023-06-04 16:55                 ` Jimmy Wong
2023-06-04 17:24                   ` Eli Zaretskii
2023-06-06 11:35                     ` Michael Albinus
2023-06-06 12:04                       ` Eli Zaretskii
2023-06-08  8:08                         ` Michael Albinus
2023-06-06 11:46                   ` Michael Albinus [this message]

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

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

  git send-email \
    --in-reply-to=87y1kwq0cz.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=63300@debbugs.gnu.org \
    --cc=wyuenho@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.