]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-imap.el
Merge from mainline.
[gnu-emacs] / lisp / net / tramp-imap.el
index da75e2307ca64c84323378fa0c88339a44bae04a..92dbb4fef3a625317e7fc2d070ab18401f1ee64f 100644 (file)
 (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"
@@ -158,7 +168,7 @@ Operations not mentioned here will be handled by the default Emacs primitives.")
 (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."
@@ -385,9 +395,10 @@ SIZE MODE WEIRD INODE DEVICE)."
   (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))
@@ -462,14 +473,19 @@ SIZE MODE WEIRD INODE DEVICE)."
                (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)
@@ -662,7 +678,8 @@ KEY-ID can be 'SYM or 'PIN among others."
                  (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))