* minibuffer.el: Revert change from 2013-08-20.
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 26 Aug 2013 13:17:22 +0000 (15:17 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 26 Aug 2013 13:17:22 +0000 (15:17 +0200)
* net/tramp.el (tramp-find-method, tramp-find-user): Mark result
with text property `tramp-default', if appropriate.
(tramp-check-proper-host): New defun.
(tramp-dissect-file-name): Do not check hostname.  Revert change
of 2013-03-18.
(tramp-backtrace): Make VEC-OR-PROC optional.

* net/tramp-adb.el (tramp-adb-maybe-open-connection):
* net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
* net/tramp-sh.el (tramp-maybe-open-connection):
* net/tramp-smb.el (tramp-smb-maybe-open-connection): Apply
`tramp-check-proper-host'.

lisp/ChangeLog
lisp/minibuffer.el
lisp/net/tramp-adb.el
lisp/net/tramp-compat.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp.el

index 53fd127..3153825 100644 (file)
@@ -1,3 +1,20 @@
+2013-08-26  Michael Albinus  <michael.albinus@gmx.de>
+
+       * minibuffer.el: Revert change from 2013-08-20.
+
+       * net/tramp.el (tramp-find-method, tramp-find-user): Mark result
+       with text property `tramp-default', if appropriate.
+       (tramp-check-proper-host): New defun.
+       (tramp-dissect-file-name): Do not check hostname.  Revert change
+       of 2013-03-18.
+       (tramp-backtrace): Make VEC-OR-PROC optional.
+
+       * net/tramp-adb.el (tramp-adb-maybe-open-connection):
+       * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
+       * net/tramp-sh.el (tramp-maybe-open-connection):
+       * net/tramp-smb.el (tramp-smb-maybe-open-connection): Apply
+       `tramp-check-proper-host'.
+
 2013-08-26  Tassilo Horn  <tsdh@gnu.org>
 
        * epa-hook.el (epa-file-encrypt-to): Quote `safe-local-variable'
index 72cb6f7..e07d28a 100644 (file)
@@ -2246,8 +2246,7 @@ same as `substitute-in-file-name'."
   ;; - Cygwin (substitute-in-file-name "C:\bin") => "/usr/bin"
   ;;          (substitute-in-file-name "C:\") => "/"
   ;;          (substitute-in-file-name "C:\bi") => "/bi"
-  (let* ((non-essential t)
-        (ustr (substitute-in-file-name qstr))
+  (let* ((ustr (substitute-in-file-name qstr))
          (uprefix (substring ustr 0 upos))
          qprefix)
     ;; Main assumption: nothing after qpos should affect the text before upos,
index 8ddbe25..ff6d0d1 100644 (file)
@@ -1092,6 +1092,8 @@ FMT and ARGS are passed to `error'."
   "Maybe open a connection VEC.
 Does not do anything if a connection is already open, but re-opens the
 connection if a previous connection has died for some reason."
+  (tramp-check-proper-host vec)
+
   (let* ((buf (tramp-get-connection-buffer vec))
         (p (get-buffer-process buf))
         (host (tramp-file-name-host vec))
index 71703fe..f090524 100644 (file)
@@ -521,6 +521,7 @@ EOL-TYPE can be one of `dos', `unix', or `mac'."
 ;; `user-error' has been added to Emacs 24.3.
 (defun tramp-compat-user-error (format &rest args)
   "Signal a pilot error."
+;  (tramp-backtrace)
   (apply (if (fboundp 'user-error) 'user-error 'error) format args))
 
 (add-hook 'tramp-unload-hook
index f70074b..e26ffb2 100644 (file)
@@ -1469,6 +1469,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
   "Maybe open a connection VEC.
 Does not do anything if a connection is already open, but re-opens the
 connection if a previous connection has died for some reason."
+  (tramp-check-proper-host vec)
 
   ;; We set the file name, in case there are incoming D-Bus signals or
   ;; D-Bus errors.
index b76ac2f..ac13176 100644 (file)
@@ -4326,6 +4326,8 @@ Gateway hops are already opened."
   "Maybe open a connection VEC.
 Does not do anything if a connection is already open, but re-opens the
 connection if a previous connection has died for some reason."
+  (tramp-check-proper-host vec)
+
   (catch 'uname-changed
     (let ((p (tramp-get-connection-process vec))
          (process-name (tramp-get-connection-property vec "process-name" nil))
index 39e87f9..569bfb9 100644 (file)
@@ -1564,6 +1564,8 @@ Does not do anything if a connection is already open, but re-opens the
 connection if a previous connection has died for some reason.
 If ARGUMENT is non-nil, use it as argument for
 `tramp-smb-winexe-program', and suppress any checks."
+  (tramp-check-proper-host vec)
+
   (let* ((share (tramp-smb-get-share vec))
         (buf (tramp-get-connection-buffer vec))
         (p (get-buffer-process buf)))
index cd7d17b..5f473a4 100644 (file)
@@ -1239,23 +1239,31 @@ their replacement."
       ;; This works with the current set of `tramp-obsolete-methods'.
       ;; Must be improved, if their are more sophisticated replacements.
       (setq result (substring result 0 -1)))
-    result))
+    ;; We must mark, whether a default value has been used.
+    (if (or method (null result))
+       result
+      (propertize result 'tramp-default t))))
 
 (defun tramp-find-user (method user host)
   "Return the right user string to use.
 This is USER, if non-nil. Otherwise, do a lookup in
 `tramp-default-user-alist'."
-  (or user
-      (let ((choices tramp-default-user-alist)
-           luser item)
-       (while choices
-         (setq item (pop choices))
-         (when (and (string-match (or (nth 0 item) "") (or method ""))
-                    (string-match (or (nth 1 item) "") (or host "")))
-           (setq luser (nth 2 item))
-           (setq choices nil)))
-       luser)
-      tramp-default-user))
+  (let ((result
+        (or user
+            (let ((choices tramp-default-user-alist)
+                  luser item)
+              (while choices
+                (setq item (pop choices))
+                (when (and (string-match (or (nth 0 item) "") (or method ""))
+                           (string-match (or (nth 1 item) "") (or host "")))
+                  (setq luser (nth 2 item))
+                  (setq choices nil)))
+              luser)
+            tramp-default-user)))
+    ;; We must mark, whether a default value has been used.
+    (if (or user (null result))
+       result
+      (propertize result 'tramp-default t))))
 
 (defun tramp-find-host (method user host)
   "Return the right host string to use.
@@ -1272,6 +1280,18 @@ This is HOST, if non-nil. Otherwise, it is `tramp-default-host'."
        lhost)
       tramp-default-host))
 
+(defun tramp-check-proper-host (vec)
+  "Check host name of VEC."
+  (let ((method (tramp-file-name-method vec))
+       (user (tramp-file-name-user vec))
+       (host (tramp-file-name-host vec)))
+    (when (and (equal tramp-syntax 'ftp) host
+              (or (null method) (get-text-property 0 'tramp-default method))
+              (or (null user) (get-text-property 0 'tramp-default user))
+              (member host (mapcar 'car tramp-methods)))
+      (tramp-compat-user-error
+       "Host name must not match method `%s'" host))))
+
 (defun tramp-dissect-file-name (name &optional nodefault)
   "Return a `tramp-file-name' structure.
 The structure consists of remote method, remote user, remote host
@@ -1290,12 +1310,7 @@ values."
          (when (string-match tramp-prefix-ipv6-regexp host)
            (setq host (replace-match "" nil t host)))
          (when (string-match tramp-postfix-ipv6-regexp host)
-           (setq host (replace-match "" nil t host)))
-         (when (and (equal tramp-syntax 'ftp) (null method) (null user)
-                    (member host (mapcar 'car tramp-methods))
-                    (not (tramp-completion-mode-p)))
-           (tramp-compat-user-error
-            "Host name must not match method `%s'" host)))
+           (setq host (replace-match "" nil t host))))
        (if nodefault
            (vector method user host localname hop)
          (vector
@@ -1537,10 +1552,14 @@ applicable)."
                   (concat (format "(%d) # " level) fmt-string)
                   arguments)))))))
 
-(defsubst tramp-backtrace (vec-or-proc)
+(defsubst tramp-backtrace (&optional vec-or-proc)
   "Dump a backtrace into the debug buffer.
-This function is meant for debugging purposes."
-  (tramp-message vec-or-proc 10 "\n%s" (with-output-to-string (backtrace))))
+If VEC-OR-PROC is nil, the buffer *debug tramp* is used.  This
+function is meant for debugging purposes."
+  (if vec-or-proc
+      (tramp-message vec-or-proc 10 "\n%s" (with-output-to-string (backtrace)))
+    (if (<= 10 tramp-verbose)
+       (with-output-to-temp-buffer "*debug tramp*" (backtrace)))))
 
 (defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments)
   "Emit an error.