| 1 |
;;; mew-summary4.el --- Summary mode for Mew |
| 2 |
|
| 3 |
;; Author: Kazu Yamamoto <[email protected]> |
| 4 |
;; Created: Oct 2, 1996 |
| 5 |
|
| 6 |
;;; Code: |
| 7 |
|
| 8 |
(require 'mew) |
| 9 |
(eval-when-compile |
| 10 |
(require 'mew-env0)) |
| 11 |
|
| 12 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 13 |
;;; |
| 14 |
;;; Variables |
| 15 |
;;; |
| 16 |
|
| 17 |
(defvar mew-last-shell-command "") |
| 18 |
|
| 19 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 20 |
;;; |
| 21 |
;;; Switching to folder |
| 22 |
;;; |
| 23 |
|
| 24 |
(defun mew-summary-switch-to-folder (case:folder &optional func) |
| 25 |
(let ((ofolder (mew-summary-folder-name 'ext))) |
| 26 |
(cond |
| 27 |
((get-buffer case:folder) |
| 28 |
(switch-to-buffer case:folder) |
| 29 |
(mew-set-buffer-cs mew-cs-m17n) |
| 30 |
(unless (mew-folder-virtualp case:folder) (mew-summary-folder-cache-load)) |
| 31 |
(unless (string= ofolder case:folder) (mew-window-configure 'summary)) |
| 32 |
nil) ;; existing folder |
| 33 |
(t |
| 34 |
(funcall (or func 'switch-to-buffer) (get-buffer-create case:folder)) |
| 35 |
(kill-all-local-variables) |
| 36 |
(mew-set-buffer-cs mew-cs-m17n) |
| 37 |
(mew-buffers-setup case:folder) |
| 38 |
(let* ((case (mew-case:folder-case case:folder)) |
| 39 |
(folder (mew-case:folder-folder case:folder)) |
| 40 |
(inboxp (string= folder (mew-proto-inbox-folder folder (or case mew-case))))) |
| 41 |
(mew-sinfo-set-case case) |
| 42 |
(mew-sinfo-set-folder folder) |
| 43 |
(mew-sinfo-set-inboxp inboxp)) |
| 44 |
(if (mew-folder-virtualp case:folder) |
| 45 |
(mew-virtual-mode) |
| 46 |
(mew-summary-mode) |
| 47 |
(if mew-summary-trace-directory (cd (mew-expand-folder case:folder))) |
| 48 |
(mew-summary-folder-cache-load)) |
| 49 |
(mew-window-configure 'summary) |
| 50 |
t)))) ;; new-folder |
| 51 |
|
| 52 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 53 |
;;; |
| 54 |
;;; Moving to folder |
| 55 |
;;; |
| 56 |
|
| 57 |
(defun mew-summary-goto-folder (&optional goend) |
| 58 |
"Go to the folder which you specify. If executed with |
| 59 |
'\\[universal-argument]', the cursor always goes to the bottom of |
| 60 |
Summary mode." |
| 61 |
(interactive "P") |
| 62 |
(let* ((proto (mew-proto-to-go (mew-summary-folder-name 'ext))) |
| 63 |
(case1 (car (mew-summary-case-proto))) |
| 64 |
(inbox (mew-proto-inbox-folder proto case1)) |
| 65 |
(case:folder (mew-input-folder case1 inbox)) |
| 66 |
case folder buf win frame folder-alist) |
| 67 |
(if (null case:folder) |
| 68 |
(message "The folder does not exist") |
| 69 |
(setq case (mew-case:folder-case case:folder)) |
| 70 |
(setq folder (mew-case:folder-folder case:folder)) |
| 71 |
(cond |
| 72 |
((mew-folder-imapp folder) |
| 73 |
(setq folder-alist (mew-imap-folder-alist case)) |
| 74 |
;; |
| 75 |
(unless (or (assoc folder folder-alist) |
| 76 |
(assoc (concat folder (mew-imap-separator case)) folder-alist)) |
| 77 |
(message "\"%s\" does not exist. %s" case:folder |
| 78 |
(mew-substitute-for-summary "Type '\\[universal-argument]\\[mew-status-update]' to collect IMAP folders")) |
| 79 |
(setq case:folder nil))) |
| 80 |
((mew-folder-nntpp folder) |
| 81 |
(unless (assoc folder (mew-nntp-folder-alist case)) |
| 82 |
(message "\"%s\" does not exist. %s" case:folder |
| 83 |
(mew-substitute-for-summary "Type '\\[universal-argument]\\[mew-status-update]' to collect newsgroups")) |
| 84 |
(setq case:folder nil)))) |
| 85 |
(when case:folder |
| 86 |
(when mew-use-other-frame-for-summary |
| 87 |
(if (setq buf (get-buffer case:folder)) |
| 88 |
(if (setq win (get-buffer-window buf 0)) |
| 89 |
(progn |
| 90 |
(setq frame (window-frame win)) |
| 91 |
(raise-frame frame) |
| 92 |
(select-frame frame) |
| 93 |
;; Ensure, if possible, that frame gets input focus. |
| 94 |
(mew-focus-frame frame)) |
| 95 |
(select-frame (make-frame))) |
| 96 |
(select-frame (make-frame)))) |
| 97 |
(mew-summary-visit-folder case:folder goend))))) |
| 98 |
|
| 99 |
(defun mew-summary-visit-folder (folder &optional goend no-ls) |
| 100 |
(let ((dir (mew-expand-folder folder)) |
| 101 |
new-folder scanp) |
| 102 |
(cond |
| 103 |
((mew-folder-virtualp folder) |
| 104 |
(if (get-buffer folder) |
| 105 |
(if (mew-virtual-thread-p folder) |
| 106 |
(if (mew-thread-cache-valid-p folder) |
| 107 |
(mew-summary-switch-to-folder folder) |
| 108 |
(message "%s is old" folder)) |
| 109 |
(mew-summary-switch-to-folder folder)) |
| 110 |
(message "No such virtual folder: %s" folder))) |
| 111 |
(t ;; local/remote folders |
| 112 |
(if (null dir) |
| 113 |
(message "Folder is wrong") |
| 114 |
(cond |
| 115 |
((mew-folder-remotep (mew-case:folder-folder folder)) |
| 116 |
(unless (file-directory-p dir) |
| 117 |
(mew-make-directory dir)) |
| 118 |
(setq scanp t)) |
| 119 |
(t ;; +, ~, /, drive letter |
| 120 |
(if (file-directory-p dir) |
| 121 |
(setq scanp t) |
| 122 |
(message "No such folder %s" folder)))) |
| 123 |
(when scanp |
| 124 |
(if no-ls |
| 125 |
(progn |
| 126 |
(mew-summary-switch-to-folder folder) |
| 127 |
(if goend (goto-char (point-max))) |
| 128 |
(if (pos-visible-in-window-p (point-min)) |
| 129 |
(mew-summary-cook-window))) |
| 130 |
(setq new-folder (mew-summary-switch-to-folder folder)) |
| 131 |
(if (and (mew-summary-ls nil (or goend new-folder)) |
| 132 |
(pos-visible-in-window-p (point-min))) |
| 133 |
(mew-summary-cook-window))))))))) |
| 134 |
|
| 135 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 136 |
;;; |
| 137 |
;;; Going to a line |
| 138 |
;;; |
| 139 |
|
| 140 |
(defun mew-summary-goto-line (&optional arg) |
| 141 |
"Jump to a line according to the number which you input. |
| 142 |
If 'mew-summary-goto-line-then-display' is non-nil, |
| 143 |
the message is then displayed." |
| 144 |
(interactive "P") |
| 145 |
(if arg |
| 146 |
(let ((msg (read-string "Message No.: " ""))) |
| 147 |
(while (not (string-match mew-regex-message-files3 msg)) |
| 148 |
(setq msg (read-string "Message No.: " ""))) |
| 149 |
(when (mew-summary-search-msg msg) |
| 150 |
(if mew-summary-goto-line-then-display |
| 151 |
(mew-summary-display)))) |
| 152 |
(let ((line (string-to-number (read-string "Line No.: " "")))) |
| 153 |
(when (/= line 0) |
| 154 |
(goto-char (point-min)) (forward-line (1- line)) |
| 155 |
(if mew-summary-goto-line-then-display |
| 156 |
(mew-summary-display)))))) |
| 157 |
|
| 158 |
(defun mew-summary-goto-original-message () |
| 159 |
"Go to the original message in the original Summary mode" |
| 160 |
(interactive) |
| 161 |
(cond |
| 162 |
((mew-summary-p) |
| 163 |
(message "This is the original")) |
| 164 |
((mew-virtual-p) |
| 165 |
(let ((folder (mew-folder-path-to-folder (mew-summary-folder-name) 'has-proto)) |
| 166 |
(msg (mew-summary-message-number))) |
| 167 |
(when folder |
| 168 |
(mew-summary-visit-folder folder nil 'no-ls) |
| 169 |
(if (mew-summary-search-msg msg) |
| 170 |
(mew-summary-display) |
| 171 |
(message "No original message found"))))))) |
| 172 |
|
| 173 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 174 |
;;; |
| 175 |
;;; Moving to Message mode |
| 176 |
;;; |
| 177 |
|
| 178 |
(defun mew-summary-goto-msg-mode () |
| 179 |
"Go to Header mode." |
| 180 |
(interactive) |
| 181 |
(let (msgp) |
| 182 |
(with-current-buffer (window-buffer (next-window)) |
| 183 |
(if (mew-message-p) (setq msgp t))) |
| 184 |
(if msgp |
| 185 |
(other-window 1) |
| 186 |
(message "No Message mode displayed")))) |
| 187 |
|
| 188 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 189 |
;;; |
| 190 |
;;; Moving to +draft |
| 191 |
;;; |
| 192 |
|
| 193 |
(defun mew-max-draft-buffer () |
| 194 |
(let* ((draft-dir (file-name-as-directory mew-draft-folder)) |
| 195 |
(regex (mew-folder-regex draft-dir)) |
| 196 |
(bufs (mew-buffer-list regex)) |
| 197 |
(msgregex (format "\\([0-9]+\\)\\(%s\\)?$" mew-suffix)) |
| 198 |
nums n) |
| 199 |
(setq nums (mapcar (lambda (x) (string-match msgregex x) (string-to-number (mew-match-string 1 x))) bufs)) |
| 200 |
(dolist (num nums) |
| 201 |
(if (or (null n) (< n num)) |
| 202 |
(setq n num))) |
| 203 |
(and n (format "%s%d%s" draft-dir n (if mew-use-suffix mew-suffix ""))))) |
| 204 |
|
| 205 |
(defun mew-summary-jump-to-draft-buffer () |
| 206 |
"Jump to one of drafts if exists." |
| 207 |
(interactive) |
| 208 |
(let* ((draft (mew-max-draft-buffer)) buf) |
| 209 |
(if (null draft) |
| 210 |
(message "No draft buffer exists!") |
| 211 |
(setq buf (mew-input-draft-buffer draft)) |
| 212 |
(if (get-buffer buf) |
| 213 |
(switch-to-buffer buf) |
| 214 |
(message "No such draft buffer!"))))) |
| 215 |
|
| 216 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 217 |
;;; |
| 218 |
;;; Moving to top and bottom |
| 219 |
;;; |
| 220 |
|
| 221 |
(defun mew-summary-jump-top () |
| 222 |
"Go to the beginning of this Summary mode. |
| 223 |
If 'mew-summary-jump-top-then-display' is non-nil, |
| 224 |
the top message is then displayed." |
| 225 |
(interactive) |
| 226 |
(if mew-use-push-mark (mew-push-mark)) |
| 227 |
(goto-char (point-min)) |
| 228 |
(if mew-summary-jump-top-then-display |
| 229 |
(mew-summary-display))) |
| 230 |
|
| 231 |
(defun mew-summary-jump-bottom () |
| 232 |
"Go to the end of this Summary mode. |
| 233 |
If 'mew-summary-jump-bottom-then-display' is non-nil, |
| 234 |
the top message is then displayed." |
| 235 |
(interactive) |
| 236 |
(if mew-use-push-mark (mew-push-mark)) |
| 237 |
(goto-char (point-max)) |
| 238 |
(if (and (mew-summary-exclusive-p 'no-msg) |
| 239 |
(not (bobp)) |
| 240 |
(mew-sinfo-get-disp-msg)) |
| 241 |
(forward-line -1)) |
| 242 |
(if mew-summary-jump-bottom-then-display |
| 243 |
(mew-summary-display))) |
| 244 |
|
| 245 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 246 |
;;; |
| 247 |
;;; Moving to the marker |
| 248 |
;;; |
| 249 |
|
| 250 |
(defun mew-summary-exchange-point () |
| 251 |
"\\<mew-summary-mode-map>Get back to the position before typing '\\[mew-summary-retrieve]' or '\\[mew-summary-ls]'." |
| 252 |
(interactive) |
| 253 |
(mew-summary-only |
| 254 |
(let ((pos (mew-sinfo-get-ret-pos))) |
| 255 |
(if pos (goto-char pos))))) |
| 256 |
|
| 257 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 258 |
;;; |
| 259 |
;;; Searching |
| 260 |
;;; |
| 261 |
|
| 262 |
(defun mew-summary-isearch-forward (&optional arg) |
| 263 |
"Incremental search forward in Message mode." |
| 264 |
(interactive "P") |
| 265 |
(let ((cwin (get-buffer-window (current-buffer))) |
| 266 |
(mwin (get-buffer-window (mew-buffer-message)))) |
| 267 |
(if (not mwin) |
| 268 |
(message "No message is displayed") |
| 269 |
(select-window mwin) |
| 270 |
(unwind-protect |
| 271 |
(progn |
| 272 |
(widen) |
| 273 |
(isearch-forward arg) |
| 274 |
(mew-message-narrow-to-page)) |
| 275 |
(select-window cwin))))) |
| 276 |
|
| 277 |
(defun mew-summary-isearch-backward (&optional arg) |
| 278 |
"Incremental search backward in Message mode." |
| 279 |
(interactive) |
| 280 |
(let ((cwin (get-buffer-window (current-buffer))) |
| 281 |
(mwin (get-buffer-window (mew-buffer-message)))) |
| 282 |
(if (not mwin) |
| 283 |
(message "No message is displayed") |
| 284 |
(select-window mwin) |
| 285 |
(unwind-protect |
| 286 |
(progn |
| 287 |
(widen) |
| 288 |
(isearch-backward arg) |
| 289 |
(mew-message-narrow-to-page)) |
| 290 |
(select-window cwin))))) |
| 291 |
|
| 292 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 293 |
;;; |
| 294 |
;;; Pipe |
| 295 |
;;; |
| 296 |
|
| 297 |
(defun mew-summary-pipe-message (prefix command) |
| 298 |
"Send the content of Message buffer to a command via pipe. |
| 299 |
If called with '\\[universal-argument]', the body of the message |
| 300 |
\(excluding its header) is sent." |
| 301 |
(interactive |
| 302 |
(list current-prefix-arg |
| 303 |
(read-string "Shell command on message: " mew-last-shell-command))) |
| 304 |
(mew-summary-display 'redisplay) |
| 305 |
(when (or (not mew-ask-pipe) |
| 306 |
(y-or-n-p "Send this message to pipe? ")) |
| 307 |
(with-current-buffer (mew-buffer-message) |
| 308 |
(save-restriction |
| 309 |
(widen) |
| 310 |
(if (string= command "") (setq command mew-last-shell-command)) |
| 311 |
(goto-char (point-min)) ; perhaps this line won't be necessary |
| 312 |
(if prefix (search-forward "\n\n")) |
| 313 |
(let ((max-mini-window-height 1)) |
| 314 |
(shell-command-on-region (point) (point-max) command nil)) |
| 315 |
(setq mew-last-shell-command command))))) |
| 316 |
|
| 317 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 318 |
;;; |
| 319 |
;;; Print |
| 320 |
;;; |
| 321 |
|
| 322 |
(defun mew-summary-print (&optional arg) |
| 323 |
"Print the content of Message mode according to 'mew-print-function'. |
| 324 |
If called with '\\[universal-argument]', you can specify a printer name." |
| 325 |
(interactive "P") |
| 326 |
(mew-summary-display 'redisplay) |
| 327 |
(let ((printer-name (if arg |
| 328 |
(read-string "Printer name: ") |
| 329 |
printer-name)) |
| 330 |
have-header str) |
| 331 |
(with-current-buffer (mew-buffer-message) |
| 332 |
(save-restriction |
| 333 |
(widen) |
| 334 |
(setq have-header (mew-msghdr-p)) |
| 335 |
(setq str (buffer-substring (point-min) (point-max))))) |
| 336 |
(when (y-or-n-p "Print this message? ") |
| 337 |
(with-temp-buffer |
| 338 |
(insert str) |
| 339 |
(if have-header |
| 340 |
(mew-header-delete-other-lines mew-field-for-printing)) |
| 341 |
(funcall mew-print-function))))) |
| 342 |
|
| 343 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 344 |
;;; |
| 345 |
;;; Saving a message to a file with header decoded |
| 346 |
;;; |
| 347 |
|
| 348 |
(defun mew-summary-store (&optional askcs) |
| 349 |
"Saving a buffer of Message mode to a file. |
| 350 |
If executed with '\\[universal-argument]', coding-system is asked." |
| 351 |
(interactive "P") |
| 352 |
(mew-summary-display 'redisplay) |
| 353 |
(let* ((file (mew-summary-input-file-name)) |
| 354 |
(doit (if (file-exists-p file) |
| 355 |
(if (y-or-n-p (format "File exists. Override it? ")) |
| 356 |
t |
| 357 |
nil) |
| 358 |
t))) |
| 359 |
(if (not doit) |
| 360 |
(message "Not saved") |
| 361 |
(let ((writecs (if askcs |
| 362 |
(read-coding-system "Coding-system: ") |
| 363 |
(default-value 'buffer-file-coding-system)))) |
| 364 |
(with-current-buffer (mew-buffer-message) |
| 365 |
(mew-frwlet mew-cs-dummy writecs |
| 366 |
;; do not specify 'no-msg |
| 367 |
(write-region (point-min) (point-max) file))))))) |
| 368 |
|
| 369 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 370 |
;;; |
| 371 |
;;; X-Face: |
| 372 |
;;; |
| 373 |
|
| 374 |
(defun mew-summary-x-face () |
| 375 |
"Display xface." |
| 376 |
(interactive) |
| 377 |
(mew-summary-msg |
| 378 |
(let ((file (mew-make-temp-name)) xface) |
| 379 |
(with-current-buffer (mew-buffer-message) |
| 380 |
(setq xface (mew-header-get-value mew-x-face:))) |
| 381 |
(when xface |
| 382 |
(with-temp-buffer |
| 383 |
(insert xface) |
| 384 |
(mew-x-face-compface-to-xbm) |
| 385 |
(mew-frwlet mew-cs-dummy mew-cs-text-for-write |
| 386 |
(write-region (point-min) (point-max) file nil 'no-msg))) |
| 387 |
(mew-mime-image-ext file))))) |
| 388 |
|
| 389 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 390 |
;;; |
| 391 |
;;; Calling a command |
| 392 |
;;; |
| 393 |
|
| 394 |
(defun mew-summary-cmd-msg () |
| 395 |
"Executing an external command specifying this message as an |
| 396 |
argument." |
| 397 |
(interactive) |
| 398 |
(mew-summary-msg-or-part |
| 399 |
(let* ((fld (mew-summary-folder-name)) |
| 400 |
(msg (mew-summary-message-number)) |
| 401 |
(file (mew-expand-msg fld msg)) |
| 402 |
(cmd-args (mew-input-command)) |
| 403 |
(cmd (car cmd-args)) |
| 404 |
(args (nconc (cdr cmd-args) (list file)))) |
| 405 |
(message "Executing %s for %s..." cmd msg) |
| 406 |
(apply 'call-process cmd nil nil nil args) |
| 407 |
(message "Executing %s for %s...done" cmd msg)))) |
| 408 |
|
| 409 |
(defun mew-summary-cmd-msgs () |
| 410 |
"Executing an external command specifying messages |
| 411 |
marked with '*' as arguments." |
| 412 |
(interactive) |
| 413 |
(mew-summary-multi-msgs |
| 414 |
(let* ((cmd-args (mew-input-command)) |
| 415 |
(cmd (car cmd-args)) |
| 416 |
(args (nconc (cdr cmd-args) FILES))) |
| 417 |
(message "Executing %s ..." cmd) |
| 418 |
(apply 'call-process cmd nil nil nil args) |
| 419 |
(message "Executing %s ...done" cmd)))) |
| 420 |
|
| 421 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 422 |
;;; |
| 423 |
;;; Citation |
| 424 |
;;; |
| 425 |
|
| 426 |
(defun mew-summary-cite (&optional arg) |
| 427 |
"Cite this message to one of drafts." |
| 428 |
(interactive "P") |
| 429 |
(let ((draft (mew-max-draft-buffer)) buf) |
| 430 |
(if (null draft) |
| 431 |
(message "No draft buffer exists!") |
| 432 |
(setq buf (mew-input-draft-buffer draft)) |
| 433 |
(if (get-buffer buf) |
| 434 |
(with-current-buffer buf |
| 435 |
(mew-draft-cite arg)) |
| 436 |
(message "No such draft buffer!"))))) |
| 437 |
|
| 438 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 439 |
;;; |
| 440 |
;;; Flushing the queue |
| 441 |
;;; |
| 442 |
|
| 443 |
(defun mew-summary-send-message (&optional arg) |
| 444 |
"If in +queue, send the messages in +queue. |
| 445 |
If in +postq, post the messages in +postq. |
| 446 |
If in %queue, process the jobs in %queue. |
| 447 |
Otherwise, flush the default queue. |
| 448 |
If executed with '\\[universal-argument]', you can set the sending case." |
| 449 |
(interactive "P") |
| 450 |
(if (mew-folder-imap-queuep) |
| 451 |
(progn |
| 452 |
(mew-window-configure 'summary) |
| 453 |
(mew-imap-flush-queue)) |
| 454 |
(let* ((fld (mew-summary-folder-name 'ext)) |
| 455 |
(proto (mew-proto-to-flush fld)) |
| 456 |
qfld case) |
| 457 |
(if (or arg mew-ask-flush-case) |
| 458 |
(setq case (mew-input-case mew-case "Queue")) |
| 459 |
(setq case mew-case)) |
| 460 |
(if (or (mew-folder-queuep fld) (mew-folder-postqp fld)) |
| 461 |
(progn |
| 462 |
(setq qfld fld) |
| 463 |
(mew-window-configure 'summary)) |
| 464 |
(setq qfld (mew-proto-queue-folder proto case))) |
| 465 |
(if (and mew-ask-flush-queue |
| 466 |
(not (y-or-n-p (concat "Flush " qfld "? ")))) |
| 467 |
(message "The queue is not flushed") |
| 468 |
(cond |
| 469 |
((mew-folder-postqp qfld) |
| 470 |
(mew-nntp2-flush-queue case qfld)) |
| 471 |
(t |
| 472 |
(mew-smtp-flush-queue case qfld))))))) |
| 473 |
|
| 474 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 475 |
;;; |
| 476 |
;;; Unlocking |
| 477 |
;;; |
| 478 |
|
| 479 |
(defun mew-subprocess-init () |
| 480 |
(add-hook 'kill-emacs-hook 'mew-subprocess-kill)) |
| 481 |
|
| 482 |
(defun mew-subprocess-clean-up () |
| 483 |
(mew-summary-kill-subprocess t) |
| 484 |
(remove-hook 'kill-emacs-hook 'mew-subprocess-kil)) |
| 485 |
|
| 486 |
(defun mew-subprocess-kill () |
| 487 |
(mew-summary-kill-subprocess t)) |
| 488 |
|
| 489 |
(defun mew-summary-kill-subprocess (&optional kill-ssx) |
| 490 |
"\\<mew-summary-mode-map> |
| 491 |
Kill a process in Summary mode. |
| 492 |
Sometime a process accidentally remains in Summary mode. |
| 493 |
In this situation, you cannot execute '\\[mew-summary-retrieve]', '\\[mew-summary-ls]', nor '\\[mew-summary-exec]'. |
| 494 |
Use this command to solve this problem. |
| 495 |
|
| 496 |
If called with '\\[universal-argument]', all SSH processes, if |
| 497 |
any, are killed." |
| 498 |
(interactive "P") |
| 499 |
(let ((process mew-summary-buffer-process) |
| 500 |
(disp-msg (mew-called-interactively-p)) |
| 501 |
pros sentinel) |
| 502 |
(if kill-ssx |
| 503 |
(progn |
| 504 |
(setq pros (process-list)) |
| 505 |
(dolist (pro pros) |
| 506 |
(if (string-match "mew" (process-name pro)) |
| 507 |
(delete-process pro))) |
| 508 |
(if disp-msg (message "All SSH/SSL/TLS processes were killed"))) |
| 509 |
(cond |
| 510 |
((not (processp process)) |
| 511 |
;; If you type "x" over SSH and type "C-g" to quit, |
| 512 |
;; refile information remains invisible. |
| 513 |
;; This command turns it visible. |
| 514 |
(mew-summary-visible-buffer (current-buffer)) |
| 515 |
(if disp-msg (message "No process to kill. This buffer is unlocked anyway"))) |
| 516 |
((eq process t) |
| 517 |
;; Emacs is locking |
| 518 |
(if disp-msg (message "This buffer was unlocked"))) |
| 519 |
((memq (process-status process) '(open closed)) |
| 520 |
;; Network process |
| 521 |
(setq sentinel (process-sentinel process)) |
| 522 |
(if (fboundp sentinel) |
| 523 |
(funcall sentinel process "killed by the user")) |
| 524 |
(delete-process process) |
| 525 |
(if disp-msg (message "The process was killed"))) |
| 526 |
(t |
| 527 |
;; Local process or SSH/SSL/TLS |
| 528 |
(delete-process process) |
| 529 |
(if disp-msg (message "The process was killed"))))) |
| 530 |
(mew-summary-unlock))) |
| 531 |
|
| 532 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 533 |
;;; |
| 534 |
;;; De-composing with the old style |
| 535 |
;;; |
| 536 |
|
| 537 |
(defun mew-summary-unshar () |
| 538 |
"Apply 'unshar' on messages marked with '*'." |
| 539 |
(interactive) |
| 540 |
(mew-summary-multi-msgs |
| 541 |
(if (y-or-n-p (format "Execute %s for these messages? " mew-prog-unshar)) |
| 542 |
(let* ((default-directory (mew-summary-input-directory-name))) |
| 543 |
(message "Executing %s..." mew-prog-unshar) |
| 544 |
(apply 'call-process mew-prog-unshar nil nil nil FILES) |
| 545 |
(message "Executing %s...done" mew-prog-unshar))))) |
| 546 |
|
| 547 |
(defun mew-summary-uudecode () |
| 548 |
"Apply 'uudecode' on messages marked with '*'." |
| 549 |
(interactive) |
| 550 |
(mew-summary-multi-msgs |
| 551 |
(cond |
| 552 |
((not (mew-which-exec mew-prog-mime-decode)) |
| 553 |
()) |
| 554 |
((not (y-or-n-p "Uudecode these messages? ")) |
| 555 |
()) |
| 556 |
(t |
| 557 |
(let ((dir (mew-summary-input-directory-name)) |
| 558 |
(fn nil) |
| 559 |
(tmp (mew-make-temp-name)) |
| 560 |
(case-fold-search nil) |
| 561 |
(files FILES) start) |
| 562 |
(with-temp-buffer |
| 563 |
(mew-frwlet mew-cs-text-for-read mew-cs-text-for-write |
| 564 |
(dolist (file files) |
| 565 |
(mew-erase-buffer) |
| 566 |
(mew-insert-file-contents file) |
| 567 |
(goto-char (point-min)) |
| 568 |
(if (re-search-forward mew-eoh nil t) |
| 569 |
(forward-line)) |
| 570 |
(setq start (point)) |
| 571 |
(goto-char (point-max)) |
| 572 |
(unless (bolp) (insert "\n")) |
| 573 |
(write-region start (point-max) tmp 'append 'no-msg))) |
| 574 |
(mew-erase-buffer) |
| 575 |
(cd dir) |
| 576 |
;; mew-folder-local is dummy to let mewencode use |
| 577 |
;; the embedded filename |
| 578 |
(call-process mew-prog-mime-decode tmp t nil |
| 579 |
"-d" "-u" "-" mew-folder-local) |
| 580 |
(mew-delete-file tmp) |
| 581 |
(goto-char (point-min)) |
| 582 |
(if (not (looking-at "^filename: \\(.*\\)")) |
| 583 |
(message "Failed to execute %s" mew-prog-mime-decode) |
| 584 |
(setq fn (mew-match-string 1)) |
| 585 |
(setq fn (mew-summary-prog-exec mew-prog-compress "-df" "Z" fn)) |
| 586 |
(setq fn (mew-summary-prog-exec mew-prog-gzip "-df" "gz" fn)) |
| 587 |
(when (and (string-match "^\\(.*\\)\\.tar$" fn) |
| 588 |
(y-or-n-p (format "Execute %s for %s? " mew-prog-tar fn))) |
| 589 |
(message "Executing %s for %s..." mew-prog-tar fn) |
| 590 |
(call-process mew-prog-tar nil nil nil "-xf" fn) |
| 591 |
(message "Executing %s for %s...done" mew-prog-tar fn))))))))) |
| 592 |
|
| 593 |
(defun mew-summary-prog-exec (prog opts suffix tarfile) |
| 594 |
(if (string-match (format "^\\(.*\\)\\.%s$" suffix) tarfile) |
| 595 |
(let ((basename (match-string 1 tarfile))) |
| 596 |
(if (not (y-or-n-p (format "Execute %s for %s? " prog tarfile))) |
| 597 |
tarfile |
| 598 |
(message "Executing %s for %s..." prog tarfile) |
| 599 |
(call-process prog nil nil nil opts tarfile) |
| 600 |
(message "Executing %s for %s...done" prog tarfile) |
| 601 |
basename)) |
| 602 |
tarfile)) |
| 603 |
|
| 604 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 605 |
;;; |
| 606 |
;;; De-composing with the new style |
| 607 |
;;; |
| 608 |
|
| 609 |
(defun mew-summary-join () |
| 610 |
"Concat Message/Partial fragments marked with '*' to an original |
| 611 |
message." |
| 612 |
(interactive) |
| 613 |
(mew-summary-only |
| 614 |
(mew-summary-with-mewl |
| 615 |
(mew-summary-multi-msgs |
| 616 |
(let ((cfld (mew-summary-folder-name)) |
| 617 |
(folder (mew-input-burst-folder)) |
| 618 |
(tfile (mew-make-temp-name)) |
| 619 |
(targets FLD-MSG-LIST) |
| 620 |
num ct med dbl vec len idx ttl TTL fid FID i |
| 621 |
beg regex) |
| 622 |
(message "Joining...") |
| 623 |
(with-temp-buffer |
| 624 |
(mew-set-buffer-multibyte t) |
| 625 |
(insert "CD: " (mew-expand-folder2 cfld) "\n") |
| 626 |
(let ((default-directory (mew-expand-folder cfld))) |
| 627 |
(dolist (fld-msg targets) |
| 628 |
(insert (mew-msg-get-filename (cdr fld-msg)) "\n"))) |
| 629 |
(mew-frwlet mew-cs-text-for-read mew-cs-text-for-write |
| 630 |
(write-region (point-min) (point-max) tfile nil 'no-msg)) |
| 631 |
(mew-erase-buffer) |
| 632 |
(call-process mew-prog-mewl nil t nil |
| 633 |
"-b" mew-mail-path "-l" "0" |
| 634 |
"-x" mew-suffix |
| 635 |
"-i" tfile "-d" "content-type") |
| 636 |
(mew-delete-file tfile) |
| 637 |
(goto-char (point-min)) |
| 638 |
(while (not (eobp)) |
| 639 |
(if (not (looking-at "^\\([0-9]+\\)[ \t]*:[ \t]*")) |
| 640 |
(forward-line) |
| 641 |
(setq num (mew-match-string 1)) |
| 642 |
(setq med (match-end 0)) |
| 643 |
(forward-line) |
| 644 |
(mew-header-goto-next) |
| 645 |
(setq ct (mew-param-decode |
| 646 |
(mew-buffer-substring med (1- (point))))) |
| 647 |
(setq dbl (cons (cons num ct) dbl)))) |
| 648 |
(setq len (length dbl)) |
| 649 |
(setq vec (make-vector len nil)) |
| 650 |
(dolist (ent dbl) |
| 651 |
(setq num (car ent)) |
| 652 |
(setq ttl (mew-syntax-get-param ent "total")) |
| 653 |
(setq fid (mew-syntax-get-param ent "id")) |
| 654 |
(setq idx (mew-syntax-get-param ent "number")) |
| 655 |
(if TTL |
| 656 |
(if (and ttl (not (string= TTL ttl))) |
| 657 |
(error "total mismatch")) |
| 658 |
(setq TTL ttl)) |
| 659 |
(if FID |
| 660 |
(if (or (null fid) (not (string= FID fid))) |
| 661 |
(error "fragment id mismatch")) |
| 662 |
(setq FID fid)) |
| 663 |
(unless idx (error "no number")) |
| 664 |
(setq idx (1- (string-to-number idx))) |
| 665 |
(if (and (>= idx 0) (< idx len)) |
| 666 |
(aset vec idx num) |
| 667 |
(error "invalid number"))) |
| 668 |
(unless TTL (error "no total")) |
| 669 |
(dotimes (i len) |
| 670 |
(unless (stringp (aref vec i)) (error "Not enough fragments"))) |
| 671 |
;; now reassemble |
| 672 |
(mew-erase-buffer) |
| 673 |
(mew-frwlet mew-cs-text-for-read mew-cs-text-for-write |
| 674 |
;; the first fragment |
| 675 |
(goto-char (point-max)) |
| 676 |
(save-restriction |
| 677 |
(narrow-to-region (point) (point)) |
| 678 |
(mew-insert-file-contents (mew-expand-msg cfld (aref vec 0))) |
| 679 |
;; Removing unnecessary fields from the encapsulating |
| 680 |
;; (outer) header. |
| 681 |
(goto-char (point-min)) |
| 682 |
(mew-header-delete-lines mew-field-delete-for-joining) |
| 683 |
;; Concatenating the two headers. |
| 684 |
(goto-char (point-min)) |
| 685 |
(re-search-forward mew-eoh nil t) |
| 686 |
(setq beg (point)) |
| 687 |
(while (looking-at mew-eoh) |
| 688 |
(forward-line) |
| 689 |
(if (eobp) (error "invalid message (number 1)"))) |
| 690 |
(delete-region beg (point)) |
| 691 |
;; Removing unnecessary fields from the encapsulated |
| 692 |
;; (inner) header. |
| 693 |
(setq beg (point)) |
| 694 |
(when (re-search-forward mew-eoh nil t) |
| 695 |
(setq regex (mew-make-field-regex mew-field-delete-for-joining)) |
| 696 |
(save-restriction |
| 697 |
(narrow-to-region beg (point)) |
| 698 |
(goto-char (point-min)) |
| 699 |
(let ((case-fold-search t)) |
| 700 |
(while (not (eobp)) |
| 701 |
(if (looking-at regex) |
| 702 |
(setq beg nil) ;; logic is reversed |
| 703 |
(setq beg (point))) |
| 704 |
(forward-line) |
| 705 |
(mew-header-goto-next) |
| 706 |
(if beg (delete-region beg (point)))))))) |
| 707 |
;; the second and subsequent fragments. |
| 708 |
(setq i 1) |
| 709 |
(while (< i len) |
| 710 |
(goto-char (point-max)) |
| 711 |
(save-restriction |
| 712 |
(narrow-to-region (point) (point)) |
| 713 |
(mew-insert-file-contents (mew-expand-msg cfld (aref vec i))) |
| 714 |
(goto-char (point-min)) |
| 715 |
(re-search-forward mew-eoh nil t) |
| 716 |
(forward-line) |
| 717 |
(if (eobp) (error "invalid message (number %d)" (1+ i))) |
| 718 |
(delete-region (point-min) (point))) |
| 719 |
(setq i (1+ i))) |
| 720 |
(mew-header-delete-lines `(,mew-x-mew-uidl:)) |
| 721 |
(write-region (point-min) (point-max) |
| 722 |
(mew-folder-new-message folder) |
| 723 |
nil 'no-msg))) |
| 724 |
(mew-touch-folder folder) |
| 725 |
(message "Joining...done") |
| 726 |
(when mew-ask-folder-after-join |
| 727 |
(if (y-or-n-p (format "Go to %s? " folder)) |
| 728 |
(mew-summary-visit-folder folder 'goend)))))))) |
| 729 |
|
| 730 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 731 |
;;; |
| 732 |
;;; Cleaning +trash |
| 733 |
;;; |
| 734 |
|
| 735 |
(defun mew-summary-clean-trash () |
| 736 |
"Remove all messages in +trash." |
| 737 |
(interactive) |
| 738 |
(let* ((case (mew-sinfo-get-case)) |
| 739 |
(folder (mew-sinfo-get-folder)) |
| 740 |
case:trash trash trashdir msgs) |
| 741 |
(cond |
| 742 |
((mew-folder-imapp folder) |
| 743 |
(setq trash (mew-imap-trash-folder case))) |
| 744 |
(t |
| 745 |
(setq trash mew-trash-folder))) |
| 746 |
(unless trash |
| 747 |
(setq trash folder)) |
| 748 |
(setq case:trash (mew-input-folder case trash)) |
| 749 |
(if (null case:trash) |
| 750 |
(message "Nothing was processed") |
| 751 |
(setq case (mew-case:folder-case case:trash)) |
| 752 |
(setq trash (mew-case:folder-folder case:trash)) |
| 753 |
(setq trashdir (mew-expand-folder case:trash)) |
| 754 |
(setq msgs (mew-dir-messages trashdir)) |
| 755 |
(if (and (mew-folder-localp trash) (null msgs)) |
| 756 |
(message "No messages to be removed in %s" trash) |
| 757 |
(if (not (y-or-n-p (format "Remove all messages in %s? " case:trash))) |
| 758 |
(message "No messages removed in %s" trash) |
| 759 |
(if (string= folder trash) (mew-summary-reset)) |
| 760 |
(message "Removing all messages in %s..." case:trash) |
| 761 |
(when (get-buffer case:trash) |
| 762 |
(with-current-buffer case:trash |
| 763 |
(mew-summary-kill-subprocess))) |
| 764 |
(mew-summary-unlink-msgs case:trash msgs) |
| 765 |
(mew-summary-folder-cache-clean case:trash) |
| 766 |
(message "Removing all messages in %s...done" case:trash) |
| 767 |
(when (mew-folder-imapp trash) |
| 768 |
(if (get-buffer case:trash) |
| 769 |
(set-buffer case:trash) |
| 770 |
(mew-summary-switch-to-folder case:trash 'set-buffer)) |
| 771 |
(mew-imap-retrieve case 'exec case:trash |
| 772 |
(mew-make-execinfo :remove '("1:*") |
| 773 |
:rttl 0 |
| 774 |
:dttl -1)))))))) |
| 775 |
|
| 776 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 777 |
;;; |
| 778 |
;;; Copy local |
| 779 |
;;; |
| 780 |
|
| 781 |
(defun mew-summary-local-copy () |
| 782 |
"Copy a message to a local folder." |
| 783 |
(interactive) |
| 784 |
(mew-summary-msg-or-part |
| 785 |
(let ((fld (mew-summary-folder-name)) |
| 786 |
(exclusivep t) |
| 787 |
msg dstmsg dstfld file dstfile) |
| 788 |
(save-excursion |
| 789 |
(mew-summary-goto-message) |
| 790 |
(setq msg (mew-summary-message-number))) |
| 791 |
(setq file (mew-expand-msg fld msg)) |
| 792 |
(setq dstfld (mew-input-local-folder mew-inbox-folder)) |
| 793 |
(when (and dstfld (mew-local-folder-check dstfld 'ask)) |
| 794 |
(setq dstmsg (mew-folder-new-message dstfld 'numonly)) |
| 795 |
(setq dstfile (mew-expand-msg dstfld dstmsg)) |
| 796 |
(when (get-buffer dstfld) |
| 797 |
(set-buffer dstfld) |
| 798 |
(setq exclusivep (mew-summary-exclusive-p))) |
| 799 |
(cond |
| 800 |
((not exclusivep) |
| 801 |
(message "Try again later")) |
| 802 |
((string= file dstfile) |
| 803 |
(message "You cannot copy this onto itself")) |
| 804 |
(t |
| 805 |
(mew-summary-local-copy-one file dstfile) |
| 806 |
(mew-touch-folder dstfld) |
| 807 |
(message "Copied to %s/%s" dstfld dstmsg))))))) |
| 808 |
|
| 809 |
(defun mew-summary-mark-local-copy (&optional arg) |
| 810 |
"Copy messages marked with '*' to a local folder. If called |
| 811 |
with '\\[universal-argument]', only messages marked with '*' in |
| 812 |
the region are handled." |
| 813 |
(interactive "P") |
| 814 |
(mew-summary-not-in-draft |
| 815 |
(let ((mew-use-highlight-x-face nil) |
| 816 |
(fld (mew-summary-folder-name)) |
| 817 |
(exclusivep t) |
| 818 |
msgs file dstmsg dstfld dstfile |
| 819 |
beg end region total i) |
| 820 |
(if (mew-mark-active-p) (setq arg t)) |
| 821 |
(cond |
| 822 |
(arg |
| 823 |
(setq region (mew-summary-get-region)) |
| 824 |
(setq beg (car region)) |
| 825 |
(setq end (cdr region))) |
| 826 |
(t |
| 827 |
(setq beg (point-min)) |
| 828 |
(setq end (point-max)))) |
| 829 |
(setq dstfld (mew-input-local-folder mew-inbox-folder)) |
| 830 |
(when (and dstfld (mew-local-folder-check dstfld 'ask)) |
| 831 |
(let ((mew-use-suffix nil)) |
| 832 |
(setq dstmsg (mew-folder-new-message dstfld 'numonly))) |
| 833 |
(setq msgs (mew-summary-mark-collect mew-mark-review beg end)) |
| 834 |
(when (get-buffer dstfld) |
| 835 |
(with-current-buffer dstfld |
| 836 |
(setq exclusivep (mew-summary-exclusive-p)))) |
| 837 |
(cond |
| 838 |
((null msgs) |
| 839 |
(message "No mark")) |
| 840 |
((not exclusivep) |
| 841 |
(message "Try again later")) |
| 842 |
(t |
| 843 |
(message "Copying...") |
| 844 |
(setq total (length msgs)) |
| 845 |
(setq i 1) |
| 846 |
(dolist (msg msgs) |
| 847 |
(setq file (mew-expand-msg fld msg)) |
| 848 |
(setq dstfile (mew-expand-new-msg dstfld dstmsg)) |
| 849 |
(message "Copying (%d/%d)..." i total) |
| 850 |
(mew-summary-local-copy-one file dstfile) |
| 851 |
(setq dstmsg (number-to-string (1+ (string-to-number dstmsg)))) |
| 852 |
(setq i (1+ i))) |
| 853 |
(mew-touch-folder dstfld) |
| 854 |
(message "Copying...done"))))))) |
| 855 |
|
| 856 |
(defun mew-summary-local-copy-one (srcfile dstfile) |
| 857 |
(with-temp-buffer |
| 858 |
(mew-frwlet mew-cs-text-for-read mew-cs-text-for-write |
| 859 |
(mew-insert-file-contents srcfile) |
| 860 |
(goto-char (point-min)) |
| 861 |
(mew-header-delete-lines (list mew-x-mew-uidl:)) |
| 862 |
(write-region (point-min) (point-max) dstfile nil 'no-msg) |
| 863 |
(mew-set-file-modes dstfile)))) |
| 864 |
|
| 865 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 866 |
;;; |
| 867 |
;;; Deleting and moving a folder |
| 868 |
;;; |
| 869 |
|
| 870 |
(defun mew-summary-delete-folder () |
| 871 |
"Delete this folder." |
| 872 |
(interactive) |
| 873 |
(mew-summary-only |
| 874 |
(let* ((folder (or (mew-sinfo-get-folder) |
| 875 |
(mew-summary-folder-name 'ext))) |
| 876 |
(case (mew-sinfo-get-case)) |
| 877 |
(case:folder (mew-summary-folder-name 'ext)) |
| 878 |
(dir (mew-expand-folder case:folder)) |
| 879 |
(buf (current-buffer))) |
| 880 |
(cond |
| 881 |
((mew-folder-localp folder) |
| 882 |
(if (mew-folder-node-p folder) |
| 883 |
(message "%s cannot be deleted" folder) |
| 884 |
(when (y-or-n-p "Delete this folder? ") |
| 885 |
(mew-delete-directory-recursively dir) |
| 886 |
(mew-local-folder-delete folder) |
| 887 |
(run-hook-with-args 'mew-summary-delete-folder-hook folder) |
| 888 |
(mew-summary-visit-folder mew-inbox-folder) |
| 889 |
(mew-kill-buffer buf)))) |
| 890 |
((mew-folder-imapp folder) |
| 891 |
(if (mew-folder-node-p folder case) |
| 892 |
(message "%s cannot be deleted" folder) |
| 893 |
(when (y-or-n-p "Delete this folder? ") |
| 894 |
(setq mew-summary-buffer-process-error nil) |
| 895 |
(mew-imap-retrieve case 'delete case:folder) |
| 896 |
(mew-timing) |
| 897 |
(mew-rendezvous mew-summary-buffer-process) |
| 898 |
(if mew-summary-buffer-process-error |
| 899 |
(progn |
| 900 |
(message "%s cannot be deleted" folder) |
| 901 |
(setq mew-summary-buffer-process-error nil)) |
| 902 |
(mew-imap-folder-delete case folder) |
| 903 |
(mew-delete-directory-recursively dir) ;; cache |
| 904 |
(run-hook-with-args 'mew-summary-delete-folder-hook case:folder) |
| 905 |
(mew-summary-visit-folder mew-imap-inbox-folder) |
| 906 |
(mew-kill-buffer buf))))))))) |
| 907 |
|
| 908 |
(defun mew-summary-rename-folder () |
| 909 |
"Rename this folder." |
| 910 |
(interactive) |
| 911 |
(mew-summary-only |
| 912 |
(let* ((folder (or (mew-sinfo-get-folder) |
| 913 |
(mew-summary-folder-name 'ext))) |
| 914 |
(case (mew-sinfo-get-case)) |
| 915 |
(case:folder (mew-summary-folder-name 'ext)) |
| 916 |
(dir (mew-expand-folder case:folder)) |
| 917 |
(buf (current-buffer)) |
| 918 |
new-folder new-dir case:new-folder) |
| 919 |
(cond |
| 920 |
((mew-folder-localp folder) |
| 921 |
(setq new-folder (mew-input-local-folder folder)) |
| 922 |
(setq new-dir (mew-expand-folder new-folder)) |
| 923 |
(cond |
| 924 |
((string= folder new-folder) |
| 925 |
(message "%s was not moved" folder)) |
| 926 |
((file-exists-p new-dir) |
| 927 |
(message "%s was not moved since %s exists" folder new-folder)) |
| 928 |
(t |
| 929 |
(mew-rename-directory dir new-dir) |
| 930 |
(mew-summary-switch-to-folder new-folder) |
| 931 |
(mew-kill-buffer buf) |
| 932 |
(if (mew-folder-node-p folder) |
| 933 |
;; xxx remove all related buffer? |
| 934 |
(mew-local-update 'force) |
| 935 |
(mew-local-folder-delete folder) |
| 936 |
(mew-local-folder-insert new-folder)) |
| 937 |
(run-hook-with-args 'mew-summary-rename-folder-hook folder new-folder)))) |
| 938 |
((mew-folder-imapp folder) |
| 939 |
(setq new-folder (car (mew-input-refile-folders (list folder) t case mew-folder-imap))) |
| 940 |
(setq case:new-folder (mew-case-folder case new-folder)) |
| 941 |
(setq new-dir (mew-expand-folder case:new-folder)) |
| 942 |
(cond |
| 943 |
((string= folder new-folder) |
| 944 |
(message "%s was not moved" folder)) |
| 945 |
((file-exists-p new-dir) |
| 946 |
(message "%s was not moved since %s exists" folder new-folder)) |
| 947 |
(t |
| 948 |
(mew-imap-retrieve case 'rename case:folder case:new-folder) |
| 949 |
(mew-timing) |
| 950 |
(mew-rendezvous mew-summary-buffer-process) |
| 951 |
(if mew-summary-buffer-process-error |
| 952 |
(progn |
| 953 |
(message "%s cannot be renamed" folder) |
| 954 |
(setq mew-summary-buffer-process-error nil)) |
| 955 |
(rename-file dir new-dir t) ;; cache |
| 956 |
(mew-summary-switch-to-folder case:new-folder) |
| 957 |
(mew-kill-buffer buf) |
| 958 |
(if (mew-folder-node-p folder case) |
| 959 |
(if (y-or-n-p "Collect folders now? ") |
| 960 |
(mew-imap-update case) |
| 961 |
(mew-message-for-summary "Type '\\[universal-argument]\\[mew-status-update]' to collect folders")) |
| 962 |
(mew-imap-folder-delete case folder) |
| 963 |
(mew-imap-folder-insert case new-folder)) |
| 964 |
(run-hook-with-args 'mew-summary-rename-folder-hook |
| 965 |
case:folder case:new-folder))))))))) |
| 966 |
|
| 967 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 968 |
;;; |
| 969 |
;;; Toggle |
| 970 |
;;; |
| 971 |
|
| 972 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 973 |
;;; |
| 974 |
;;; Summary only vs Summary/Message |
| 975 |
;;; |
| 976 |
|
| 977 |
(defun mew-summary-toggle-disp-msg (&optional arg) |
| 978 |
"Toggle 'Summary mode only' and 'Summary & Message mode'. If |
| 979 |
you choose 'Summary mode only', you can quickly put the delete |
| 980 |
marks since the next message is not displayed." |
| 981 |
(interactive) |
| 982 |
(cond |
| 983 |
((eq arg 'on) |
| 984 |
(mew-sinfo-set-disp-msg t)) |
| 985 |
((eq arg 'off) |
| 986 |
(mew-sinfo-set-disp-msg nil) |
| 987 |
(mew-summary-reset-mode-line)) |
| 988 |
(t |
| 989 |
(mew-sinfo-set-disp-msg (not (mew-sinfo-get-disp-msg))) |
| 990 |
(if (mew-sinfo-get-disp-msg) |
| 991 |
(mew-summary-display 'redisplay) |
| 992 |
(mew-summary-goto-message) |
| 993 |
(mew-summary-reset) |
| 994 |
(mew-summary-cook-window)))) |
| 995 |
(run-hooks 'mew-summary-toggle-disp-msg-hook)) |
| 996 |
|
| 997 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 998 |
;;; |
| 999 |
;;; 8bit clean |
| 1000 |
;;; |
| 1001 |
|
| 1002 |
(defun mew-summary-toggle-8bit () |
| 1003 |
"Toggle 8bit mode(i.e. 'mew-use-8bit')." |
| 1004 |
(interactive) |
| 1005 |
(setq mew-use-8bit (not mew-use-8bit)) |
| 1006 |
(if mew-use-8bit |
| 1007 |
(message "mew-use-8bit has been set to 't'") |
| 1008 |
(message "mew-use-8bit has been set to 'nil'"))) |
| 1009 |
|
| 1010 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1011 |
;;; |
| 1012 |
;;; Mew cache clean up |
| 1013 |
;;; |
| 1014 |
|
| 1015 |
(defun mew-summary-cache-clean-up () |
| 1016 |
"Clean-up caches of analyzed messages." |
| 1017 |
(interactive) |
| 1018 |
(mew-cache-clean-up) |
| 1019 |
(message "Mew cache clean up...done")) |
| 1020 |
|
| 1021 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1022 |
;;; |
| 1023 |
;;; Toggle warning |
| 1024 |
;;; |
| 1025 |
|
| 1026 |
(defun mew-summary-toggle-warning () |
| 1027 |
"Toggle warning level. |
| 1028 |
If 'mew-warning-field-level' is 2, set it to 1. |
| 1029 |
If 'mew-warning-field-level' is 1, set it to 2." |
| 1030 |
(interactive) |
| 1031 |
(if (= mew-warning-field-level 2) |
| 1032 |
(setq mew-warning-field-level 1) |
| 1033 |
(setq mew-warning-field-level 2)) |
| 1034 |
(mew-cache-clean-up) |
| 1035 |
(mew-summary-analyze-again) |
| 1036 |
(message "Mew warning level %d" mew-warning-field-level)) |
| 1037 |
|
| 1038 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1039 |
;;; |
| 1040 |
;;; Toggle decode policy |
| 1041 |
;;; |
| 1042 |
|
| 1043 |
(defun mew-summary-toggle-policy (&optional arg) |
| 1044 |
"Toggle decode policy(i.e. 'mew-decode-broken')." |
| 1045 |
(interactive "P") |
| 1046 |
(if arg |
| 1047 |
(setq mew-decode-broken nil |
| 1048 |
mew-use-name-parameter nil) |
| 1049 |
(setq mew-decode-broken (not mew-decode-broken)) |
| 1050 |
(setq mew-use-name-parameter (not mew-use-name-parameter))) |
| 1051 |
(mew-cache-clean-up) |
| 1052 |
(mew-summary-analyze-again) |
| 1053 |
(message "Mew \"%s\" mode" (if mew-decode-broken "TOLERANT" "STRICT"))) |
| 1054 |
|
| 1055 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1056 |
;;; |
| 1057 |
;;; Toggle debug |
| 1058 |
;;; |
| 1059 |
|
| 1060 |
(defun mew-summary-toggle-debug () |
| 1061 |
"Toggle 'mew-debug'." |
| 1062 |
(interactive) |
| 1063 |
(setq mew-debug (not mew-debug)) |
| 1064 |
(if mew-debug |
| 1065 |
(message "'mew-debug' is now 't'") |
| 1066 |
(message "'mew-debug' is now 'nil'"))) |
| 1067 |
|
| 1068 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1069 |
;;; |
| 1070 |
;;; Toggle PGP/MIME and old PGP |
| 1071 |
;;; |
| 1072 |
|
| 1073 |
(defun mew-summary-toggle-pgp () |
| 1074 |
"Toggle PGP/MIME and old PGP (i.e. 'mew-use-old-pgp')." |
| 1075 |
(interactive) |
| 1076 |
(setq mew-use-old-pgp (not mew-use-old-pgp)) |
| 1077 |
(if mew-use-old-pgp |
| 1078 |
(message "mew-use-old-pgp has been set to 't'") |
| 1079 |
(message "mew-use-old-pgp has been set to 'nil'"))) |
| 1080 |
|
| 1081 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1082 |
;;; |
| 1083 |
;;; Learning spam and ham |
| 1084 |
;;; |
| 1085 |
|
| 1086 |
(defun mew-summary-learn-spam () |
| 1087 |
"Learn that this message is a spam. |
| 1088 |
See also 'mew-spam-prog' and 'mew-spam-prog-args." |
| 1089 |
(interactive) |
| 1090 |
(mew-summary-msg |
| 1091 |
(let* ((fld (mew-summary-folder-name)) |
| 1092 |
(msg (mew-summary-message-number)) |
| 1093 |
(file (mew-expand-msg fld msg)) |
| 1094 |
(case (mew-sinfo-get-case)) |
| 1095 |
(prog (mew-spam-prog case)) |
| 1096 |
(args (mew-spam-prog-args case)) |
| 1097 |
beg end) |
| 1098 |
(message "Learning as spam...") |
| 1099 |
(when (mew-which-exec prog) |
| 1100 |
(with-temp-buffer |
| 1101 |
(apply 'call-process prog file (current-buffer) nil args) |
| 1102 |
(setq beg (point-min)) |
| 1103 |
(goto-char beg) |
| 1104 |
(forward-line) |
| 1105 |
(if (= (point) beg) |
| 1106 |
(message "Learning as spam...done") |
| 1107 |
(setq end (1- (point))) |
| 1108 |
(message "%s" (concat "Learned as spam: " (mew-buffer-substring beg end))))))))) |
| 1109 |
|
| 1110 |
(defun mew-summary-learn-ham () |
| 1111 |
"Learn that this message is a ham. |
| 1112 |
See also 'mew-ham-prog' and 'mew-ham-prog-args." |
| 1113 |
(interactive) |
| 1114 |
(mew-summary-msg |
| 1115 |
(let* ((fld (mew-summary-folder-name)) |
| 1116 |
(msg (mew-summary-message-number)) |
| 1117 |
(file (mew-expand-msg fld msg)) |
| 1118 |
(case (mew-sinfo-get-case)) |
| 1119 |
(prog (mew-ham-prog case)) |
| 1120 |
(args (mew-ham-prog-args case)) |
| 1121 |
beg end) |
| 1122 |
(message "Learning as ham...") |
| 1123 |
(when (mew-which-exec prog) |
| 1124 |
(with-temp-buffer |
| 1125 |
(apply 'call-process prog file (current-buffer) nil args) |
| 1126 |
(setq beg (point-min)) |
| 1127 |
(goto-char beg) |
| 1128 |
(forward-line) |
| 1129 |
(if (= (point) beg) |
| 1130 |
(message "Learning as ham...done") |
| 1131 |
(setq end (1- (point))) |
| 1132 |
(message "%s" (concat "Learned as ham: " (mew-buffer-substring beg end))))))))) |
| 1133 |
|
| 1134 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1135 |
;;; |
| 1136 |
;;; Search invisible |
| 1137 |
;;; |
| 1138 |
|
| 1139 |
(defun mew-summary-toggle-invisible () |
| 1140 |
"Toggle the value of search-invisible. |
| 1141 |
Invisible information in Summary mode cannot be searched by default. |
| 1142 |
Executing this command enables searching such information." |
| 1143 |
(interactive) |
| 1144 |
(if (eq search-invisible t) |
| 1145 |
(setq search-invisible 'open) |
| 1146 |
(setq search-invisible t)) |
| 1147 |
(message "'search-invisible' is set to '%s'" search-invisible)) |
| 1148 |
|
| 1149 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1150 |
;;; |
| 1151 |
;;; Lines |
| 1152 |
;;; |
| 1153 |
|
| 1154 |
(defun mew-summary-line () |
| 1155 |
"Toggle normal lines, wrapped lines and long lines." |
| 1156 |
(interactive) |
| 1157 |
(let ((fld (mew-summary-folder-name)) |
| 1158 |
(msg (mew-summary-message-number)) |
| 1159 |
(cwin (get-buffer-window (current-buffer))) |
| 1160 |
(mwin (get-buffer-window (mew-buffer-message)))) |
| 1161 |
(if (not mwin) |
| 1162 |
(message "No message is displayed") |
| 1163 |
(select-window mwin) |
| 1164 |
(unwind-protect |
| 1165 |
(progn |
| 1166 |
(mew-message-line) |
| 1167 |
(mew-message-mode-line fld msg)) |
| 1168 |
(select-window cwin))))) |
| 1169 |
|
| 1170 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1171 |
;;; |
| 1172 |
;;; Horizontal Scrolling |
| 1173 |
;;; |
| 1174 |
|
| 1175 |
(defun mew-summary-scroll-left () |
| 1176 |
"Scroll the Message window to the right." |
| 1177 |
(interactive) |
| 1178 |
(let ((cwin (get-buffer-window (current-buffer))) |
| 1179 |
(mwin (get-buffer-window (mew-buffer-message)))) |
| 1180 |
(if (not mwin) |
| 1181 |
(message "No message is displayed") |
| 1182 |
(select-window mwin) |
| 1183 |
(unwind-protect |
| 1184 |
(mew-message-scroll-left) |
| 1185 |
(select-window cwin))))) |
| 1186 |
|
| 1187 |
(defun mew-summary-scroll-right () |
| 1188 |
"Scroll the Message window to the left." |
| 1189 |
(interactive) |
| 1190 |
(let ((cwin (get-buffer-window (current-buffer))) |
| 1191 |
(mwin (get-buffer-window (mew-buffer-message)))) |
| 1192 |
(if (not mwin) |
| 1193 |
(message "No message is displayed") |
| 1194 |
(select-window mwin) |
| 1195 |
(unwind-protect |
| 1196 |
(mew-message-scroll-right) |
| 1197 |
(select-window cwin))))) |
| 1198 |
|
| 1199 |
(provide 'mew-summary4) |
| 1200 |
|
| 1201 |
;;; Copyright Notice: |
| 1202 |
|
| 1203 |
;; Copyright (C) 1996-2015 Mew developing team. |
| 1204 |
;; All rights reserved. |
| 1205 |
|
| 1206 |
;; Redistribution and use in source and binary forms, with or without |
| 1207 |
;; modification, are permitted provided that the following conditions |
| 1208 |
;; are met: |
| 1209 |
;; |
| 1210 |
;; 1. Redistributions of source code must retain the above copyright |
| 1211 |
;; notice, this list of conditions and the following disclaimer. |
| 1212 |
;; 2. Redistributions in binary form must reproduce the above copyright |
| 1213 |
;; notice, this list of conditions and the following disclaimer in the |
| 1214 |
;; documentation and/or other materials provided with the distribution. |
| 1215 |
;; 3. Neither the name of the team nor the names of its contributors |
| 1216 |
;; may be used to endorse or promote products derived from this software |
| 1217 |
;; without specific prior written permission. |
| 1218 |
;; |
| 1219 |
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND |
| 1220 |
;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 1221 |
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 1222 |
;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE |
| 1223 |
;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 1224 |
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 1225 |
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 1226 |
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 1227 |
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 1228 |
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 1229 |
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 1230 |
|
| 1231 |
;;; mew-summary4.el ends here |