+2010-10-05 Michael Albinus <michael.albinus@gmx.de>
+
+ * net/tramp.el (tramp-handle-directory-files-and-attributes)
+ (tramp-handle-file-exists-p, tramp-handle-file-newer-than-file-p):
+ New defuns, taken from tramp-smb.el.
+ (tramp-coding-system-change-eol-conversion)
+ (tramp-set-process-query-on-exit-flag): Removed.
+
+ * net/tramp-compat.el (top): Do not check for byte-compiler
+ objects.
+ (tramp-compat-coding-system-change-eol-conversion)
+ (tramp-compat-set-process-query-on-exit-flag): New defuns, taken
+ from tramp.el.
+
+ * net/tramp-gvfs.el:
+ * net/tramp-gw.el: Replace `tramp-set-process-query-on-exit-flag'
+ by `tramp-compat-set-process-query-on-exit-flag'.
+
+ * net/tramp-imap.el (tramp-imap-file-name-handler-alist): Use
+ `tramp-handle-directory-files-and-attributes',
+ `tramp-handle-file-exists-p' and
+ `tramp-handle-file-newer-than-file-p'.
+ (tramp-imap-handle-file-exists-p)
+ (tramp-imap-handle-file-executable-p)
+ (tramp-imap-handle-file-readable-p)
+ (tramp-imap-handle-directory-files-and-attributes)
+ (tramp-imap-handle-file-newer-than-file-p): Removed.
+
+ * net/tramp-sh.el: Replace `tramp-set-process-query-on-exit-flag'
+ by `tramp-compat-set-process-query-on-exit-flag' and
+ `tramp-coding-system-change-eol-conversion' by
+ `tramp-compat-coding-system-change-eol-conversion'.
+
+ * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use
+ `tramp-handle-directory-files-and-attributes',
+ `tramp-handle-file-exists-p' and
+ `tramp-handle-file-newer-than-file-p'.
+ (tramp-smb-handle-directory-files-and-attributes)
+ (tramp-smb-handle-file-exists-p)
+ (tramp-smb-handle-file-newer-than-file-p): Removed.
+ (tramp-smb-maybe-open-connection): Replace
+ `tramp-set-process-query-on-exit-flag' by
+ `tramp-compat-set-process-query-on-exit-flag'.
+
2010-10-05 Glenn Morris <rgm@gnu.org>
* obsolete/rnews.el, obsolete/rnewspost.el: Remove files.
;; needed to pacify Emacs byte-compiler.
;; Note that it was removed altogether in Emacs 24.1.
(when (boundp 'directory-sep-char)
- (unless (boundp 'byte-compile-not-obsolete-var)
- (defvar byte-compile-not-obsolete-var nil))
+ (defvar byte-compile-not-obsolete-var nil)
(setq byte-compile-not-obsolete-var 'directory-sep-char)
;; Emacs 23.2.
- (unless (boundp 'byte-compile-not-obsolete-vars)
- (defvar byte-compile-not-obsolete-vars nil))
+ (defvar byte-compile-not-obsolete-vars nil)
(setq byte-compile-not-obsolete-vars '(directory-sep-char)))
;; `remote-file-name-inhibit-cache' has been introduced with Emacs 24.1.
It can be retrieved with `(process-get PROCESS PROPNAME)'."
(ignore-errors (tramp-compat-funcall 'process-put process propname value)))
+(defun tramp-compat-set-process-query-on-exit-flag (process flag)
+ "Specify if query is needed for process when Emacs is exited.
+If the second argument flag is non-nil, Emacs will query the user before
+exiting if process is running."
+ (if (fboundp 'set-process-query-on-exit-flag)
+ (tramp-compat-funcall 'set-process-query-on-exit-flag process flag)
+ (tramp-compat-funcall 'process-kill-without-query process flag)))
+
(add-hook 'tramp-unload-hook
(lambda ()
(unload-feature 'tramp-compat 'force)))
+(defun tramp-compat-coding-system-change-eol-conversion (coding-system eol-type)
+ "Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
+EOL-TYPE can be one of `dos', `unix', or `mac'."
+ (cond ((fboundp 'coding-system-change-eol-conversion)
+ (tramp-compat-funcall
+ 'coding-system-change-eol-conversion coding-system eol-type))
+ ((fboundp 'subsidiary-coding-system)
+ (tramp-compat-funcall
+ 'subsidiary-coding-system coding-system
+ (cond ((eq eol-type 'dos) 'crlf)
+ ((eq eol-type 'unix) 'lf)
+ ((eq eol-type 'mac) 'cr)
+ (t
+ (error "Unknown EOL-TYPE `%s', must be %s"
+ eol-type
+ "`dos', `unix', or `mac'")))))
+ (t (error "Can't change EOL conversion -- is MULE missing?"))))
+
(provide 'tramp-compat)
;;; TODO:
(file-name-directory . tramp-handle-file-name-directory)
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
;; `file-name-sans-versions' performed by default handler.
- ;; CCC: Must be checked!
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-ownership-preserved-p . ignore)
(file-readable-p . tramp-gvfs-handle-file-readable-p)
:name (tramp-buffer-name vec)
:buffer (tramp-get-buffer vec)
:server t :host 'local :service t)))
- (tramp-set-process-query-on-exit-flag p nil)))
+ (tramp-compat-set-process-query-on-exit-flag p nil)))
(unless (tramp-gvfs-connection-mounted-p vec)
(let* ((method (tramp-file-name-method vec))
tramp-gw-vector 4
"Opening auxiliary process `%s', speaking with process `%s'"
proc tramp-gw-gw-proc)
- (tramp-set-process-query-on-exit-flag proc nil)
+ (tramp-compat-set-process-query-on-exit-flag proc nil)
;; We don't want debug messages, because the corresponding debug
;; buffer might be undecided.
(let (tramp-verbose)
:name (tramp-buffer-name aux-vec) :buffer nil :host 'local
:server t :noquery t :service t :coding 'binary))
(set-process-sentinel tramp-gw-aux-proc 'tramp-gw-aux-proc-sentinel)
- (tramp-set-process-query-on-exit-flag tramp-gw-aux-proc nil)
+ (tramp-compat-set-process-query-on-exit-flag tramp-gw-aux-proc nil)
(tramp-message
vec 4 "Opening auxiliary process `%s', listening on port %d"
tramp-gw-aux-proc (process-contact tramp-gw-aux-proc :service))))
(tramp-file-name-real-host target-vec)
(tramp-file-name-port target-vec)))
(set-process-sentinel tramp-gw-gw-proc 'tramp-gw-gw-proc-sentinel)
- (tramp-set-process-query-on-exit-flag tramp-gw-gw-proc nil)
+ (tramp-compat-set-process-query-on-exit-flag tramp-gw-gw-proc nil)
(tramp-message
vec 4 "Opened %s process `%s'"
(case gw-method ('tunnel "HTTP tunnel") ('socks "SOCKS"))
(setq proc (open-network-stream
name buffer (nth 1 socks-server) (nth 2 socks-server)))
(set-process-coding-system proc 'binary 'binary)
- (tramp-set-process-query-on-exit-flag proc nil)
+ (tramp-compat-set-process-query-on-exit-flag proc nil)
;; Send CONNECT command.
(process-send-string proc (format "%s%s\r\n" command authentication))
(tramp-message
(directory-file-name . tramp-handle-directory-file-name)
(directory-files . tramp-handle-directory-files)
(directory-files-and-attributes
- . tramp-imap-handle-directory-files-and-attributes)
+ . tramp-handle-directory-files-and-attributes)
(dired-call-process . ignore)
;; `dired-compress-file' performed by default handler
;; `dired-uncache' performed by default handler
;; `file-accessible-directory-p' performed by default handler
(file-attributes . tramp-imap-handle-file-attributes)
(file-directory-p . tramp-imap-handle-file-directory-p)
- (file-executable-p . tramp-imap-handle-file-executable-p)
- (file-exists-p . tramp-imap-handle-file-exists-p)
+ (file-executable-p . ignore)
+ (file-exists-p . tramp-handle-file-exists-p)
(file-local-copy . tramp-imap-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-imap-handle-file-name-all-completions)
(file-name-directory . tramp-handle-file-name-directory)
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
;; `file-name-sans-versions' performed by default handler
- (file-newer-than-file-p . tramp-imap-handle-file-newer-than-file-p)
+ (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-ownership-preserved-p . ignore)
- (file-readable-p . tramp-imap-handle-file-readable-p)
+ (file-readable-p . tramp-handle-file-exists-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-selinux-context' performed by default handler.
(goto-char point)
(list (expand-file-name filename) size))))))
-(defun tramp-imap-handle-file-exists-p (filename)
- "Like `file-exists-p' for Tramp files."
- (and (file-attributes filename) t))
-
(defun tramp-imap-handle-file-directory-p (filename)
"Like `file-directory-p' for Tramp-IMAP files."
;; We allow only mailboxes to be a directory.
"Get inode equivalent \(actually the UID) for Tramp-IMAP FILENAME."
(nth 10 (tramp-compat-file-attributes filename id-format)))
-(defun tramp-imap-handle-file-executable-p (filename)
- "Like `file-executable-p' for Tramp files. False for IMAP."
- nil)
-
-(defun tramp-imap-handle-file-readable-p (filename)
- "Like `file-readable-p' for Tramp files. True for IMAP."
- (file-exists-p filename))
-
(defun tramp-imap-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files. True for IMAP."
;; `file-exists-p' does not work yet for directories.
(let ((iht (tramp-imap-make-iht v)))
(imap-hash-rem (tramp-imap-get-file-inode filename) iht))))))
-(defun tramp-imap-handle-directory-files-and-attributes
- (directory &optional full match nosort id-format)
- "Like `directory-files-and-attributes' for Tramp files."
- (mapcar
- (lambda (x)
- (cons x (tramp-compat-file-attributes
- (if full x (expand-file-name x directory)) id-format)))
- (directory-files directory full match nosort)))
-
-;; TODO: fix this in tramp-imap-get-file-entries.
-(defun tramp-imap-handle-file-newer-than-file-p (file1 file2)
- "Like `file-newer-than-file-p' for Tramp files."
- (cond
- ((not (file-exists-p file1)) nil)
- ((not (file-exists-p file2)) t)
- (t (tramp-time-less-p (nth 5 (file-attributes file2))
- (nth 5 (file-attributes file1))))))
-
(defun tramp-imap-handle-file-local-copy (filename)
"Like `file-local-copy' for Tramp files."
(with-parsed-tramp-file-name (expand-file-name filename) nil
(append copy-args (list source target))))))
(tramp-message
v 6 "%s" (mapconcat 'identity (process-command p) " "))
- (tramp-set-process-query-on-exit-flag p nil)
+ (tramp-compat-set-process-query-on-exit-flag p nil)
(tramp-process-actions p v tramp-actions-copy-out-of-band))))
;; Reset the transfer process properties.
;; Set sentinel and query flag for this process.
(tramp-set-connection-property p "vector" v)
(set-process-sentinel p 'tramp-process-sentinel)
- (tramp-set-process-query-on-exit-flag p t)
+ (tramp-compat-set-process-query-on-exit-flag p t)
;; Return process.
p))
;; Save exit.
(setq cs-encode (cdr cs))
(unless cs-decode (setq cs-decode 'undecided))
(unless cs-encode (setq cs-encode 'undecided))
- (setq cs-encode (tramp-coding-system-change-eol-conversion
+ (setq cs-encode (tramp-compat-coding-system-change-eol-conversion
cs-encode 'unix))
(when (search-forward "\r" nil t)
- (setq cs-decode (tramp-coding-system-change-eol-conversion
+ (setq cs-decode (tramp-compat-coding-system-change-eol-conversion
cs-decode 'dos)))
(tramp-compat-funcall
'set-buffer-process-coding-system cs-decode cs-encode)
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Check whether process is alive.
- (tramp-set-process-query-on-exit-flag p nil)
+ (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)
(directory-file-name . tramp-handle-directory-file-name)
(directory-files . tramp-smb-handle-directory-files)
(directory-files-and-attributes
- . tramp-smb-handle-directory-files-and-attributes)
+ . tramp-handle-directory-files-and-attributes)
(dired-call-process . ignore)
(dired-compress-file . ignore)
(dired-uncache . tramp-handle-dired-uncache)
(file-accessible-directory-p . tramp-smb-handle-file-directory-p)
(file-attributes . tramp-smb-handle-file-attributes)
(file-directory-p . tramp-smb-handle-file-directory-p)
- (file-executable-p . tramp-smb-handle-file-exists-p)
- (file-exists-p . tramp-smb-handle-file-exists-p)
+ (file-executable-p . tramp-handle-file-exists-p)
+ (file-exists-p . tramp-handle-file-exists-p)
(file-local-copy . tramp-smb-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-smb-handle-file-name-all-completions)
(file-name-directory . tramp-handle-file-name-directory)
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
;; `file-name-sans-versions' performed by default handler.
- (file-newer-than-file-p . tramp-smb-handle-file-newer-than-file-p)
+ (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
(file-ownership-preserved-p . ignore)
- (file-readable-p . tramp-smb-handle-file-exists-p)
+ (file-readable-p . tramp-handle-file-exists-p)
(file-regular-p . tramp-handle-file-regular-p)
(file-remote-p . tramp-handle-file-remote-p)
;; `file-selinux-context' performed by default handler.
;; That's it.
result))
-(defun tramp-smb-handle-directory-files-and-attributes
- (directory &optional full match nosort id-format)
- "Like `directory-files-and-attributes' for Tramp files."
- (mapcar
- (lambda (x)
- (cons x (tramp-compat-file-attributes
- (if full x (expand-file-name x directory)) id-format)))
- (directory-files directory full match nosort)))
-
(defun tramp-smb-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for Tramp files."
;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
(and (file-exists-p filename)
(eq ?d (aref (nth 8 (file-attributes filename)) 0))))
-(defun tramp-smb-handle-file-exists-p (filename)
- "Like `file-exists-p' for Tramp files."
- (not (null (file-attributes filename))))
-
(defun tramp-smb-handle-file-local-copy (filename)
"Like `file-local-copy' for Tramp files."
(with-parsed-tramp-file-name filename nil
(nth 0 x))))
entries)))))))
-(defun tramp-smb-handle-file-newer-than-file-p (file1 file2)
- "Like `file-newer-than-file-p' for Tramp files."
- (cond
- ((not (file-exists-p file1)) nil)
- ((not (file-exists-p file2)) t)
- (t (tramp-time-less-p (nth 5 (file-attributes file2))
- (nth 5 (file-attributes file1))))))
-
(defun tramp-smb-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
(if (file-exists-p filename)
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
- (tramp-set-process-query-on-exit-flag p nil)
+ (tramp-compat-set-process-query-on-exit-flag p nil)
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method tramp-smb-method
result)))
(if nosort result (sort result 'string<)))))
+(defun tramp-handle-directory-files-and-attributes
+ (directory &optional full match nosort id-format)
+ "Like `directory-files-and-attributes' for Tramp files."
+ (mapcar
+ (lambda (x)
+ (cons x (tramp-compat-file-attributes
+ (if full x (expand-file-name x directory)) id-format)))
+ (directory-files directory full match nosort)))
+
(defun tramp-handle-dired-uncache (dir &optional dir-p)
"Like `dired-uncache' for Tramp files."
;; DIR-P is valid for XEmacs only.
(if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
(tramp-flush-directory-property v localname)))
+(defun tramp-handle-file-exists-p (filename)
+ "Like `file-exists-p' for Tramp files."
+ (not (null (file-attributes filename))))
+
(defun tramp-handle-file-modes (filename)
"Like `file-modes' for Tramp files."
(let ((truename (or (file-truename filename) filename)))
(with-parsed-tramp-file-name file nil
(tramp-run-real-handler 'file-name-nondirectory (list localname))))
+(defun tramp-handle-file-newer-than-file-p (file1 file2)
+ "Like `file-newer-than-file-p' for Tramp files."
+ (cond
+ ((not (file-exists-p file1)) nil)
+ ((not (file-exists-p file2)) t)
+ (t (tramp-time-less-p (nth 5 (file-attributes file2))
+ (nth 5 (file-attributes file1))))))
+
(defun tramp-handle-file-regular-p (filename)
"Like `file-regular-p' for Tramp files."
(and (file-exists-p filename)
(cadr time)
(/ (or (nth 2 time) 0) 1000000.0))))))
-(defun tramp-coding-system-change-eol-conversion (coding-system eol-type)
- "Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
-EOL-TYPE can be one of `dos', `unix', or `mac'."
- (cond ((fboundp 'coding-system-change-eol-conversion)
- (tramp-compat-funcall
- 'coding-system-change-eol-conversion coding-system eol-type))
- ((fboundp 'subsidiary-coding-system)
- (tramp-compat-funcall
- 'subsidiary-coding-system coding-system
- (cond ((eq eol-type 'dos) 'crlf)
- ((eq eol-type 'unix) 'lf)
- ((eq eol-type 'mac) 'cr)
- (t
- (error "Unknown EOL-TYPE `%s', must be %s"
- eol-type
- "`dos', `unix', or `mac'")))))
- (t (error "Can't change EOL conversion -- is MULE missing?"))))
-
-(defun tramp-set-process-query-on-exit-flag (process flag)
- "Specify if query is needed for process when Emacs is exited.
-If the second argument flag is non-nil, Emacs will query the user before
-exiting if process is running."
- (if (fboundp 'set-process-query-on-exit-flag)
- (tramp-compat-funcall 'set-process-query-on-exit-flag process flag)
- (tramp-compat-funcall 'process-kill-without-query process flag)))
-
;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
;; does not deal well with newline characters. Newline is replaced by
;; backslash newline. But if, say, the string `a backslash newline b'