* wl-demo.el (wl-demo-insert-image): Make Emacs 21 use BITMAP-MULE for xbm if
[elisp/wanderlust.git] / wl / wl-summary.el
index 005108f..68d1356 100644 (file)
@@ -1,4 +1,4 @@
-;;; wl-summary.el -- Summary mode for Wanderlust.
+;;; wl-summary.el --- Summary mode for Wanderlust.
 
 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
 ;; Copyright (C) 1998,1999,2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
              wl-summary-buffer-unread-count unread))
     (+ new unread)))
 
+(defun wl-summary-message-string (&optional use-cache)
+  "Return full body string of current message.
+If optional USE-CACHE is non-nil, use cache if exists."
+  (let ((number (wl-summary-message-number))
+       (folder wl-summary-buffer-elmo-folder))
+    (if (null number)
+       (message "No message.")
+      (elmo-set-work-buf
+       (elmo-message-fetch folder
+                          number
+                          (elmo-make-fetch-strategy
+                           'entire
+                           use-cache ; use cache
+                           nil ; save cache (should `t'?)
+                           (and
+                            use-cache
+                            (elmo-file-cache-get-path
+                             (elmo-message-field folder number 'message-id))))
+                          nil
+                          (current-buffer)
+                          'unread)
+       (buffer-string)))))
+
 (defun wl-summary-reedit (&optional arg)
   "Re-edit current message.
 If ARG is non-nil, Supersedes message"
@@ -578,13 +601,7 @@ If ARG is non-nil, Supersedes message"
                  (mail-position-on-field "Newsgroups")
                (mail-position-on-field "To"))
              (delete-other-windows)))
-      (save-excursion
-       (let ((mmelmo-force-fetch-entire-message t))
-         (if (null (wl-summary-message-number))
-             (message "No message.")
-           (set-buffer (wl-summary-get-original-buffer))
-           (wl-draft-edit-string (buffer-substring (point-min)
-                                                   (point-max)))))))))
+      (wl-draft-edit-string (wl-summary-message-string)))))
 
 (defun wl-summary-resend-bounced-mail ()
   "Re-mail the current message.
@@ -593,37 +610,36 @@ contains some mail you have written but has been bounced back to
 you."
   (interactive)
   (save-excursion
-    (let ((mmelmo-force-fetch-entire-message t))
-      (wl-summary-set-message-buffer-or-redisplay)
-      (set-buffer (wl-message-get-original-buffer))
-      (goto-char (point-min))
-      (let ((case-fold-search nil))
-       (cond
-        ((and
-          (re-search-forward
-           (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
-          (not (bolp))
-          (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
-         (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
-               start)
-           (cond
-            ((and (setq start (re-search-forward
-                          (concat "^--" boundary "\n"
-                                  "\\([Cc]ontent-[Dd]escription:.*\n\\)?"
-                                  "[Cc]ontent-[Tt]ype:[ \t]+"
-                                  "\\(message/rfc822\\|text/rfc822-headers\\)\n"
-                                  "\\(.+\n\\)*\n") nil t))
-                  (re-search-forward
-                        (concat "\n\\(--" boundary "\\)--\n") nil t))
-             (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
-            (t
-             (message "Seems no message/rfc822 part.")))))
-        ((let ((case-fold-search t))
-           (re-search-forward wl-rejected-letter-start nil t))
-         (skip-chars-forward " \t\n")
-         (wl-draft-edit-string (buffer-substring (point) (point-max))))
-        (t
-         (message "Does not appear to be a rejected letter.")))))))
+    (wl-summary-set-message-buffer-or-redisplay)
+    (set-buffer (wl-message-get-original-buffer))
+    (goto-char (point-min))
+    (let ((case-fold-search nil))
+      (cond
+       ((and
+        (re-search-forward
+         (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
+        (not (bolp))
+        (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
+       (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
+             start)
+         (cond
+          ((and (setq start (re-search-forward
+                             (concat "^--" boundary "\n"
+                                     "\\([Cc]ontent-[Dd]escription:.*\n\\)?"
+                                     "[Cc]ontent-[Tt]ype:[ \t]+"
+                                     "\\(message/rfc822\\|text/rfc822-headers\\)\n"
+                                     "\\(.+\n\\)*\n") nil t))
+                (re-search-forward
+                 (concat "\n\\(--" boundary "\\)--\n") nil t))
+           (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
+          (t
+           (message "Seems no message/rfc822 part.")))))
+       ((let ((case-fold-search t))
+         (re-search-forward wl-rejected-letter-start nil t))
+       (skip-chars-forward " \t\n")
+       (wl-draft-edit-string (buffer-substring (point) (point-max))))
+       (t
+       (message "Does not appear to be a rejected letter."))))))
 
 (defun wl-summary-resend-message (address)
   "Resend the current message to ADDRESS."
@@ -747,8 +763,6 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
   (use-local-map wl-summary-mode-map)
 ;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
   (setq buffer-read-only t)
-  (make-local-variable 'truncate-partial-width-windows)
-  (setq truncate-partial-width-windows nil)
   (setq truncate-lines t)
 ;;;(make-local-variable 'tab-width)
 ;;;(setq tab-width 1)
@@ -759,7 +773,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
   (easy-menu-add wl-summary-mode-menu)
   (when wl-summary-lazy-highlight
     (make-local-variable 'window-scroll-functions)
-    (add-hook 'window-scroll-functions 'wl-highlight-summary-window))  
+    (add-hook 'window-scroll-functions 'wl-highlight-summary-window))
   ;; This hook may contain the function `wl-setup-summary' for reasons
   ;; of system internal to accord facilities for the Emacs variants.
   (run-hooks 'wl-summary-mode-hook))
@@ -1274,7 +1288,7 @@ If ARG is non-nil, checking is omitted."
                             "[ "
                             (save-match-data
                               (wl-set-string-width
-                               wl-from-width
+                               wl-summary-from-width
                                (wl-summary-from-func-internal
                                 (eword-decode-string
                                  (elmo-delete-char
@@ -1662,7 +1676,7 @@ If ARG is non-nil, checking is omitted."
            (delete-region (match-beginning 2) (match-end 2))
            (goto-char (match-beginning 2))
            (insert new-mark)
-           (elmo-file-cache-delete 
+           (elmo-file-cache-delete
             (elmo-file-cache-get-path
              (elmo-message-field wl-summary-buffer-elmo-folder
                                  number
@@ -1699,7 +1713,7 @@ If ARG is non-nil, checking is omitted."
        (if (elmo-file-cache-exists-p msgid)
            (if (or
                 (string= mark wl-summary-unread-uncached-mark) ; U -> !
-                (string= mark wl-summary-new-mark)             ; N -> !
+                (string= mark wl-summary-new-mark)             ; N -> !
                 )
                (setq set-mark wl-summary-unread-cached-mark)
              (if (string= mark wl-summary-read-uncached-mark)  ; u -> ' '
@@ -1766,7 +1780,7 @@ If ARG is non-nil, checking is omitted."
       (while mark-alist
        (setq entity (car mark-alist))
        (if (setq msg-num (car (rassoc (car entity) number-alist)))
-           (progn 
+           (progn
 ;;;          (goto-char (point-min))
              (if (re-search-forward (format "^ *%s \\( \\)" msg-num) nil t)
                  (progn
@@ -1953,7 +1967,7 @@ If ARG is non-nil, checking is omitted."
                               wl-summary-unread-uncached-mark
                               wl-summary-new-mark)
            mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb))
-            num-ma (length mark-alist)
+           num-ma (length mark-alist)
            importants (elmo-folder-list-importants
                        wl-summary-buffer-elmo-folder
                        wl-summary-important-mark)
@@ -2003,26 +2017,6 @@ If ARG is non-nil, checking is omitted."
        (setq diffs (cdr diffs)))
       (if (interactive-p) (message mes)))))
 
-(defun wl-summary-confirm-appends (appends)
-  (let ((len (length appends))
-       in)
-    (if (> len wl-summary-update-confirm-threshold)
-       (if (y-or-n-p (format "Too many messages(%d).  Continue? " len))
-           appends
-         (setq in wl-summary-update-confirm-threshold)
-         (catch 'end
-           (while t
-             (setq in (read-from-minibuffer "Update number: "
-                                            (int-to-string in))
-                   in (string-to-int in))
-             (if (< len in)
-                 (throw 'end len))
-             (if (y-or-n-p (format "%d messages are disappeared.  OK? "
-                                   (max (- len in) 0)))
-                 (throw 'end in))))
-         (nthcdr (max (- len in) 0) appends))
-      appends)))
-
 (defun wl-summary-sync-update (&optional unset-cursor sync-all no-check)
   "Update the summary view to the newest folder status."
   (interactive)
@@ -2031,9 +2025,8 @@ If ARG is non-nil, checking is omitted."
         (elmo-mime-charset wl-summary-buffer-mime-charset)
         (inhibit-read-only t)
         (buffer-read-only nil)
-        (elmo-folder-update-threshold wl-summary-update-confirm-threshold)
         gc-message
-        overview number-alist mark-alist 
+        overview number-alist mark-alist
         curp num i new-msgdb
         append-list delete-list crossed
         update-thread update-top-list
@@ -2142,7 +2135,7 @@ If ARG is non-nil, checking is omitted."
                (if elmo-use-database
                    (elmo-database-close))
                (run-hooks 'wl-summary-sync-updated-hook)
-               (setq mes 
+               (setq mes
                      (if (and (eq (length delete-list) 0)
                               (eq num 0))
                          (format
@@ -2202,7 +2195,7 @@ If ARG is non-nil, checking is omitted."
       (wl-delete-all-overlays)
       (set-buffer-modified-p nil)
       (if mes (message "%s" mes)))))
-  
+
 (defun wl-summary-set-score-mark (mark)
   (save-excursion
     (beginning-of-line)
@@ -2595,7 +2588,7 @@ If ARG, without confirm."
          (set-buffer-modified-p nil)
          (goto-char (point-min))
          (if (wl-summary-cursor-down t)
-             (let ((unreadp (wl-summary-next-message 
+             (let ((unreadp (wl-summary-next-message
                              (wl-summary-message-number)
                              'down t)))
                (cond ((and wl-auto-select-first
@@ -2796,7 +2789,7 @@ If ARG, without confirm."
                     ;; Is founded entity myself or children?
                     (not (string=
                           (elmo-msgdb-overview-entity-get-id entity)
-                          (elmo-msgdb-overview-entity-get-id 
+                          (elmo-msgdb-overview-entity-get-id
                            (car found-entity))))
                     (with-current-buffer summary-buf
                       (not (wl-thread-descendant-p
@@ -3005,8 +2998,8 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
   (save-excursion
     (let ((inhibit-read-only t)
          (buffer-read-only nil)
-          (buf (current-buffer))
-          sol eol rs re)
+         (buf (current-buffer))
+         sol eol rs re)
       (beginning-of-line)
       (setq sol (point))
       (end-of-line)
@@ -3217,7 +3210,7 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
        (setq fld default))
     (setq fld (elmo-string (wl-folder-get-realname fld)))
     (if (string-match "\n" fld)
-       (error "Not supported folder name: %s" fld))    
+       (error "Not supported folder name: %s" fld))
     (unless no-create
       (if ignore-error
          (condition-case nil
@@ -3793,8 +3786,8 @@ If ARG, exit virtual folder."
              (delq (car mlist) wl-summary-buffer-target-mark-list))
        (setq mlist (cdr mlist))))))
 
-(defun wl-summary-target-mark-prefetch ()
-  (interactive)
+(defun wl-summary-target-mark-prefetch (&optional ignore-cache)
+  (interactive "P")
   (save-excursion
     (let* ((mlist (nreverse wl-summary-buffer-target-mark-list))
           (inhibit-read-only t)
@@ -3805,7 +3798,7 @@ If ARG, exit virtual folder."
           skipped
           new-mark)
       (while mlist
-       (setq new-mark (wl-summary-prefetch-msg (car mlist)))
+       (setq new-mark (wl-summary-prefetch-msg (car mlist) ignore-cache))
        (if new-mark
            (progn
              (message "Prefetching... %d/%d message(s)"
@@ -3973,7 +3966,8 @@ If ARG, exit virtual folder."
   (save-excursion
     (goto-char (point-min))
     (let ((wl-save-dir
-          (wl-read-directory-name "Save to directory: " wl-tmp-dir))
+          (wl-read-directory-name "Save to directory: "
+                                  wl-temporary-file-directory))
          (regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
          number mlist)
       (if (null (file-exists-p wl-save-dir))
@@ -4203,8 +4197,7 @@ If ARG, exit virtual folder."
       (setq linked (wl-thread-entity-get-linked thr-entity)))
     (if (string= thr-str "")
        (setq no-parent t)) ; no parent
-    (if (and wl-summary-width
-            wl-summary-indent-length-limit
+    (if (and wl-summary-indent-length-limit
             (< wl-summary-indent-length-limit
                (string-width thr-str)))
        (setq thr-str (wl-set-string-width
@@ -4213,8 +4206,8 @@ If ARG, exit virtual folder."
     (setq from
          (wl-set-string-width
           (if children-num
-              (- wl-from-width (length children-num) 2)
-            wl-from-width)
+              (- wl-summary-from-width (length children-num) 2)
+            wl-summary-from-width)
           (elmo-delete-char ?\n
                             (wl-summary-from-func-internal
                              (elmo-msgdb-overview-entity-get-from entity)))))
@@ -4256,8 +4249,8 @@ If ARG, exit virtual folder."
                                         subject parent-subject)))
                               (wl-summary-subject-func-internal subject) ""))
                     (if (and (not wl-summary-width)
-                             wl-subject-length-limit)
-                        (truncate-string subject wl-subject-length-limit)
+                             wl-summary-subject-length-limit)
+                        (truncate-string subject wl-summary-subject-length-limit)
                       subject)))))
     (if wl-summary-width (setq line
                               (wl-set-string-width
@@ -4317,7 +4310,7 @@ If ARG, exit virtual folder."
 (defsubst wl-summary-next-message (num direction hereto)
   (if wl-summary-buffer-next-message-function
       (funcall wl-summary-buffer-next-message-function num direction hereto)
-    (let ((cur-spec (cdr (assq wl-summary-move-order 
+    (let ((cur-spec (cdr (assq wl-summary-move-order
                               (if (elmo-folder-plugged-p
                                    wl-summary-buffer-elmo-folder)
                                   wl-summary-move-spec-plugged-alist
@@ -4350,7 +4343,7 @@ If ARG, exit virtual folder."
                           (setq nums (cdr nums))))))
              (setq cur-spec (cdr cur-spec))))
        (car nums)))))
-  
+
 (defsubst wl-summary-cursor-move (direction hereto)
   (when (and (eq direction 'up)
             (eobp))
@@ -4493,8 +4486,7 @@ If ARG, exit virtual folder."
            (when mes-win
              (wl-message-select-buffer wl-message-buffer)
              (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
-             (select-window (get-buffer-window cur-buf)))
-           )
+             (select-window (get-buffer-window cur-buf))))
        ;; hide message window
        (let ((wl-stay-folder-window t)
              (mes-win (and wl-message-buffer
@@ -4518,8 +4510,7 @@ If ARG, exit virtual folder."
          (when mes-win
            (wl-message-select-buffer wl-message-buffer)
            (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
-           (select-window (get-buffer-window cur-buf))))
-       ))))
+           (select-window (get-buffer-window cur-buf))))))))
   (run-hooks 'wl-summary-toggle-disp-folder-hook))
 
 (defun wl-summary-toggle-disp-msg (&optional arg)
@@ -4546,7 +4537,7 @@ If ARG, exit virtual folder."
          (delete-window)
          (and (get-buffer-window cur-buf)
               (select-window (get-buffer-window cur-buf))))
-        (run-hooks 'wl-summary-toggle-disp-off-hook)))
+       (run-hooks 'wl-summary-toggle-disp-off-hook)))
      (t
       (if (and wl-message-buffer
               (get-buffer-window wl-message-buffer)) ; already displayed
@@ -4898,7 +4889,8 @@ Reply to author if invoked with ARG."
   "Write a new draft from Summary."
   (interactive)
   (wl-draft nil nil nil nil nil
-           nil nil nil nil nil nil (current-buffer))
+           nil nil nil nil nil nil (current-buffer)
+           nil (wl-summary-buffer-folder-name))
   (run-hooks 'wl-mail-setup-hook)
   (mail-position-on-field "To"))
 
@@ -4907,31 +4899,37 @@ Reply to author if invoked with ARG."
     wl-folder-guess-mailing-list-by-refile-rule
     wl-folder-guess-mailing-list-by-folder-name)
   "Newsgroups or Mailing List address guess functions list.
-Call from `wl-summary-write-current-folder'")
+Call from `wl-summary-write-current-folder'.
+When guess function return nil, challenge next guess-function.")
 
 (defun wl-summary-write-current-folder (&optional folder)
   "Write message to current FOLDER's newsgroup or mailing-list.
 Use function list is `wl-summary-write-current-folder-functions'."
   (interactive)
-  (let (newsgroups to cc)
-    ;; default FOLDER is current buffer folder
-    (setq folder (or folder (wl-summary-buffer-folder-name)))
-    (let ((flist wl-summary-write-current-folder-functions)
-         guess-list)
-      (while flist
-       (setq guess-list (funcall (car flist) folder))
-       (if (or (nth 0 guess-list)      ; To:
-;;;            (nth 1 guess-list)      ; Cc:
-               (nth 2 guess-list))     ; Newsgroups:
-           (setq flist nil)
-         (setq flist (cdr flist))))
-      (when (null guess-list)
-       (error "Can't guess by folder %s" folder))
-      (wl-draft (nth 0 guess-list) nil nil ; To:
-               (nth 1 guess-list) nil  ; Cc:
-               (nth 2 guess-list))     ; Newsgroups:
-      (run-hooks 'wl-mail-setup-hook)
-      (mail-position-on-field "Subject"))))
+  ;; default FOLDER is current buffer folder
+  (setq folder (or folder (wl-summary-buffer-folder-name)))
+  (let ((func-list wl-summary-write-current-folder-functions)
+       guess-list guess-func)
+    (while func-list
+      (setq guess-list (funcall (car func-list) folder))
+      (if (null guess-list)
+         (setq func-list (cdr func-list))
+       (setq guess-func (car func-list))
+       (setq func-list nil)))
+    (when (null guess-func)
+      (error "Can't guess by folder %s" folder))
+    (unless (or (stringp (nth 0 guess-list))
+               (stringp (nth 1 guess-list))
+               (stringp (nth 2 guess-list)))
+      (error "Invalid value return guess function `%s'"
+            (symbol-name guess-func)))
+    (wl-draft (nth 0 guess-list) nil nil ; To:
+             (nth 1 guess-list) nil    ; Cc:
+             (nth 2 guess-list)        ; Newsgroups:
+             nil nil nil nil nil nil nil
+             folder)
+    (run-hooks 'wl-mail-setup-hook)
+    (mail-position-on-field "Subject")))
 
 (defun wl-summary-forward (&optional without-setup-hook)
   ""
@@ -4961,7 +4959,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
       (if summary-buf
          (save-excursion
            (set-buffer summary-buf)
-           (setq subject 
+           (setq subject
                  (or (elmo-message-field folder number 'subject) ""))))
       (set-buffer mes-buf)
       (wl-draft-forward subject summary-buf)
@@ -5189,7 +5187,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
                   (setq fld-buf (get-buffer wl-folder-buffer-name)))
              (if (setq fld-win (get-buffer-window fld-buf))
                  (delete-window fld-win)))
-          (setq wl-current-summary-buffer (current-buffer))
+         (setq wl-current-summary-buffer (current-buffer))
          (wl-summary-mark-as-read
           nil
           ;; not fetched, then change server-mark.
@@ -5214,7 +5212,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (setq wl-summary-buffer-current-msg num)
          (when wl-summary-recenter
            (recenter (/ (- (window-height) 2) 2))
-           (if (not wl-summary-width)
+           (if (not wl-summary-indent-length-limit)
                (wl-horizontal-recenter)))
          (wl-highlight-summary-displaying)
          (wl-message-buffer-prefetch-next folder num (current-buffer)
@@ -5240,7 +5238,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (setq wl-summary-buffer-current-msg num)
          (when wl-summary-recenter
            (recenter (/ (- (window-height) 2) 2))
-           (if (not wl-summary-width)
+           (if (not wl-summary-indent-length-limit)
                (wl-horizontal-recenter)))
          (wl-highlight-summary-displaying)
          (run-hooks 'wl-summary-redisplay-hook))
@@ -5267,7 +5265,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (setq wl-summary-buffer-current-msg num)
          (when wl-summary-recenter
            (recenter (/ (- (window-height) 2) 2))
-           (if (not wl-summary-width)
+           (if (not wl-summary-indent-length-limit)
                (wl-horizontal-recenter)))
          (wl-highlight-summary-displaying)
          (run-hooks 'wl-summary-redisplay-hook))
@@ -5337,7 +5335,6 @@ Use function list is `wl-summary-write-current-folder-functions'."
   "Supersede current message."
   (interactive)
   (let ((summary-buf (current-buffer))
-       (mmelmo-force-fetch-entire-message t)
        message-buf from)
     (wl-summary-set-message-buffer-or-redisplay)
     (if (setq message-buf (wl-message-get-original-buffer))
@@ -5371,10 +5368,9 @@ Use function list is `wl-summary-write-current-folder-functions'."
 (defun wl-summary-save (&optional arg wl-save-dir)
   (interactive)
   (let ((filename)
-       (num (wl-summary-message-number))
-       (mmelmo-force-fetch-entire-message t))
+       (num (wl-summary-message-number)))
     (if (null wl-save-dir)
-       (setq wl-save-dir wl-tmp-dir))
+       (setq wl-save-dir wl-temporary-file-directory))
     (if num
        (save-excursion
          (setq filename (expand-file-name
@@ -5401,7 +5397,8 @@ Use function list is `wl-summary-write-current-folder-functions'."
       (narrow-to-region beg end)
       (goto-char (point-min))
       (let ((wl-save-dir
-            (wl-read-directory-name "Save to directory: " wl-tmp-dir)))
+            (wl-read-directory-name "Save to directory: "
+                                    wl-temporary-file-directory)))
        (if (null (file-exists-p wl-save-dir))
            (make-directory wl-save-dir))
        (if (eq wl-summary-buffer-view 'thread)
@@ -5558,15 +5555,15 @@ Use function list is `wl-summary-write-current-folder-functions'."
       (set-buffer tmp-buf)
       (message "Exec %s..." wl-prog-uudecode)
       (unwind-protect
-         (let ((decode-dir wl-tmp-dir))
+         (let ((decode-dir wl-temporary-file-directory))
            (if (not wl-prog-uudecode-no-stdout-option)
                (setq filename (read-file-name "Save to file: "
                                               (expand-file-name
                                                (elmo-safe-filename filename)
-                                               wl-tmp-dir)))
+                                               wl-temporary-file-directory)))
              (setq decode-dir
                    (wl-read-directory-name "Save to directory: "
-                                           wl-tmp-dir))
+                                           wl-temporary-file-directory))
              (setq filename (expand-file-name filename decode-dir)))
            (if (file-exists-p filename)
                (or (yes-or-no-p (format "File %s exists. Save anyway? "