From: Michael Albinus Date: Wed, 15 Sep 2010 20:27:11 +0000 (+0200) Subject: * net/tramp-compat.el (tramp-compat-with-temp-message) X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~47^2~119^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6139f995addcb8fce63deb30c7ed0e6f2b618b02;p=emacs.git * net/tramp-compat.el (tramp-compat-with-temp-message) (tramp-compat-font-lock-add-keywords, tramp-compat-process-get) (tramp-compat-process-put): New defuns. * net/tramp.el (top): * net/tramp-gvfs.el (top): * net/tramp-cache.el (top): Use `tramp-compat-font-lock-add-keywords'. * net/tramp.el (tramp-progress-reporter-update): Use `tramp-compat-funcall. * net/tramp.el (tramp-process-actions): * net/tramp-gvfs.el (tramp-handle-vc-registered): * net/tramp-sh.el (tramp-gvfs-handler-askquestion) (tramp-get-remote-stat, tramp-get-remote-readlink): Use `tramp-compat-with-temp-message'. * net/tramp-sh.el (top): Require 'cl. (tramp-handle-start-file-process): Use `tramp-compat-process-get'. (tramp-open-connection-setup-interactive-shell): Use `tramp-compat-process-put'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7731c6686b7..48b5581d8a9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,27 @@ +2010-09-15 Michael Albinus + + * net/tramp-compat.el (tramp-compat-with-temp-message) + (tramp-compat-font-lock-add-keywords, tramp-compat-process-get) + (tramp-compat-process-put): New defuns. + + * net/tramp.el (top): + * net/tramp-gvfs.el (top): + * net/tramp-cache.el (top): Use `tramp-compat-font-lock-add-keywords'. + + * net/tramp.el (tramp-progress-reporter-update): Use + `tramp-compat-funcall. + + * net/tramp.el (tramp-process-actions): + * net/tramp-gvfs.el (tramp-handle-vc-registered): + * net/tramp-sh.el (tramp-gvfs-handler-askquestion) + (tramp-get-remote-stat, tramp-get-remote-readlink): Use + `tramp-compat-with-temp-message'. + + * net/tramp-sh.el (top): Require 'cl. + (tramp-handle-start-file-process): Use `tramp-compat-process-get'. + (tramp-open-connection-setup-interactive-shell): Use + `tramp-compat-process-put'. + 2010-09-15 Alan Mackenzie * progmodes/cc-engine.el (c-forward-<>-arglist-recur): Correct the @@ -238,7 +262,7 @@ * net/tramp-sh.el: New file, derived from tramp.el. (top): Initialize `tramp-methods', `tramp-default-method-alist', - `tramp-default-user-alist', tramp-foreign-file-name-handler-alist. + `tramp-default-user-alist', `tramp-foreign-file-name-handler-alist'. Remove "scp1_old", "scp2_old", "ssh1_old", "ssh2_old". Use `ignore-errors' where appropriate. (tramp-sh-file-name-handler-alist): Renamed from diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index 7a55a4978d1..5745546e3e8 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -152,8 +152,8 @@ FILE must be a local file name on a connection identified via VEC." ;;;###tramp-autoload (put 'with-file-property 'lisp-indent-function 3) (put 'with-file-property 'edebug-form-spec t) -;;;###tramp-autoload -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) ;;;###tramp-autoload (defun tramp-flush-file-property (vec file) @@ -255,8 +255,8 @@ PROPERTY is set persistent when KEY is a vector." ;;;###tramp-autoload (put 'with-connection-property 'lisp-indent-function 2) (put 'with-connection-property 'edebug-form-spec t) -;;;###tramp-autoload -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) ;;;###tramp-autoload (defun tramp-flush-connection-property (key) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index d17ad8d09ce..4da2fb33771 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -96,11 +96,6 @@ (defvar byte-compile-not-obsolete-vars nil)) (setq byte-compile-not-obsolete-vars '(directory-sep-char)) - ;; `with-temp-message' does not exists in XEmacs. - (condition-case nil - (with-temp-message (current-message) nil) - (error (defmacro with-temp-message (message &rest body) `(progn ,@body)))) - ;; For not existing functions, or functions with a changed argument ;; list, there are compiler warnings. We want to avoid them in ;; cases we know what we do. @@ -114,10 +109,6 @@ (unless (fboundp 'set-buffer-multibyte) (defalias 'set-buffer-multibyte 'ignore)) - ;; `font-lock-add-keywords' does not exist in XEmacs. - (unless (fboundp 'font-lock-add-keywords) - (defalias 'font-lock-add-keywords 'ignore)) - ;; The following functions cannot be aliases of the corresponding ;; `tramp-handle-*' functions, because this would bypass the locking ;; mechanism. @@ -190,6 +181,19 @@ 'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards) (ad-activate 'file-expand-wildcards))))) +;; `with-temp-message' does not exists in XEmacs. +(if (fboundp 'with-temp-message) + (defalias 'tramp-compat-with-temp-message 'with-temp-message) + (defun tramp-compat-with-temp-message (message &rest body) + "Display MESSAGE temporarily if non-nil while BODY is evaluated." + `(progn ,@body))) + +;; `font-lock-add-keywords' does not exist in XEmacs. +(defun tramp-compat-font-lock-add-keywords (mode keywords &optional how) + "Add highlighting KEYWORDS for MODE." + (ignore-errors + (tramp-compat-funcall 'font-lock-add-keywords mode keywords how))) + (defsubst tramp-compat-line-beginning-position () "Return point at beginning of line (compat function). Calls `line-beginning-position' or `point-at-bol' if defined, else @@ -474,6 +478,18 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." (setenv "UNIX95" unix95) result))))) +;; The following functions do not exist in XEmacs. We ignore this; +;; they are used for checking a remote tty. +(defun tramp-compat-process-get (process propname) + "Return the value of PROCESS' PROPNAME property. +This is the last value stored with `(process-put PROCESS PROPNAME VALUE)'." + (ignore-errors (tramp-compat-funcall 'process-get process propname))) + +(defun tramp-compat-process-put (process propname value) + "Change PROCESS' PROPNAME property to VALUE. +It can be retrieved with `(process-get PROCESS PROPNAME)'." + (ignore-errors (tramp-compat-funcall 'process-put process propname value))) + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-compat 'force))) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index adcda5ebb80..cd2bab26f47 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -498,7 +498,8 @@ will be traced by Tramp with trace level 6." (put 'with-tramp-dbus-call-method 'lisp-indent-function 2) (put 'with-tramp-dbus-call-method 'edebug-form-spec '(form symbolp body)) -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) (defmacro with-tramp-gvfs-error-message (filename handler &rest args) "Apply a Tramp GVFS `handler'. @@ -519,7 +520,8 @@ In case of an error, modify the error message by replacing (put 'with-tramp-gvfs-error-message 'lisp-indent-function 2) (put 'with-tramp-gvfs-error-message 'edebug-form-spec '(form symbolp body)) -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) (defvar tramp-gvfs-dbus-event-vector nil "Current Tramp file name to be used, as vector. @@ -973,7 +975,7 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"." ;; host signature. (with-temp-buffer ;; Preserve message for `progress-reporter'. - (with-temp-message "" + (tramp-compat-with-temp-message "" (insert message) (pop-to-buffer (current-buffer)) (setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6d51da3bf97..423b4fcbd5e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -27,6 +27,7 @@ ;;; Code: +(eval-when-compile (require 'cl)) ; ignore-errors (require 'tramp) (require 'shell) @@ -2855,7 +2856,8 @@ beginning of local filename are not substituted." (tramp-send-command v command nil t) ; nooutput ;; Check, whether a pty is associated. (tramp-maybe-open-connection v) - (unless (process-get (tramp-get-connection-process v) 'remote-tty) + (unless (tramp-compat-process-get + (tramp-get-connection-process v) 'remote-tty) (tramp-error v 'file-error "pty association is not supported for `%s'" name))) (let ((p (tramp-get-connection-process v))) @@ -3659,7 +3661,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." ;; any other remote command. (defun tramp-handle-vc-registered (file) "Like `vc-registered' for Tramp files." - (with-temp-message "" + (tramp-compat-with-temp-message "" (with-parsed-tramp-file-name file nil (with-progress-reporter v 3 (format "Checking `vc-registered' for %s" file) @@ -4139,7 +4141,8 @@ process to set up. VEC specifies the connection." ;; Set `remote-tty' process property. (ignore-errors (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\""))) - (unless (zerop (length tty)) (process-put proc 'remote-tty tty)))) + (unless (zerop (length tty)) + (tramp-compat-process-put proc 'remote-tty tty)))) ;; Set the environment. (tramp-message vec 5 "Setting default environment") @@ -5268,7 +5271,7 @@ Return the local name of the temporary file." (when result (setq tmp ;; We don't want to display an error message. - (with-temp-message (or (current-message) "") + (tramp-compat-with-temp-message (or (current-message) "") (ignore-errors (tramp-send-command-and-read vec (format "%s -c '(\"%%N\" %%s)' /" result))))) @@ -5285,7 +5288,7 @@ Return the local name of the temporary file." vec "readlink" (tramp-get-remote-path vec)))) (when (and result ;; We don't want to display an error message. - (with-temp-message (or (current-message) "") + (tramp-compat-with-temp-message (or (current-message) "") (ignore-errors (tramp-send-command-and-check vec (format "%s --canonicalize-missing /" result))))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index d03201a3afb..3a3b3ad35e0 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1413,13 +1413,14 @@ If VAR is nil, then we bind `v' to the structure and `method', `user', (put 'with-parsed-tramp-file-name 'lisp-indent-function 2) (put 'with-parsed-tramp-file-name 'edebug-form-spec '(form symbolp body)) -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) (defun tramp-progress-reporter-update (reporter &optional value) (let* ((parameters (cdr reporter)) (message (aref parameters 3))) (when (string-match message (or (current-message) "")) - (funcall 'progress-reporter-update reporter value)))) + (tramp-compat-funcall 'progress-reporter-update reporter value)))) (defmacro with-progress-reporter (vec level message &rest body) "Executes BODY, spinning a progress reporter with MESSAGE. @@ -1450,7 +1451,8 @@ progress reporter." (put 'with-progress-reporter 'lisp-indent-function 3) (put 'with-progress-reporter 'edebug-form-spec t) -(font-lock-add-keywords 'emacs-lisp-mode '("\\")) +(tramp-compat-font-lock-add-keywords + 'emacs-lisp-mode '("\\")) (eval-and-compile ;; Silence compiler. (if (memq system-type '(cygwin windows-nt)) @@ -2688,7 +2690,7 @@ The terminal type can be configured with `tramp-terminal-type'." (defun tramp-process-actions (proc vec actions &optional timeout) "Perform actions until success or TIMEOUT." ;; Preserve message for `progress-reporter'. - (with-temp-message "" + (tramp-compat-with-temp-message "" ;; Enable auth-source and password-cache. (tramp-set-connection-property vec "first-password-request" t) (let (exit)