diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2019-03-09 16:44:24 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2019-03-09 16:44:24 +0100 |
commit | 21f54feee8c83e2c5fd8eeb6741cbd479a7b19eb (patch) | |
tree | 3edf223c49dfedf09ec93804856954a9554a93cd /lisp/files-x.el | |
parent | c37bdd00c7dcabaa3ca8405d9dc5122ed36f27e0 (diff) | |
download | emacs-21f54feee8c83e2c5fd8eeb6741cbd479a7b19eb.tar.gz |
Do not hardcode "/bin/sh" in compile. Bug#24338, Bug#29723
* doc/emacs/custom.texi (Connection Variables): New node.
* doc/emacs/emacs.texi (Top): Add entry for Connection Variables.
* doc/emacs/misc.texi (Single Shell): Mention default value for
remote buffers.
* doc/lispref/variables.texi (Connection Local Variables):
Describe `with-connection-local-variables' instead of
`with-connection-local-profiles'.
* doc/misc/tramp.texi (Remote processes): Refer to Emacs manual.
Mention default connection-local settings for `shell-file-name'
and `shell-command-switch'.
* etc/NEWS: Mention connection-local variables changes.
* lisp/files-x.el (hack-connection-local-variables):
Push connection-local variables to `file-local-variables-alist'.
(connection-local-criteria-for-default-directory): New defsubst.
(with-connection-local-variables): Rename from
`with-connection-local-profiles'. Adapt implementation.
* lisp/files.el (hack-local-variables):
Call `hack-connection-local-variables'.
* lisp/shell.el (shell): Use `with-connection-local-variables'.
* lisp/subr.el (start-file-process-shell-command):
* lisp/progmodes/compile.el (compilation-start):
Use `with-connection-local-variables'. Do not set "/bin/sh" for
remote buffers, trust settings of `shell-file-name'. (Bug#24338),
(Bug#29723)
* lisp/net/ange-ftp.el (ange-ftp-compress, ange-ftp-uncompress):
Use `shell-command-switch'.
* lisp/net/tramp-adb.el (tramp-adb-connection-local-default-profile):
New defvar. Add it to connection-local profiles after loading "shell".
* lisp/net/tramp-integration.el (tramp-compat): Require tramp-compat.
(tramp-compat-exec-path): Do not declare anymore.
(tramp-connection-local-safe-shell-file-names): New defvar.
(tramp-connection-local-default-profile): New defconst. Activate
it after loading "shell".
(shell-file-name, shell-command-switch): Add safe-local-variable
property.
* lisp/net/tramp-sh.el (tramp-display-escape-sequence-regexp):
Add tramp-autoload cookie.
* test/lisp/files-x-tests.el (remote-shell-file-name):
Add safe-local-variable property to remote-* variables.
(tramp-connection-local-default-profile): Declare.
(files-x-test-with-connection-local-variables):
Rename from `files-x-test-with-connection-local-profiles'. Adapt
implementation.
* test/lisp/net/tramp-tests.el
(tramp-test34-connection-local-variables): New test.
(tramp-test34-explicit-shell-file-name): Run it also for tramp-adb.
Bind connection-local-{profile,criteria}-alist. Use tramp-adb
specific `shell-file-name'. Add safe-local-variable property to
`explicit-shell-file-name' and `explicit-sh-args'.
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r-- | lisp/files-x.el | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index c9abb695700..eedf630b71f 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -582,7 +582,7 @@ changed by the user.") (setq ignored-local-variables (cons 'connection-local-variables-alist ignored-local-variables)) -(defvar connection-local-profile-alist '() +(defvar 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). @@ -590,7 +590,7 @@ 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 '() +(defvar 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 @@ -685,7 +685,9 @@ This does nothing if `enable-connection-local-variables' is nil." ;; Loop over variables. (dolist (variable (connection-local-get-profile-variables profile)) (unless (assq (car variable) connection-local-variables-alist) - (push variable connection-local-variables-alist)))))) + (push variable connection-local-variables-alist)))) + ;; Push them to `file-local-variables-alist'. + (hack-local-variables-filter connection-local-variables-alist nil))) ;;;###autoload (defun hack-connection-local-variables-apply (criteria) @@ -697,24 +699,35 @@ will not be changed." (copy-tree connection-local-variables-alist))) (hack-local-variables-apply))) +(defsubst connection-local-criteria-for-default-directory () + "Return a connection-local criteria, which represents `default-directory'." + (when (file-remote-p default-directory) + `(:application tramp + :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-profiles (profiles &rest body) - "Apply connection-local variables according to PROFILES in current buffer. +(defmacro with-connection-local-variables (&rest body) + "Apply connection-local variables according to `default-directory'. Execute BODY, and unwind connection-local variables." - (declare (indent 1) (debug t)) - `(let ((enable-connection-local-variables t) - (old-buffer-local-variables (buffer-local-variables)) - connection-local-variables-alist connection-local-criteria-alist) - (apply 'connection-local-set-profiles nil ,profiles) - (hack-connection-local-variables-apply nil) - (unwind-protect - (progn ,@body) - ;; Cleanup. - (dolist (variable connection-local-variables-alist) - (let ((elt (assq (car variable) old-buffer-local-variables))) - (if elt - (set (make-local-variable (car elt)) (cdr elt)) - (kill-local-variable (car variable)))))))) + (declare (debug t)) + `(if (file-remote-p default-directory) + (let ((enable-connection-local-variables t) + (old-buffer-local-variables (buffer-local-variables)) + connection-local-variables-alist) + (hack-connection-local-variables-apply + (connection-local-criteria-for-default-directory)) + (unwind-protect + (progn ,@body) + ;; Cleanup. + (dolist (variable connection-local-variables-alist) + (let ((elt (assq (car variable) old-buffer-local-variables))) + (if elt + (set (make-local-variable (car elt)) (cdr elt)) + (kill-local-variable (car variable))))))) + ;; No connection-local variables to apply. + ,@body)) |