From 61addbc212a08ba146fc7baa7b3c04071f4445fb Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 16 Feb 2013 18:44:00 +0100 Subject: [PATCH] * net/tramp-cache.el (tramp-connection-properties): New customer option. (tramp-get-connection-property): Use it. * net/tramp-compat.el (top): Require 'trampver. * net/tramp-sh.el (tramp-remote-process-environment): Set tramp-autoload cookie. --- lisp/ChangeLog | 11 +++++++++++ lisp/net/tramp-cache.el | 37 ++++++++++++++++++++++++++++++++++--- lisp/net/tramp-compat.el | 1 + lisp/net/tramp-sh.el | 1 + 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0718296dffd..dd738ca9430 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2013-02-16 Michael Albinus + + * net/tramp-cache.el (tramp-connection-properties): New customer + option. + (tramp-get-connection-property): Use it. + + * net/tramp-compat.el (top): Require 'trampver. + + * net/tramp-sh.el (tramp-remote-process-environment): Set + tramp-autoload cookie. + 2013-02-16 Kevin Ryde * info-look.el (info-lookup-select-mode): If major-mode has no diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index d1ef1739bf7..dc45a57b7c6 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -58,6 +58,19 @@ (defvar tramp-cache-data (make-hash-table :test 'equal) "Hash table for remote files properties.") +;;;###tramp-autoload +(defcustom tramp-connection-properties nil + "List of static connection properties. +Every entry has the form (REGEXP PROPERTY VALUE). The regexp +matches remote file names. It can be nil. PROPERTY is a string, +and VALUE the corresponding value. They are used, if there is no +matching entry in for PROPERTY in `tramp-cache-data'." + :group 'tramp + :version "24.4" + :type '(repeat (list (choice :tag "File Name regexp" regexp (const nil)) + (choice :tag " Property" string) + (choice :tag " Value" sexp)))) + (defcustom tramp-persistency-file-name (cond ;; GNU Emacs. @@ -204,9 +217,27 @@ If the value is not set for the connection, returns DEFAULT." (setq key (copy-sequence key)) (aset key 3 nil)) (let* ((hash (gethash key tramp-cache-data)) - (value (if (hash-table-p hash) - (gethash property hash default) - default))) + (value + (catch 'result + (or + ;; Check for dynamic properties. + (and + (hash-table-p hash) + (maphash + (lambda (x y) (when (equal x property) (throw 'result y))) + hash)) + ;; Check for static properties. + (and + (vectorp key) + (dolist (elt tramp-connection-properties) + (when (and (string-match + (or (nth 0 elt) "") + (tramp-make-tramp-file-name + (aref key 0) (aref key 1) (aref key 2) nil)) + (string-equal (or (nth 1 elt) "") (or property ""))) + (throw 'result (nth 2 elt))))) + ;; The default value. + default)))) (tramp-message key 7 "%s %s" property value) value)) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 12510bf7fab..81c4d5ccced 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -52,6 +52,7 @@ (require 'format-spec) (require 'shell) + (require 'trampver) (require 'tramp-loaddefs) ;; As long as password.el is not part of (X)Emacs, it shouldn't be diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 001a27f3b2e..9be22352b23 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -512,6 +512,7 @@ as given in your `~/.profile'." (const :tag "Private Directories" tramp-own-remote-path) (string :tag "Directory")))) +;;;###tramp-autoload (defcustom tramp-remote-process-environment `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C" ,(format "TERM=%s" tramp-terminal-type)