1 ;;; mh-show.el --- MH-Show mode
3 ;; Copyright (C) 1993, 1995, 1997,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Bill Wohler <wohler@newt.com>
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
30 ;; Mode for showing messages.
42 (autoload 'mh-make-buffer-data
"mh-mime") ;can't be automatically generated
48 ;;; MH-Folder Commands
50 (defvar mh-showing-with-headers nil
51 "If non-nil, MH-Show buffer contains message with all header fields.
52 If nil, MH-Show buffer contains message processed normally.")
55 (defun mh-show (&optional message redisplay-flag
)
56 "Display message\\<mh-folder-mode-map>.
58 If the message under the cursor is already displayed, this command
59 scrolls to the beginning of the message. MH-E normally hides a lot of
60 the superfluous header fields that mailers add to a message, but if
61 you wish to see all of them, use the command \\[mh-header-display].
63 Two hooks can be used to control how messages are displayed. The
64 first hook, `mh-show-mode-hook', is called early on in the
65 process of the message display. It is usually used to perform
66 some action on the message's content. The second hook,
67 `mh-show-hook', is the last thing called after messages are
68 displayed. It's used to affect the behavior of MH-E in general or
69 when `mh-show-mode-hook' is too early.
71 From a program, optional argument MESSAGE can be used to display an
72 alternative message. The optional argument REDISPLAY-FLAG forces the
73 redisplay of the message even if the show buffer was already
74 displaying the correct message.
76 See the \"mh-show\" customization group for a litany of options that
77 control what displayed messages look like."
78 (interactive (list nil t
))
79 (when (or redisplay-flag
80 (and mh-showing-with-headers
81 (or mh-mhl-format-file mh-clean-message-header-flag
)))
82 (mh-invalidate-show-buffer))
83 (mh-show-msg message
))
86 (defun mh-header-display ()
87 "Display message with all header fields\\<mh-folder-mode-map>.
89 Use the command \\[mh-show] to show the message normally again."
91 (and (not mh-showing-with-headers
)
92 (or mh-mhl-format-file mh-clean-message-header-flag
)
93 (mh-invalidate-show-buffer))
94 (let ((mh-decode-mime-flag nil
)
95 (mh-mhl-format-file nil
)
96 (mh-clean-message-header-flag nil
))
98 (mh-in-show-buffer (mh-show-buffer)
99 (goto-char (point-min))
101 (setq mh-showing-with-headers t
)))
105 ;;; Support Routines for MH-Folder Commands
108 (defun mh-maybe-show (&optional msg
)
109 "Display message at cursor, but only if in show mode.
110 If optional arg MSG is non-nil, display that message instead."
111 (if mh-showing-mode
(mh-show msg
)))
113 (defun mh-show-msg (msg)
116 The hook `mh-show-hook' is called after the message has been
119 (setq msg
(mh-get-msg-num t
)))
121 (setq mh-page-to-next-msg-flag nil
)
122 (let ((folder mh-current-folder
)
123 (folders (list mh-current-folder
))
124 (clean-message-header mh-clean-message-header-flag
)
125 (show-window (get-buffer-window mh-show-buffer
))
126 (display-mime-buttons-flag mh-display-buttons-for-inline-parts-flag
))
127 (if (not (eq (next-window (minibuffer-window)) (selected-window)))
128 (delete-other-windows)) ; force ourself to the top window
129 (mh-in-show-buffer (mh-show-buffer)
130 (setq mh-display-buttons-for-inline-parts-flag display-mime-buttons-flag
)
132 (equal (mh-msg-filename msg folder
) buffer-file-name
))
133 (progn ;just back up to start
134 (goto-char (point-min))
135 (if (not clean-message-header
)
136 (mh-start-of-uncleaned-message)))
137 (mh-display-msg msg folder
)))
138 (if (not (= (1+ (window-height)) (frame-height))) ;not horizontally split
139 (shrink-window (- (window-height) (or mh-summary-height
140 (mh-summary-height)))))
142 ;; The following line is a nop which forces update of the scan line so
143 ;; that font-lock will update it (if needed)...
144 (mh-notate nil nil mh-cmd-note
)
145 (if (not (memq msg mh-seen-list
))
146 (setq mh-seen-list
(cons msg mh-seen-list
)))
147 (when mh-update-sequences-after-mh-show-flag
148 (mh-update-sequences)
151 (append (mh-index-delete-from-sequence mh-unseen-seq
(list msg
))
153 (when (mh-speed-flists-active-p)
154 (apply #'mh-speed-flists t folders
)))
155 (run-hooks 'mh-show-hook
)))
158 (defun mh-showing-mode (&optional arg
)
159 "Change whether messages should be displayed.
161 With ARG, display messages iff ARG is positive."
162 (setq mh-showing-mode
164 (not mh-showing-mode
)
165 (> (prefix-numeric-value arg
) 0))))
168 (defun mh-start-of-uncleaned-message ()
169 "Position uninteresting headers off the top of the window."
170 (let ((case-fold-search t
))
172 "^To:\\|^Cc:\\|^From:\\|^Subject:\\|^Date:" nil t
)
176 (defvar mh-show-buffer-mode-line-buffer-id
" {show-%s} %d"
177 "Format string to produce `mode-line-buffer-identification' for show buffers.
179 First argument is folder name. Second is message number.")
182 (defun mh-display-msg (msg-num folder-name
)
183 "Display MSG-NUM of FOLDER-NAME.
184 Sets the current buffer to the show buffer."
185 (let ((folder (mh-msg-folder folder-name
)))
187 ;; When Gnus uses external displayers it has to keep handles longer. So
188 ;; we will delete these handles when mh-quit is called on the folder. It
189 ;; would be nicer if there are weak pointers in emacs lisp, then we could
190 ;; get the garbage collector to do this for us.
191 (unless (mh-buffer-data)
192 (setf (mh-buffer-data) (mh-make-buffer-data)))
193 ;; Bind variables in folder buffer in case they are local
194 (let ((formfile mh-mhl-format-file
)
195 (clean-message-header mh-clean-message-header-flag
)
196 (invisible-headers mh-invisible-header-fields-compiled
)
197 (visible-headers nil
)
198 (msg-filename (mh-msg-filename msg-num folder-name
))
199 (show-buffer mh-show-buffer
)
200 (mm-inline-media-tests mh-mm-inline-media-tests
))
201 (if (not (file-exists-p msg-filename
))
202 (error "Message %d does not exist" msg-num
))
203 (if (and (> mh-show-maximum-size
0)
204 (> (elt (file-attributes msg-filename
) 7)
205 mh-show-maximum-size
)
208 "Message %d (%d bytes) exceeds %d bytes. Display it? "
209 msg-num
(elt (file-attributes msg-filename
) 7)
210 mh-show-maximum-size
))))
211 (error "Message %d not displayed" msg-num
))
212 (set-buffer show-buffer
)
213 (cond ((not (equal msg-filename buffer-file-name
))
215 (setq buffer-read-only nil
)
216 ;; Cleanup old mime handles
219 ;; Changing contents, so this hook needs to be reinitialized.
221 (if (boundp 'write-contents-hooks
) ;Emacs 19
222 (kill-local-variable 'write-contents-hooks
))
224 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
225 (if (stringp formfile
)
226 (list "-form" formfile
))
228 (insert-file-contents-literally msg-filename
))
229 ;; Use mm to display buffer
230 (when (and mh-decode-mime-flag
(not formfile
))
231 (mh-add-missing-mime-version-header)
232 (setf (mh-buffer-data) (mh-make-buffer-data))
236 (goto-char (point-min))
237 (cond (clean-message-header
238 (mh-clean-msg-header (point-min)
241 (goto-char (point-min)))
243 (mh-start-of-uncleaned-message)))
244 (mh-decode-message-header)
245 ;; the parts of visiting we want to do (no locking)
246 (or (eq buffer-undo-list t
) ;don't save undo info for prev msgs
247 (setq buffer-undo-list nil
))
248 (set-buffer-auto-saved)
249 ;; the parts of set-visited-file-name we want to do (no locking)
250 (setq buffer-file-name msg-filename
)
251 (setq buffer-backed-up nil
)
255 (when (and mh-decode-mime-flag
(not formfile
))
256 (setq buffer-read-only nil
)
258 (mh-display-emphasis))
259 (setq buffer-read-only t
))
260 (set-buffer-modified-p nil
)
261 (setq mh-show-folder-buffer folder
)
262 (setq mode-line-buffer-identification
263 (list (format mh-show-buffer-mode-line-buffer-id
264 folder-name msg-num
)))
267 (setq mh-showing-with-headers nil
))))))
269 (defun mh-msg-folder (folder-name)
270 "Return the name of the buffer for FOLDER-NAME."
274 (defun mh-clean-msg-header (start invisible-headers visible-headers
)
275 "Flush extraneous lines in message header.
277 Header is cleaned from START to the end of the message header.
278 INVISIBLE-HEADERS contains a regular expression specifying lines
279 to delete from the header. VISIBLE-HEADERS contains a regular
280 expression specifying the lines to display. INVISIBLE-HEADERS is
281 ignored if VISIBLE-HEADERS is non-nil."
282 ;; XXX Note that MH-E no longer supports the `mh-visible-headers'
283 ;; variable, so this function could be trimmed of this feature too."
284 (let ((case-fold-search t
)
285 (buffer-read-only nil
))
288 (if (search-forward "\n\n" nil
'move
)
290 (narrow-to-region start
(point))
291 (goto-char (point-min))
293 (while (< (point) (point-max))
294 (cond ((looking-at visible-headers
)
296 (while (looking-at "[ \t]") (forward-line 1)))
299 (while (looking-at "[ \t]")
300 (mh-delete-line 1)))))
301 (while (re-search-forward invisible-headers nil t
)
304 (while (looking-at "[ \t]")
305 (mh-delete-line 1)))))
306 (let ((mh-compose-skipped-header-fields ()))
307 (mh-letter-hide-all-skipped-fields))
311 (defun mh-invalidate-show-buffer ()
312 "Invalidate the show buffer so we must update it to use it."
313 (if (get-buffer mh-show-buffer
)
315 (set-buffer mh-show-buffer
)
318 (defun mh-unvisit-file ()
319 "Separate current buffer from the message file it was visiting."
320 (or (not (buffer-modified-p))
321 (null buffer-file-name
) ;we've been here before
322 (yes-or-no-p (format "Message %s modified; flush changes? "
323 (file-name-nondirectory buffer-file-name
)))
324 (error "Flushing changes not confirmed"))
325 (clear-visited-file-modtime)
327 (setq buffer-file-name nil
))
329 (defun mh-summary-height ()
330 "Return ideal value for the variable `mh-summary-height'.
331 The current frame height is taken into consideration."
332 (or (and (fboundp 'frame-height
)
333 (> (frame-height) 24)
334 (min 10 (/ (frame-height) 6)))
339 ;; Infrastructure to generate show-buffer functions from folder functions
340 ;; XEmacs does not have deactivate-mark? What is the equivalent of
341 ;; transient-mark-mode for XEmacs? Should we be restoring the mark in the
342 ;; folder buffer after the operation has been carried out.
343 (defmacro mh-defun-show-buffer
(function original-function
344 &optional dont-return
)
345 "Define FUNCTION to run ORIGINAL-FUNCTION in folder buffer.
346 If the buffer we start in is still visible and DONT-RETURN is nil
347 then switch to it after that."
349 ,(format "Calls %s from the message's folder.\n%s\nSee \"%s\" for more info.\n"
352 "When function completes, returns to the show buffer if it is
356 (when (buffer-live-p (get-buffer mh-show-folder-buffer
))
357 (let ((config (current-window-configuration))
358 (folder-buffer mh-show-folder-buffer
)
360 ,@(if dont-return
() '((cur-buffer-name (buffer-name)))))
361 (pop-to-buffer mh-show-folder-buffer nil
)
362 (unless (equal (buffer-name
363 (window-buffer (frame-first-window (selected-frame))))
365 (delete-other-windows))
367 (mh-funcall-if-exists deactivate-mark
)
369 (prog1 (call-interactively (function ,original-function
))
370 (setq normal-exit t
))
371 (mh-funcall-if-exists deactivate-mark
)
372 (when (eq major-mode
'mh-folder-mode
)
373 (mh-funcall-if-exists hl-line-highlight
))
374 (cond ((not normal-exit
)
375 (set-window-configuration config
))
377 `(t (setq mh-previous-window-config config
))
378 `((and (get-buffer cur-buffer-name
)
379 (window-live-p (get-buffer-window
380 (get-buffer cur-buffer-name
))))
381 (pop-to-buffer (get-buffer cur-buffer-name
) nil
)))))))))
383 ;; Generate interactive functions for the show buffer from the corresponding
385 (mh-defun-show-buffer mh-show-previous-undeleted-msg
386 mh-previous-undeleted-msg
)
387 (mh-defun-show-buffer mh-show-next-undeleted-msg
388 mh-next-undeleted-msg
)
389 (mh-defun-show-buffer mh-show-quit mh-quit
)
390 (mh-defun-show-buffer mh-show-delete-msg mh-delete-msg
)
391 (mh-defun-show-buffer mh-show-refile-msg mh-refile-msg
)
392 (mh-defun-show-buffer mh-show-undo mh-undo
)
393 (mh-defun-show-buffer mh-show-execute-commands mh-execute-commands
)
394 (mh-defun-show-buffer mh-show-reply mh-reply t
)
395 (mh-defun-show-buffer mh-show-redistribute mh-redistribute
)
396 (mh-defun-show-buffer mh-show-forward mh-forward t
)
397 (mh-defun-show-buffer mh-show-header-display mh-header-display
)
398 (mh-defun-show-buffer mh-show-refile-or-write-again
399 mh-refile-or-write-again
)
400 (mh-defun-show-buffer mh-show-show mh-show
)
401 (mh-defun-show-buffer mh-show-write-message-to-file
402 mh-write-msg-to-file
)
403 (mh-defun-show-buffer mh-show-extract-rejected-mail
404 mh-extract-rejected-mail t
)
405 (mh-defun-show-buffer mh-show-delete-msg-no-motion
406 mh-delete-msg-no-motion
)
407 (mh-defun-show-buffer mh-show-first-msg mh-first-msg
)
408 (mh-defun-show-buffer mh-show-last-msg mh-last-msg
)
409 (mh-defun-show-buffer mh-show-copy-msg mh-copy-msg
)
410 (mh-defun-show-buffer mh-show-edit-again mh-edit-again t
)
411 (mh-defun-show-buffer mh-show-goto-msg mh-goto-msg
)
412 (mh-defun-show-buffer mh-show-inc-folder mh-inc-folder
)
413 (mh-defun-show-buffer mh-show-delete-subject-or-thread
414 mh-delete-subject-or-thread
)
415 (mh-defun-show-buffer mh-show-delete-subject mh-delete-subject
)
416 (mh-defun-show-buffer mh-show-print-msg mh-print-msg
)
417 (mh-defun-show-buffer mh-show-send mh-send t
)
418 (mh-defun-show-buffer mh-show-toggle-showing mh-toggle-showing t
)
419 (mh-defun-show-buffer mh-show-pipe-msg mh-pipe-msg t
)
420 (mh-defun-show-buffer mh-show-sort-folder mh-sort-folder
)
421 (mh-defun-show-buffer mh-show-visit-folder mh-visit-folder t
)
422 (mh-defun-show-buffer mh-show-rescan-folder mh-rescan-folder
)
423 (mh-defun-show-buffer mh-show-pack-folder mh-pack-folder
)
424 (mh-defun-show-buffer mh-show-kill-folder mh-kill-folder t
)
425 (mh-defun-show-buffer mh-show-list-folders mh-list-folders t
)
426 (mh-defun-show-buffer mh-show-undo-folder mh-undo-folder
)
427 (mh-defun-show-buffer mh-show-delete-msg-from-seq
428 mh-delete-msg-from-seq
)
429 (mh-defun-show-buffer mh-show-delete-seq mh-delete-seq
)
430 (mh-defun-show-buffer mh-show-list-sequences mh-list-sequences
)
431 (mh-defun-show-buffer mh-show-narrow-to-seq mh-narrow-to-seq
)
432 (mh-defun-show-buffer mh-show-put-msg-in-seq mh-put-msg-in-seq
)
433 (mh-defun-show-buffer mh-show-msg-is-in-seq mh-msg-is-in-seq
)
434 (mh-defun-show-buffer mh-show-widen mh-widen
)
435 (mh-defun-show-buffer mh-show-narrow-to-subject mh-narrow-to-subject
)
436 (mh-defun-show-buffer mh-show-narrow-to-from mh-narrow-to-from
)
437 (mh-defun-show-buffer mh-show-narrow-to-cc mh-narrow-to-cc
)
438 (mh-defun-show-buffer mh-show-narrow-to-range mh-narrow-to-range
)
439 (mh-defun-show-buffer mh-show-narrow-to-to mh-narrow-to-to
)
440 (mh-defun-show-buffer mh-show-store-msg mh-store-msg
)
441 (mh-defun-show-buffer mh-show-page-digest mh-page-digest
)
442 (mh-defun-show-buffer mh-show-page-digest-backwards
443 mh-page-digest-backwards
)
444 (mh-defun-show-buffer mh-show-burst-digest mh-burst-digest
)
445 (mh-defun-show-buffer mh-show-page-msg mh-page-msg
)
446 (mh-defun-show-buffer mh-show-previous-page mh-previous-page
)
447 (mh-defun-show-buffer mh-show-modify mh-modify t
)
448 (mh-defun-show-buffer mh-show-next-button mh-next-button
)
449 (mh-defun-show-buffer mh-show-prev-button mh-prev-button
)
450 (mh-defun-show-buffer mh-show-toggle-mime-part mh-folder-toggle-mime-part
)
451 (mh-defun-show-buffer mh-show-save-mime-part mh-folder-save-mime-part
)
452 (mh-defun-show-buffer mh-show-inline-mime-part mh-folder-inline-mime-part
)
453 (mh-defun-show-buffer mh-show-toggle-threads mh-toggle-threads
)
454 (mh-defun-show-buffer mh-show-thread-delete mh-thread-delete
)
455 (mh-defun-show-buffer mh-show-thread-refile mh-thread-refile
)
456 (mh-defun-show-buffer mh-show-update-sequences mh-update-sequences
)
457 (mh-defun-show-buffer mh-show-next-unread-msg mh-next-unread-msg
)
458 (mh-defun-show-buffer mh-show-previous-unread-msg mh-previous-unread-msg
)
459 (mh-defun-show-buffer mh-show-thread-ancestor mh-thread-ancestor
)
460 (mh-defun-show-buffer mh-show-thread-next-sibling mh-thread-next-sibling
)
461 (mh-defun-show-buffer mh-show-thread-previous-sibling
462 mh-thread-previous-sibling
)
463 (mh-defun-show-buffer mh-show-index-visit-folder mh-index-visit-folder t
)
464 (mh-defun-show-buffer mh-show-toggle-tick mh-toggle-tick
)
465 (mh-defun-show-buffer mh-show-narrow-to-tick mh-narrow-to-tick
)
466 (mh-defun-show-buffer mh-show-junk-blacklist mh-junk-blacklist
)
467 (mh-defun-show-buffer mh-show-junk-whitelist mh-junk-whitelist
)
468 (mh-defun-show-buffer mh-show-index-new-messages mh-index-new-messages
)
469 (mh-defun-show-buffer mh-show-index-ticked-messages mh-index-ticked-messages
)
470 (mh-defun-show-buffer mh-show-index-sequenced-messages
471 mh-index-sequenced-messages
)
472 (mh-defun-show-buffer mh-show-catchup mh-catchup
)
473 (mh-defun-show-buffer mh-show-ps-print-toggle-color mh-ps-print-toggle-color
)
474 (mh-defun-show-buffer mh-show-ps-print-toggle-faces mh-ps-print-toggle-faces
)
475 (mh-defun-show-buffer mh-show-ps-print-msg-file mh-ps-print-msg-file
)
476 (mh-defun-show-buffer mh-show-ps-print-msg mh-ps-print-msg
)
477 (mh-defun-show-buffer mh-show-toggle-mime-buttons mh-toggle-mime-buttons
)
478 (mh-defun-show-buffer mh-show-display-with-external-viewer
479 mh-display-with-external-viewer
)
486 mh-show-sequence-menu mh-show-mode-map
"Menu for MH-E folder-sequence."
488 ["Add Message to Sequence..." mh-show-put-msg-in-seq t
]
489 ["List Sequences for Message" mh-show-msg-is-in-seq t
]
490 ["Delete Message from Sequence..." mh-show-delete-msg-from-seq t
]
491 ["List Sequences in Folder..." mh-show-list-sequences t
]
492 ["Delete Sequence..." mh-show-delete-seq t
]
493 ["Narrow to Sequence..." mh-show-narrow-to-seq t
]
494 ["Widen from Sequence" mh-show-widen t
]
496 ["Narrow to Subject Sequence" mh-show-narrow-to-subject t
]
497 ["Narrow to Tick Sequence" mh-show-narrow-to-tick
499 (set-buffer mh-show-folder-buffer
)
500 (and mh-tick-seq
(mh-seq-msgs (mh-find-seq mh-tick-seq
))))]
501 ["Delete Rest of Same Subject" mh-show-delete-subject t
]
502 ["Toggle Tick Mark" mh-show-toggle-tick t
]
504 ["Push State Out to MH" mh-show-update-sequences t
]))
509 mh-show-message-menu mh-show-mode-map
"Menu for MH-E folder-message."
511 ["Show Message" mh-show-show t
]
512 ["Show Message with Header" mh-show-header-display t
]
513 ["Next Message" mh-show-next-undeleted-msg t
]
514 ["Previous Message" mh-show-previous-undeleted-msg t
]
515 ["Go to First Message" mh-show-first-msg t
]
516 ["Go to Last Message" mh-show-last-msg t
]
517 ["Go to Message by Number..." mh-show-goto-msg t
]
518 ["Modify Message" mh-show-modify t
]
519 ["Delete Message" mh-show-delete-msg t
]
520 ["Refile Message" mh-show-refile-msg t
]
521 ["Undo Delete/Refile" mh-show-undo t
]
522 ["Process Delete/Refile" mh-show-execute-commands t
]
524 ["Compose a New Message" mh-send t
]
525 ["Reply to Message..." mh-show-reply t
]
526 ["Forward Message..." mh-show-forward t
]
527 ["Redistribute Message..." mh-show-redistribute t
]
528 ["Edit Message Again" mh-show-edit-again t
]
529 ["Re-edit a Bounced Message" mh-show-extract-rejected-mail t
]
531 ["Copy Message to Folder..." mh-show-copy-msg t
]
532 ["Print Message" mh-show-print-msg t
]
533 ["Write Message to File..." mh-show-write-msg-to-file t
]
534 ["Pipe Message to Command..." mh-show-pipe-msg t
]
535 ["Unpack Uuencoded Message..." mh-show-store-msg t
]
536 ["Burst Digest Message" mh-show-burst-digest t
]))
541 mh-show-folder-menu mh-show-mode-map
"Menu for MH-E folder."
543 ["Incorporate New Mail" mh-show-inc-folder t
]
544 ["Toggle Show/Folder" mh-show-toggle-showing t
]
545 ["Execute Delete/Refile" mh-show-execute-commands t
]
546 ["Rescan Folder" mh-show-rescan-folder t
]
547 ["Thread Folder" mh-show-toggle-threads t
]
548 ["Pack Folder" mh-show-pack-folder t
]
549 ["Sort Folder" mh-show-sort-folder t
]
551 ["List Folders" mh-show-list-folders t
]
552 ["Visit a Folder..." mh-show-visit-folder t
]
553 ["View New Messages" mh-show-index-new-messages t
]
554 ["Search..." mh-search t
]
556 ["Quit MH-E" mh-quit t
]))
562 (gnus-define-keys mh-show-mode-map
564 "!" mh-show-refile-or-write-again
565 "'" mh-show-toggle-tick
566 "," mh-show-header-display
568 ">" mh-show-write-message-to-file
570 "E" mh-show-extract-rejected-mail
572 "\177" mh-show-previous-page
573 "\C-d" mh-show-delete-msg-no-motion
574 "\t" mh-show-next-button
575 [backtab] mh-show-prev-button
576 "\M-\t" mh-show-prev-button
577 "\ed" mh-show-redistribute
578 "^" mh-show-refile-msg
580 "d" mh-show-delete-msg
581 "e" mh-show-edit-again
584 "i" mh-show-inc-folder
585 "k" mh-show-delete-subject-or-thread
587 "n" mh-show-next-undeleted-msg
588 "\M-n" mh-show-next-unread-msg
589 "o" mh-show-refile-msg
590 "p" mh-show-previous-undeleted-msg
591 "\M-p" mh-show-previous-unread-msg
595 "t" mh-show-toggle-showing
597 "x" mh-show-execute-commands
598 "v" mh-show-index-visit-folder
599 "|" mh-show-pipe-msg)
601 (gnus-define-keys (mh-show-folder-map "F" mh-show-mode-map)
603 "'" mh-index-ticked-messages
604 "S" mh-show-sort-folder
606 "f" mh-show-visit-folder
607 "k" mh-show-kill-folder
608 "l" mh-show-list-folders
609 "n" mh-index-new-messages
610 "o" mh-show-visit-folder
611 "q" mh-show-index-sequenced-messages
612 "r" mh-show-rescan-folder
614 "t" mh-show-toggle-threads
615 "u" mh-show-undo-folder
616 "v" mh-show-visit-folder)
618 (gnus-define-keys (mh-show-sequence-map "S" mh-show-mode-map)
619 "'" mh-show-narrow-to-tick
621 "d" mh-show-delete-msg-from-seq
622 "k" mh-show-delete-seq
623 "l" mh-show-list-sequences
624 "n" mh-show-narrow-to-seq
625 "p" mh-show-put-msg-in-seq
626 "s" mh-show-msg-is-in-seq
629 (define-key mh-show-mode-map "I" mh-inc-spool-map)
631 (gnus-define-keys (mh-show-junk-map "J" mh-show-mode-map)
633 "b" mh-show-junk-blacklist
634 "w" mh-show-junk-whitelist)
636 (gnus-define-keys (mh-show-ps-print-map "P" mh-show-mode-map)
638 "C" mh-show-ps-print-toggle-color
639 "F" mh-show-ps-print-toggle-faces
640 "f" mh-show-ps-print-msg-file
641 "l" mh-show-print-msg
642 "p" mh-show-ps-print-msg)
644 (gnus-define-keys (mh-show-thread-map "T" mh-show-mode-map)
646 "u" mh-show-thread-ancestor
647 "p" mh-show-thread-previous-sibling
648 "n" mh-show-thread-next-sibling
649 "t" mh-show-toggle-threads
650 "d" mh-show-thread-delete
651 "o" mh-show-thread-refile)
653 (gnus-define-keys (mh-show-limit-map "/" mh-show-mode-map)
654 "'" mh-show-narrow-to-tick
656 "c" mh-show-narrow-to-cc
657 "g" mh-show-narrow-to-range
658 "m" mh-show-narrow-to-from
659 "s" mh-show-narrow-to-subject
660 "t" mh-show-narrow-to-to
663 (gnus-define-keys (mh-show-extract-map "X" mh-show-mode-map)
665 "s" mh-show-store-msg
666 "u" mh-show-store-msg)
668 (gnus-define-keys (mh-show-digest-map "D" mh-show-mode-map)
670 " " mh-show-page-digest
671 "\177" mh-show-page-digest-backwards
672 "b" mh-show-burst-digest)
674 (gnus-define-keys (mh-show-mime-map "K" mh-show-mode-map)
676 "a" mh-mime-save-parts
677 "e" mh-show-display-with-external-viewer
678 "v" mh-show-toggle-mime-part
679 "o" mh-show-save-mime-part
680 "i" mh-show-inline-mime-part
681 "t" mh-show-toggle-mime-buttons
682 "\t" mh-show-next-button
683 [backtab] mh-show-prev-button
684 "\M-\t" mh-show-prev-button
)
688 ;;; MH-Show Font Lock
690 (defun mh-header-field-font-lock (field limit
)
691 "Return the value of a header field FIELD to font-lock.
692 Argument LIMIT limits search."
693 (if (= (point) limit
)
695 (let* ((mail-header-end (mh-mail-header-end))
696 (lesser-limit (if (< mail-header-end limit
) mail-header-end limit
))
697 (case-fold-search t
))
698 (when (and (< (point) mail-header-end
) ;Only within header
699 (re-search-forward (format "^%s" field
) lesser-limit t
))
700 (let ((match-one-b (match-beginning 0))
701 (match-one-e (match-end 0)))
702 (mh-header-field-end)
703 (if (> (point) limit
) ;Don't search for end beyond limit
705 (set-match-data (list match-one-b match-one-e
706 (1+ match-one-e
) (point)))
709 (defun mh-header-to-font-lock (limit)
710 "Return the value of a header field To to font-lock.
711 Argument LIMIT limits search."
712 (mh-header-field-font-lock "To:" limit
))
714 (defun mh-header-cc-font-lock (limit)
715 "Return the value of a header field cc to font-lock.
716 Argument LIMIT limits search."
717 (mh-header-field-font-lock "cc:" limit
))
719 (defun mh-header-subject-font-lock (limit)
720 "Return the value of a header field Subject to font-lock.
721 Argument LIMIT limits search."
722 (mh-header-field-font-lock "Subject:" limit
))
724 (defun mh-letter-header-font-lock (limit)
725 "Return the entire mail header to font-lock.
726 Argument LIMIT limits search."
727 (if (= (point) limit
)
729 (let* ((mail-header-end (save-match-data (mh-mail-header-end)))
730 (lesser-limit (if (< mail-header-end limit
) mail-header-end limit
)))
731 (when (mh-in-header-p)
732 (set-match-data (list 1 lesser-limit
))
733 (goto-char lesser-limit
)
736 (defun mh-show-font-lock-fontify-region (beg end loudly
)
737 "Limit font-lock in `mh-show-mode' to the header.
739 Used when the option `mh-highlight-citation-style' is set to
740 \"Gnus\", leaving the body to be dealt with by Gnus highlighting.
741 The region between BEG and END is given over to be fontified and
742 LOUDLY controls if a user sees a message about the fontification
744 (let ((header-end (mh-mail-header-end)))
746 ((and (< beg header-end
)(< end header-end
))
747 (font-lock-default-fontify-region beg end loudly
))
748 ((and (< beg header-end
)(>= end header-end
))
749 (font-lock-default-fontify-region beg header-end loudly
))
753 (defvar mh-show-font-lock-keywords
754 '(("^\\(From:\\|Sender:\\)\\(.*\\)"
757 (mh-header-to-font-lock
760 (mh-header-cc-font-lock
763 ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$"
766 (mh-header-subject-font-lock
768 (1 'mh-show-subject
))
769 ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)"
772 ("^\\(In-reply-to\\|Date\\):\\(.*\\)$"
775 (mh-letter-header-font-lock
776 (0 'mh-show-header append t
)))
777 "Additional expressions to highlight in MH-Show buffers.")
780 (defun mh-show-font-lock-keywords ()
781 "Return variable `mh-show-font-lock-keywords'."
782 mh-show-font-lock-keywords
)
784 (defvar mh-show-font-lock-keywords-with-cite
785 (let* ((cite-chars "[>|}]")
786 (cite-prefix "A-Za-z")
787 (cite-suffix (concat cite-prefix
"0-9_.@-`'\"")))
789 mh-show-font-lock-keywords
791 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
793 (,(concat "\\=[ \t]*"
794 "\\(\\([" cite-prefix
"]+[" cite-suffix
"]*\\)?"
795 "\\(" cite-chars
"[ \t]*\\)\\)+"
797 (beginning-of-line) (end-of-line)
798 (2 font-lock-constant-face nil t
)
799 (4 font-lock-comment-face nil t
))))))
800 "Additional expressions to highlight in MH-Show buffers.")
803 (defun mh-show-font-lock-keywords-with-cite ()
804 "Return variable `mh-show-font-lock-keywords-with-cite'."
805 mh-show-font-lock-keywords-with-cite
)
811 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
812 (put 'mh-show-mode
'mode-class
'special
)
815 (eval-when-compile (defvar font-lock-auto-fontify
))
818 (define-derived-mode mh-show-mode text-mode
"MH-Show"
819 "Major mode for showing messages in MH-E.\\<mh-show-mode-map>
821 The hook `mh-show-mode-hook' is called upon entry to this mode.
823 See also `mh-folder-mode'.
825 \\{mh-show-mode-map}"
826 (set (make-local-variable 'mail-header-separator
) mh-mail-header-separator
)
827 (setq paragraph-start
(default-value 'paragraph-start
))
828 (mh-show-unquote-From)
831 (setq buffer-invisibility-spec
'((vanish . t
) t
))
832 (set (make-local-variable 'line-move-ignore-invisible
) t
)
833 (make-local-variable 'font-lock-defaults
)
834 ;;(set (make-local-variable 'font-lock-support-mode) nil)
836 ((equal mh-highlight-citation-style
'font-lock
)
837 (setq font-lock-defaults
'(mh-show-font-lock-keywords-with-cite t
)))
838 ((equal mh-highlight-citation-style
'gnus
)
839 (setq font-lock-defaults
'((mh-show-font-lock-keywords)
841 (font-lock-fontify-region-function
842 . mh-show-font-lock-fontify-region
)))
843 (mh-gnus-article-highlight-citation))
845 (setq font-lock-defaults
'(mh-show-font-lock-keywords t
))))
846 (if (and mh-xemacs-flag
847 font-lock-auto-fontify
)
849 (set (make-local-variable 'tool-bar-map
) mh-show-tool-bar-map
)
850 (mh-funcall-if-exists mh-tool-bar-init
:show
)
851 (when mh-decode-mime-flag
852 (mh-make-local-hook 'kill-buffer-hook
)
853 (add-hook 'kill-buffer-hook
'mh-mime-cleanup nil t
))
854 (easy-menu-add mh-show-sequence-menu
)
855 (easy-menu-add mh-show-message-menu
)
856 (easy-menu-add mh-show-folder-menu
)
857 (make-local-variable 'mh-show-folder-buffer
)
858 (buffer-disable-undo)
859 (setq buffer-read-only t
)
860 (use-local-map mh-show-mode-map
))
866 (defun mh-show-unquote-From ()
867 "Decode >From at beginning of lines for `mh-show-mode'."
869 (let ((modified (buffer-modified-p))
870 (case-fold-search nil
)
871 (buffer-read-only nil
))
872 (goto-char (mh-mail-header-end))
873 (while (re-search-forward "^>From" nil t
)
874 (replace-match "From"))
875 (set-buffer-modified-p modified
))))
878 (defun mh-show-addr ()
879 "Use `goto-address'."
880 (when mh-show-use-goto-addr-flag
881 (require 'goto-addr nil t
)
882 (if (fboundp 'goto-address
)
886 (defun mh-gnus-article-highlight-citation ()
887 "Highlight cited text in current buffer using Gnus."
889 ;; Don't allow Gnus to create buttons while highlighting, maybe this is bad
891 (flet ((gnus-article-add-button (&rest args
) nil
))
892 (let* ((modified (buffer-modified-p))
893 (gnus-article-buffer (buffer-name))
894 (gnus-cite-face-list `(,@(cdr gnus-cite-face-list
)
895 ,(car gnus-cite-face-list
))))
896 (gnus-article-highlight-citation t
)
897 (set-buffer-modified-p modified
))))
902 ;; indent-tabs-mode: nil
903 ;; sentence-end-double-space: nil
906 ;; arch-tag: 8607a80a-9b5c-43a7-a25d-d7e4a848c25b
907 ;;; mh-show.el ends here