emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104936: * net/tramp-cmds.el (tramp-c


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104936: * net/tramp-cmds.el (tramp-cleanup-this-connection): New command.
Date: Mon, 04 Jul 2011 14:12:38 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104936
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Mon 2011-07-04 14:12:38 +0200
message:
  * net/tramp-cmds.el (tramp-cleanup-this-connection): New command.
  
  * net/tramp-sh.el (tramp-color-escape-sequence-regexp): New defconst.
  (tramp-sh-handle-insert-directory, tramp-convert-file-attributes):
  Use it.
  (tramp-remote-path): Add "/bin" and "/usr/bin".  On busyboxes,
  `tramp-default-remote-path' does not exist.
  (tramp-send-command-and-read): New optional argument NOERROR.
  (tramp-open-connection-setup-interactive-shell)
  (tramp-get-remote-path, tramp-get-remote-stat): Use it.
  (tramp-get-remote-readlink): Do not mask with `ignore-errors'.
  (tramp-process-sentinel): Flush also process' connection property.
  (tramp-sh-handle-start-file-process): Do not set process
  sentinel.  It is done now ...
  (tramp-maybe-open-connection): ... here.  (Bug#8929)
modified:
  lisp/ChangeLog
  lisp/net/tramp-cmds.el
  lisp/net/tramp-sh.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-07-04 11:44:36 +0000
+++ b/lisp/ChangeLog    2011-07-04 12:12:38 +0000
@@ -1,3 +1,21 @@
+2011-07-04  Michael Albinus  <address@hidden>
+
+       * net/tramp-cmds.el (tramp-cleanup-this-connection): New command.
+
+       * net/tramp-sh.el (tramp-color-escape-sequence-regexp): New defconst.
+       (tramp-sh-handle-insert-directory, tramp-convert-file-attributes):
+       Use it.
+       (tramp-remote-path): Add "/bin" and "/usr/bin".  On busyboxes,
+       `tramp-default-remote-path' does not exist.
+       (tramp-send-command-and-read): New optional argument NOERROR.
+       (tramp-open-connection-setup-interactive-shell)
+       (tramp-get-remote-path, tramp-get-remote-stat): Use it.
+       (tramp-get-remote-readlink): Do not mask with `ignore-errors'.
+       (tramp-process-sentinel): Flush also process' connection property.
+       (tramp-sh-handle-start-file-process): Do not set process
+       sentinel.  It is done now ...
+       (tramp-maybe-open-connection): ... here.  (Bug#8929)
+
 2011-07-04  MON KEY  <address@hidden>
 
        * play/animate.el (animate-string): Doc fixes and allow changing

=== modified file 'lisp/net/tramp-cmds.el'
--- a/lisp/net/tramp-cmds.el    2011-05-23 17:57:17 +0000
+++ b/lisp/net/tramp-cmds.el    2011-07-04 12:12:38 +0000
@@ -100,6 +100,15 @@
       (when (bufferp buf) (kill-buffer buf)))))
 
 ;;;###tramp-autoload
+(defun tramp-cleanup-this-connection ()
+  "Flush all connection related objects of the current buffer's connection."
+  (interactive)
+  (and (stringp default-directory)
+       (file-remote-p default-directory)
+       (tramp-cleanup-connection
+       (tramp-dissect-file-name default-directory 'noexpand))))
+
+;;;###tramp-autoload
 (defun tramp-cleanup-all-connections ()
   "Flush all Tramp internal objects.
 This includes password cache, file cache, connection cache, buffers."

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2011-07-01 09:14:31 +0000
+++ b/lisp/net/tramp-sh.el      2011-07-04 12:12:38 +0000
@@ -66,6 +66,9 @@
   :group 'tramp
   :type 'string)
 
+(defconst tramp-color-escape-sequence-regexp "\e[[;0-9]+m"
+  "Escape sequences produced by the \"ls\" command.")
+
 ;; ksh on OpenBSD 4.5 requires that $PS1 contains a `#' character for
 ;; root users.  It uses the `$' character for other users.  In order
 ;; to guarantee a proper prompt, we use "#$ " for the prompt.
@@ -484,7 +487,7 @@
 ;; FreeBSD: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"!
 ;; IRIX64: /usr/bin
 (defcustom tramp-remote-path
-  '(tramp-default-remote-path "/usr/sbin" "/usr/local/bin"
+  '(tramp-default-remote-path "/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin"
     "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
     "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin")
   "*List of directories to search for executables on remote host.
@@ -2582,6 +2585,12 @@
          (forward-line 1)
          (delete-region (match-beginning 0) (point)))
 
+       ;; Some busyboxes are reluctant to discard colors.
+       (unless (string-match "color" (tramp-get-connection-property v "ls" ""))
+         (goto-char beg)
+         (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
+           (replace-match "")))
+
        ;; The inserted file could be from somewhere else.
        (when (and (not wildcard) (not full-directory-p))
          (goto-char (point-max))
@@ -2669,6 +2678,7 @@
     (let ((vec (tramp-get-connection-property proc "vector" nil)))
       (when vec
        (tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event)
+        (tramp-flush-connection-property proc)
         (tramp-flush-directory-property vec "")))))
 
 ;; We use BUFFER also as connection buffer during setup. Because of
@@ -2721,9 +2731,7 @@
                       v 'file-error
                       "pty association is not supported for `%s'" name)))))
              (let ((p (tramp-get-connection-process v)))
-               ;; Set sentinel and query flag for this process.
-               (tramp-set-connection-property p "vector" v)
-               (set-process-sentinel p 'tramp-process-sentinel)
+               ;; Set query flag for this process.
                (tramp-compat-set-process-query-on-exit-flag p t)
                ;; Return process.
                p)))
