(require 'assoc)
(require 'tramp)
(require 'tramp-compat)
-(require 'message)
-(require 'imap-hash)
-(require 'epa)
+
(autoload 'auth-source-user-or-password "auth-source")
+(autoload 'epg-context-operation "epg")
+(autoload 'epg-context-set-armor "epg")
+(autoload 'epg-context-set-passphrase-callback "epg")
+(autoload 'epg-context-set-progress-callback "epg")
+(autoload 'epg-decrypt-string "epg")
+(autoload 'epg-encrypt-string "epg")
+(autoload 'imap-hash-get "imap-hash")
+(autoload 'imap-hash-make "imap-hash")
+(autoload 'imap-hash-map "imap-hash")
+(autoload 'imap-hash-put "imap-hash")
+(autoload 'imap-hash-rem "imap-hash")
;; We use the additional header "X-Size" for encoding the size of a file.
-(add-to-list 'imap-hash-headers 'X-Size 'append)
+(eval-after-load "imap-hash"
+ '(add-to-list 'imap-hash-headers 'X-Size 'append))
;; Define Tramp IMAP method ...
(defconst tramp-imap-method "imap"
(defgroup tramp-imap nil
"Tramp over IMAP configuration."
:version "23.2"
- :group 'applications)
+ :group 'tramp)
(defcustom tramp-imap-subject-marker "tramp-imap-subject-marker"
"The subject marker that Tramp-IMAP will use."
(filename switches &optional wildcard full-directory-p)
"Like `insert-directory' for Tramp files."
(setq filename (expand-file-name filename))
- (when full-directory-p
- ;; Called from `dired-add-entry'.
- (setq filename (file-name-as-directory filename)))
+ (if full-directory-p
+ ;; Called from `dired-add-entry'.
+ (setq filename (file-name-as-directory filename))
+ (setq filename (directory-file-name filename)))
(with-parsed-tramp-file-name filename nil
(save-match-data
(let ((base (file-name-nondirectory localname))
(nth 6 x)))) ; date
;; For the file name, we set the `dired-filename'
;; property. This allows to handle file names with
- ;; leading or trailing spaces as well.
+ ;; leading or trailing spaces as well. The inserted name
+ ;; could be from somewhere else, so we use the relative
+ ;; file name of `default-directory'.
(let ((pos (point)))
- (insert (format "%s" (nth 0 x))) ; file name
- (put-text-property pos (point) 'dired-filename t))
- (insert "\n")
+ (insert
+ (format
+ "%s\n"
+ (file-relative-name
+ (expand-file-name (nth 0 x) (file-name-directory filename)))))
+ (put-text-property pos (1- (point)) 'dired-filename t))
(forward-line)
(beginning-of-line)))
- entries)))))
+ entries)))))
(defun tramp-imap-handle-insert-file-contents
(filename &optional visit beg end replace)
(read-passwd
(if (eq key-id 'PIN)
"Tramp-IMAP passphrase for PIN: "
- (let ((entry (assoc key-id epg-user-id-alist)))
+ (let ((entry (assoc key-id
+ (symbol-value 'epg-user-id-alist))))
(if entry
(format "Tramp-IMAP passphrase for %s %s: "
key-id (cdr entry))