diff options
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r-- | lisp/files-x.el | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index e86ba8f8d04..0ae9fb076eb 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -579,15 +579,22 @@ changed by the user.") (setq ignored-local-variables (cons 'connection-local-variables-alist ignored-local-variables)) -(defvar connection-local-profile-alist nil +(defcustom connection-local-profile-alist nil "Alist mapping connection profiles to variable lists. Each element in this list has the form (PROFILE VARIABLES). PROFILE is the name of a connection profile (a symbol). VARIABLES is a list that declares connection-local variables for PROFILE. An element in VARIABLES is an alist whose elements are -of the form (VAR . VALUE).") - -(defvar connection-local-criteria-alist nil +of the form (VAR . VALUE)." + :type '(repeat (cons (symbol :tag "Profile") + (repeat :tag "Variables" + (cons (symbol :tag "Variable") + (sexp :tag "Value"))))) + :group 'files + :group 'tramp + :version "29.1") + +(defcustom connection-local-criteria-alist nil "Alist mapping connection criteria to connection profiles. Each element in this list has the form (CRITERIA PROFILES). CRITERIA is a plist identifying a connection and the application @@ -596,7 +603,19 @@ using this connection. Property names might be `:application', `:application' is a symbol, all other property values are strings. All properties are optional; if CRITERIA is nil, it always applies. -PROFILES is a list of connection profiles (symbols).") +PROFILES is a list of connection profiles (symbols)." + :type '(repeat (cons (plist :tag "Criteria" + ;; Give the most common options as checkboxes. + :options (((const :format "%v " :application) + symbol) + ((const :format "%v " :protocol) string) + ((const :format "%v " :user) string) + ((const :format "%v " :machine) string))) + (repeat :tag "Profiles" + (symbol :tag "Profile")))) + :group 'files + :group 'tramp + :version "29.1") (defsubst connection-local-normalize-criteria (criteria) "Normalize plist CRITERIA according to properties. @@ -649,7 +668,9 @@ variables for a connection profile are defined using (setcdr slot (delete-dups (append (cdr slot) profiles))) (setq connection-local-criteria-alist (cons (cons criteria (delete-dups profiles)) - connection-local-criteria-alist))))) + connection-local-criteria-alist)))) + (customize-set-variable + 'connection-local-criteria-alist connection-local-criteria-alist)) (defsubst connection-local-get-profile-variables (profile) "Return the connection-local variable list for PROFILE." @@ -668,7 +689,9 @@ connection profile using `connection-local-set-profiles'. Then 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)) + (setf (alist-get profile connection-local-profile-alist) variables) + (customize-set-variable + 'connection-local-profile-alist connection-local-profile-alist)) (defun hack-connection-local-variables (criteria) "Read connection-local variables according to CRITERIA. @@ -699,14 +722,18 @@ will not be changed." (copy-tree connection-local-variables-alist))) (hack-local-variables-apply))) +(defvar connection-local-default-application 'tramp + "Default application in connection-local functions, a symbol. +This variable must not be changed globally.") + (defsubst connection-local-criteria-for-default-directory (&optional application) "Return a connection-local criteria, which represents `default-directory'. -If APPLICATION is nil, the symbol `tramp' is used." +If APPLICATION is nil, `connection-local-default-application' is used." (when (file-remote-p default-directory) - `(:application ,(or application 'tramp) - :protocol ,(file-remote-p default-directory 'method) - :user ,(file-remote-p default-directory 'user) - :machine ,(file-remote-p default-directory 'host)))) + `(:application ,(or application connection-local-default-application) + :protocol ,(file-remote-p default-directory 'method) + :user ,(file-remote-p default-directory 'user) + :machine ,(file-remote-p default-directory 'host)))) ;;;###autoload (defmacro with-connection-local-variables (&rest body) |