@@ -3834,10 +3842,9 @@
     (tramp-send-command vec "stty -oxtabs" t))
 
   ;; Set `remote-tty' process property.
-  (ignore-errors
-    (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"")))
-      (unless (zerop (length tty))
-       (tramp-compat-process-put proc 'remote-tty tty))))
+  (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"" 'noerror)))
+    (unless (zerop (length tty))
+      (tramp-compat-process-put proc 'remote-tty tty)))
 
   ;; Dump stty settings in the traces.
   (when (>= tramp-verbose 9)
@@ -4300,11 +4307,15 @@
                                 tramp-encoding-command-interactive)
                         (list tramp-encoding-shell))))))
 
+           ;; Set sentinel and query flag.
+           (tramp-set-connection-property p "vector" vec)
+           (set-process-sentinel p 'tramp-process-sentinel)
+           (tramp-compat-set-process-query-on-exit-flag p nil)
+
            (tramp-message
             vec 6 "%s" (mapconcat 'identity (process-command p) " "))
 
            ;; Check whether process is alive.
-           (tramp-compat-set-process-query-on-exit-flag p nil)
            (tramp-barf-if-no-shell-prompt
             p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell)
 
@@ -4492,9 +4503,10 @@
   (unless (tramp-send-command-and-check vec command)
     (apply 'tramp-error vec 'file-error fmt args)))
 
-(defun tramp-send-command-and-read (vec command)
+(defun tramp-send-command-and-read (vec command &optional noerror)
   "Run COMMAND and return the output, which must be a Lisp expression.
-In case there is no valid Lisp expression, it raises an error"
+In case there is no valid Lisp expression and NOERROR is nil, it
+raises an error."
   (tramp-barf-unless-okay vec command "`%s' returns with error" command)
   (with-current-buffer (tramp-get-connection-buffer vec)
     ;; Read the expression.
@@ -4504,16 +4516,21 @@
          ;; Error handling.
          (when (re-search-forward "\\S-" (point-at-eol) t)
            (error nil)))
-      (error (tramp-error
-             vec 'file-error
-             "`%s' does not return a valid Lisp expression: `%s'"
-             command (buffer-string))))))
+      (error (unless noerror
+              (tramp-error
+               vec 'file-error
+               "`%s' does not return a valid Lisp expression: `%s'"
+               command (buffer-string)))))))
 
 (defun tramp-convert-file-attributes (vec attr)
   "Convert file-attributes ATTR generated by perl script, stat or ls.
 Convert file mode bits to string and set virtual device number.
 Return ATTR."
   (when attr
+    ;; Remove color escape sequences from symlink.
+    (when (stringp (car attr))
+      (while (string-match tramp-color-escape-sequence-regexp (car attr))
+       (setcar attr (replace-match "" nil nil (car attr)))))
     ;; Convert last access time.
     (unless (listp (nth 4 attr))
       (setcar (nthcdr 4 attr)
@@ -4691,8 +4708,7 @@
             (when elt1
               (or
                (tramp-send-command-and-read
-                vec
-                "x=`getconf PATH 2>/dev/null` && echo \\\"$x\\\" || echo nil")
+                vec "echo \\\"`getconf PATH 2>/dev/null`\\\"" 'noerror)
                ;; Default if "getconf" is not available.
                (progn
                  (tramp-message
@@ -4854,15 +4870,12 @@
     (let ((result (tramp-find-executable
                   vec "stat" (tramp-get-remote-path vec)))
          tmp)
-      ;; Check whether stat(1) returns usable syntax.  %s does not
+      ;; Check whether stat(1) returns usable syntax.  "%s" does not
       ;; work on older AIX systems.
       (when result
        (setq tmp
-             ;; We don't want to display an error message.
-             (tramp-compat-with-temp-message (or (current-message) "")
-               (ignore-errors
-                 (tramp-send-command-and-read
-                  vec (format "%s -c '(\"%%N\" %%s)' /" result)))))
+             (tramp-send-command-and-read
+              vec (format "%s -c '(\"%%N\" %%s)' /" result) 'noerror))
        (unless (and (listp tmp) (stringp (car tmp))
                     (string-match "^./.$" (car tmp))
                     (integerp (cadr tmp)))
@@ -4875,11 +4888,8 @@
     (let ((result (tramp-find-executable
                   vec "readlink" (tramp-get-remote-path vec))))
       (when (and result
-                ;; We don't want to display an error message.
-                (tramp-compat-with-temp-message (or (current-message) "")
-                  (ignore-errors
-                    (tramp-send-command-and-check
-                     vec (format "%s --canonicalize-missing /" result)))))
+                (tramp-send-command-and-check
+                 vec (format "%s --canonicalize-missing /" result)))
        result))))
 
 (defun tramp-get-remote-trash (vec)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]