aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2017-04-02 11:02:54 +0200
committerMichael Albinus2017-04-02 11:02:54 +0200
commit59191cd0cbe8463f9095a71cb4048bb138d6e446 (patch)
treeea0e063deb25c07c6e315b02d3db427e25e917b8 /lisp
parent21918f4e1c5939038c7e8d0b8b8e8a647c086796 (diff)
downloademacs-59191cd0cbe8463f9095a71cb4048bb138d6e446.tar.gz
emacs-59191cd0cbe8463f9095a71cb4048bb138d6e446.zip
Apply connecion-local variables for shells
* doc/misc/tramp.texi (Remote processes): Show use of connection-local variables. Don't mention Emacs 23 anymore. (Frequently Asked Questions): Precise Emacs and MS Windows version. * lisp/files-x.el (connection-local-normalize-criteria): Suppress nil properties. (connection-local-set-profiles, with-connection-local-profiles): Adapt docstring. * lisp/shell.el (shell): Apply connecion-local variables.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files-x.el14
-rw-r--r--lisp/shell.el67
2 files changed, 43 insertions, 38 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el
index a0cad708425..b7c6f51e658 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -585,7 +585,7 @@ Return a new ordered plist list containing only property names from PROPERTIES."
585 nil 585 nil
586 (mapcar 586 (mapcar
587 (lambda (property) 587 (lambda (property)
588 (when (plist-member criteria property) 588 (when (and (plist-member criteria property) (plist-get criteria property))
589 (list property (plist-get criteria property)))) 589 (list property (plist-get criteria property))))
590 properties))) 590 properties)))
591 591
@@ -606,12 +606,10 @@ using this connection, see `connection-local-criteria-alist'."
606 606
607;;;###autoload 607;;;###autoload
608(defun connection-local-set-profiles (criteria &rest profiles) 608(defun connection-local-set-profiles (criteria &rest profiles)
609 "Add PROFILES for remote servers. 609 "Add PROFILES for CRITERIA.
610CRITERIA is either a regular expression identifying a remote 610CRITERIA is a plist identifying a connection and the application
611server, or a function with one argument IDENTIFICATION, which 611using this connection, see `connection-local-criteria-alist'.
612returns non-nil when a remote server shall apply PROFILE's 612PROFILES are the names of connection profiles (a symbol).
613variables. If CRITERIA is nil, it always applies.
614PROFILES are the names of a connection profile (a symbol).
615 613
616When a connection to a remote server is opened and CRITERIA 614When a connection to a remote server is opened and CRITERIA
617matches to that server, the connection-local variables from 615matches to that server, the connection-local variables from
@@ -678,7 +676,7 @@ will not be changed."
678;;;###autoload 676;;;###autoload
679(defmacro with-connection-local-profiles (profiles &rest body) 677(defmacro with-connection-local-profiles (profiles &rest body)
680 "Apply connection-local variables according to PROFILES in current buffer. 678 "Apply connection-local variables according to PROFILES in current buffer.
681Execute BODY, and unwind connection local variables." 679Execute BODY, and unwind connection-local variables."
682 (declare (indent 1) (debug t)) 680 (declare (indent 1) (debug t))
683 `(let ((enable-connection-local-variables t) 681 `(let ((enable-connection-local-variables t)
684 (old-buffer-local-variables (buffer-local-variables)) 682 (old-buffer-local-variables (buffer-local-variables))
diff --git a/lisp/shell.el b/lisp/shell.el
index c8a8555d632..55a053295fa 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -711,36 +711,43 @@ Otherwise, one argument `-i' is passed to the shell.
711 ;; If the current buffer is a dead shell buffer, use it. 711 ;; If the current buffer is a dead shell buffer, use it.
712 (current-buffer))) 712 (current-buffer)))
713 713
714 ;; On remote hosts, the local `shell-file-name' might be useless. 714 (with-current-buffer buffer
715 (if (and (called-interactively-p 'any) 715 (when (file-remote-p default-directory)
716 (file-remote-p default-directory) 716 ;; Apply connection-local variables.
717 (null explicit-shell-file-name) 717 (hack-connection-local-variables-apply
718 (null (getenv "ESHELL"))) 718 `(:application 'tramp
719 (with-current-buffer buffer 719 :protocol ,(file-remote-p default-directory 'method)
720 (set (make-local-variable 'explicit-shell-file-name) 720 :user ,(file-remote-p default-directory 'user)
721 (expand-file-name 721 :machine ,(file-remote-p default-directory 'host)))
722 (file-local-name 722
723 (read-file-name 723 ;; On remote hosts, the local `shell-file-name' might be useless.
724 "Remote shell path: " default-directory shell-file-name 724 (if (and (called-interactively-p 'any)
725 t shell-file-name)))))) 725 (null explicit-shell-file-name)
726 726 (null (getenv "ESHELL")))
727 ;; The buffer's window must be correctly set when we call comint (so 727 (set (make-local-variable 'explicit-shell-file-name)
728 ;; that comint sets the COLUMNS env var properly). 728 (expand-file-name
729 (pop-to-buffer buffer) 729 (file-local-name
730 (unless (comint-check-proc buffer) 730 (read-file-name
731 (let* ((prog (or explicit-shell-file-name 731 "Remote shell path: " default-directory shell-file-name
732 (getenv "ESHELL") shell-file-name)) 732 t shell-file-name))))))
733 (name (file-name-nondirectory prog)) 733
734 (startfile (concat "~/.emacs_" name)) 734 ;; The buffer's window must be correctly set when we call comint
735 (xargs-name (intern-soft (concat "explicit-" name "-args")))) 735 ;; (so that comint sets the COLUMNS env var properly).
736 (unless (file-exists-p startfile) 736 (pop-to-buffer buffer)
737 (setq startfile (concat user-emacs-directory "init_" name ".sh"))) 737 (unless (comint-check-proc buffer)
738 (apply 'make-comint-in-buffer "shell" buffer prog 738 (let* ((prog (or explicit-shell-file-name
739 (if (file-exists-p startfile) startfile) 739 (getenv "ESHELL") shell-file-name))
740 (if (and xargs-name (boundp xargs-name)) 740 (name (file-name-nondirectory prog))
741 (symbol-value xargs-name) 741 (startfile (concat "~/.emacs_" name))
742 '("-i"))) 742 (xargs-name (intern-soft (concat "explicit-" name "-args"))))
743 (shell-mode))) 743 (unless (file-exists-p startfile)
744 (setq startfile (concat user-emacs-directory "init_" name ".sh")))
745 (apply 'make-comint-in-buffer "shell" buffer prog
746 (if (file-exists-p startfile) startfile)
747 (if (and xargs-name (boundp xargs-name))
748 (symbol-value xargs-name)
749 '("-i")))
750 (shell-mode))))
744 buffer) 751 buffer)
745 752
746;;; Directory tracking 753;;; Directory tracking