diff lisp/mh-e/mh-show.el @ 68465:37d03b3298bf

The Great Cleanup Remove circular dependencies. mh-e.el now includes few require statements and stands alone. Other files should need to require mh-e.el, which requires mh-loaddefs.el, plus variable-only files such as mh-scan.el. Remove unneeded require statements. Remove unneeded load statements, or replace them with non-fatal require statements. Break out components into their own files that were often spread between many files. As a result, many functions that are now only used within a single file no longer need to be autoloaded. Rearrange and provide consistent headings. Untabify. * mh-acros.el: Update commentary to reflect current usage. Add autoload cookies to all macros. (mh-require-cl): Merge docstring and comment. (mh-do-in-xemacs): Fix typo in docstring. (assoc-string): Move to new file mh-compat.el. (with-mh-folder-updating, mh-in-show-buffer) (mh-do-at-event-location, mh-seq-msgs): Move here from mh-utils.el. (mh-iterate-on-messages-in-region, mh-iterate-on-range): Move here from mh-seq.el. * mh-alias.el (mh-address-mail-regexp) (mh-goto-address-find-address-at-point): Move here from mh-utils.el. (mh-folder-line-matches-show-buffer-p): Move here from mh-e.el. * mh-buffers.el: Update descriptive text. * mh-comp.el (mh-note-repl, mh-note-forw, mh-note-dist): Move to new file mh-scan.el. (mh-yank-hooks, mh-to-field-choices, mh-position-on-field) (mh-letter-menu, mh-letter-mode-help-messages) (mh-letter-buttons-init-flag, mh-letter-mode) (mh-font-lock-field-data, mh-letter-header-end) (mh-auto-fill-for-letter, mh-to-field, mh-to-fcc) (mh-file-is-vcard-p, mh-insert-signature, mh-check-whom) (mh-insert-letter, mh-extract-from-attribution, mh-yank-cur-msg) (mh-filter-out-non-text, mh-insert-prefix-string) (mh-current-fill-prefix, mh-open-line, mh-complete-word) (mh-folder-expand-at-point, mh-letter-complete-function-alist) (mh-letter-complete, mh-letter-complete-or-space) (mh-letter-confirm-address, mh-letter-header-field-at-point) (mh-letter-next-header-field-or-indent) (mh-letter-next-header-field, mh-letter-previous-header-field) (mh-letter-skipped-header-field-p) (mh-letter-skip-leading-whitespace-in-header-field) (mh-hidden-header-keymap) (mh-letter-toggle-header-field-display-button) (mh-letter-toggle-header-field-display) (mh-letter-truncate-header-field, mh-letter-mode-map): Move to new file mh-letter.el. (mh-letter-mode-map, mh-sent-from-folder, mh-send-args) (mh-pgp-support-flag, mh-x-mailer-string) (mh-letter-header-field-regexp): Move to mh-e.el. (mh-goto-header-field, mh-goto-header-end) (mh-extract-from-header-value, mh-beginning-of-word): Move to mh-utils.el. (mh-insert-header-separator): Move to mh-comp.el. (mh-display-completion-list-compat): Move to new file mh-compat.el. * mh-compat.el: New file. (assoc-string): Move here from mh-acros.el. (mh-display-completion-list): Move here from mh-comp.el. * mh-customize.el: Move content into mh-e.el and remove. * mh-e.el (mh-folder-mode-map, mh-folder-seq-tool-bar-map) (mh-folder-tool-bar-map, mh-inc-spool-map, mh-letter-mode-map) (mh-letter-tool-bar-map, mh-search-mode-map, mh-show-mode-map) (mh-show-seq-tool-bar-map, mh-show-tool-bar-map): All maps now declared here so that they can be used in docstrings. (mh-sent-from-folder, mh-sent-from-msg) (mh-letter-header-field-regexp, mh-pgp-support-flag) (mh-x-mailer-string): Move here from mh-comp.el. (mh-folder-line-matches-show-buffer-p): Move to mh-alias.el. (mh-thread-scan-line-map, mh-thread-scan-line-map-stack): Move here from mh-seq.el. (mh-draft-folder, mh-inbox, mh-user-path, mh-current-folder) (mh-previous-window-config, mh-seen-list, mh-seq-list) (mh-show-buffer, mh-showing-mode, mh-globals-hash) (mh-show-folder-buffer, mh-mail-header-separator) (mh-unseen-seq, mh-previous-seq, mh-page-to-next-msg-flag) (mh-signature-separator, mh-signature-separator-regexp) (mh-list-to-string, mh-list-to-string-1): Move here from mh-utils.el. (mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell) (mh-exec-cmd, mh-exec-cmd-error, mh-exec-cmd-daemon) (mh-exec-cmd-env-daemon, mh-process-daemon, mh-exec-cmd-quiet) (mh-exec-cmd-output) (mh-exchange-point-and-mark-preserving-active-mark) (mh-exec-lib-cmd-output, mh-handle-process-error): Move here from deprecated file mh-exec.el. (mh-path): Move here from deprecated file mh-customize.el. (mh-sys-path, mh-variants, mh-variant-in-use, mh-progs, mh-lib) (mh-flists-present-flag, mh-variants, mh-variant-mh-info) (mh-variant-mu-mh-info, mh-variant-nmh-info, mh-file-command-p) (mh-variant-set-variant, mh-variant-p, mh-profile-component) (mh-profile-component-value, mh-defface-compat): Move here from deprecated file mh-init.el. (mh-goto-next-button, mh-folder-mime-action) (mh-folder-toggle-mime-part, mh-folder-inline-mime-part) (mh-folder-save-mime-part, mh-toggle-mime-buttons): Move to to mh-mime.el. (mh-scan-format-mh, mh-scan-format-nmh, mh-note-deleted) (mh-note-refiled, mh-note-cur, mh-scan-good-msg-regexp) (mh-scan-deleted-msg-regexp, mh-scan-refiled-msg-regexp) (mh-scan-valid-regexp, mh-scan-cur-msg-number-regexp) (mh-scan-date-regexp, mh-scan-rcpt-regexp, mh-scan-body-regexp) (mh-scan-subject-regexp, mh-scan-sent-to-me-sender-regexp) (mh-scan-cmd-note-width, mh-scan-destination-width) (mh-scan-date-width, mh-scan-date-flag-width) (mh-scan-from-mbox-width, mh-scan-from-mbox-sep-width) (mh-scan-field-destination-offset) (mh-scan-field-from-start-offset, mh-scan-field-from-end-offset) (mh-scan-field-subject-start-offset, mh-scan-format) (mh-msg-num-width-to-column, mh-set-cmd-note): Move to new file mh-scan.el. (mh-partial-folder-mode-line-annotation) (mh-folder-font-lock-keywords, mh-folder-font-lock-subject) (mh-generate-sequence-font-lock, mh-last-destination) (mh-last-destination-write, mh-first-msg-num, mh-last-msg-num) (mh-rmail, mh-nmail, mh-delete-msg, mh-delete-msg-no-motion) (mh-execute-commands, mh-first-msg, mh-header-display) (mh-inc-folder, mh-last-msg, mh-next-undeleted-msg) (mh-folder-from-address, mh-prompt-for-refile-folder) (mh-refile-msg, mh-refile-or-write-again, mh-quit, mh-page-msg) (mh-previous-page, mh-previous-undeleted-msg) (mh-previous-unread-msg, mh-next-button, mh-prev-button) (mh-reset-threads-and-narrowing, mh-rescan-folder) (mh-write-msg-to-file, mh-toggle-showing, mh-undo) (mh-visit-folder, mh-update-sequences, mh-delete-a-msg) (mh-refile-a-msg, mh-next-msg, mh-next-unread-msg) (mh-set-scan-mode, mh-undo-msg, mh-make-folder) (mh-folder-sequence-menu, mh-folder-message-menu) (mh-folder-folder-menu, mh-remove-xemacs-horizontal-scrollbar) (mh-write-file-functions-compat, mh-folder-mode) (mh-restore-desktop-buffer, mh-scan-folder) (mh-regenerate-headers, mh-generate-new-cmd-note) (mh-get-new-mail, mh-make-folder-mode-line, mh-goto-cur-msg) (mh-process-or-undo-commands, mh-process-commands) (mh-update-unseen, mh-delete-scan-msgs) (mh-outstanding-commands-p): Move to new file mh-folder.el. (mh-mapc, mh-colors-available-p, mh-colors-in-use-p) (mh-make-local-vars, mh-coalesce-msg-list, mh-greaterp) (mh-lessp): Move to mh-utils.el. (mh-parse-flist-output-line, mh-folder-size-folder) (mh-folder-size-flist, mh-folder-size, mh-add-sequence-notation) (mh-remove-sequence-notation, mh-remove-cur-notation) (mh-remove-all-notation, mh-delete-seq-locally) (mh-read-folder-sequences, mh-read-msg-list) (mh-notate-user-sequences, mh-internal-seqs, mh-internal-seq) (mh-valid-seq-p, mh-delete-msg-from-seq, mh-catchup) (mh-delete-a-msg-from-seq, mh-undefine-sequence) (mh-define-sequence, mh-seq-containing-msg): Move to mh-seq.el. (mh-xemacs-flag) (mh-customize, mh-e, mh-alias, mh-folder, mh-folder-selection) (mh-identity, mh-inc, mh-junk, mh-letter, mh-ranges) (mh-scan-line-formats, mh-search, mh-sending-mail, mh-sequences) (mh-show, mh-speedbar, mh-thread, mh-tool-bar, mh-hooks) (mh-faces, mh-alias-completion-ignore-case-flag) (mh-alias-expand-aliases-flag, mh-alias-flash-on-comma) (mh-alias-insert-file, mh-alias-insertion-location) (mh-alias-local-users, mh-alias-local-users-prefix) (mh-alias-passwd-gecos-comma-separator-flag) (mh-new-messages-folders, mh-ticked-messages-folders) (mh-large-folder, mh-recenter-summary-flag) (mh-recursive-folders-flag, mh-sortm-args) (mh-default-folder-for-message-function, mh-default-folder-list) (mh-default-folder-must-exist-flag, mh-default-folder-prefix) (mh-identity-list, mh-auto-fields-list) (mh-auto-fields-prompt-flag, mh-identity-default) (mh-identity-handlers, mh-inc-prog, mh-inc-spool-list) (mh-junk-choice, mh-junk-function-alist, mh-junk-choose) (mh-junk-background, mh-junk-disposition, mh-junk-program) (mh-compose-insertion, mh-compose-skipped-header-fields) (mh-compose-space-does-completion-flag) (mh-delete-yanked-msg-window-flag) (mh-extract-from-attribution-verb, mh-ins-buf-prefix) (mh-letter-complete-function, mh-letter-fill-column) (mh-mml-method-default, mh-signature-file-name) (mh-signature-separator-flag, mh-x-face-file, mh-yank-behavior) (mh-interpret-number-as-range-flag, mh-adaptive-cmd-note-flag) (mh-scan-format-file-check, mh-scan-format-file) (mh-adaptive-cmd-note-flag-check, mh-scan-prog) (mh-search-program, mh-compose-forward-as-mime-flag) (mh-compose-letter-function, mh-compose-prompt-flag) (mh-forward-subject-format, mh-insert-x-mailer-flag) (mh-redist-full-contents-flag, mh-reply-default-reply-to) (mh-reply-show-message-flag, mh-refile-preserves-sequences-flag) (mh-tick-seq, mh-update-sequences-after-mh-show-flag) (mh-bury-show-buffer-flag, mh-clean-message-header-flag) (mh-decode-mime-flag, mh-display-buttons-for-alternatives-flag) (mh-display-buttons-for-inline-parts-flag) (mh-do-not-confirm-flag, mh-fetch-x-image-url) (mh-graphical-smileys-flag, mh-graphical-emphasis-flag) (mh-highlight-citation-style) (mh-invisible-header-fields-internal) (mh-delay-invisible-header-generation-flag) (mh-invisible-header-fields, mh-invisible-header-fields-default) (mh-invisible-header-fields-compiled, mh-invisible-headers) (mh-lpr-command-format, mh-max-inline-image-height) (mh-max-inline-image-width, mh-mhl-format-file) (mh-mime-save-parts-default-directory, mh-print-background-flag) (mh-show-maximum-size, mh-show-use-goto-addr-flag) (mh-show-use-xface-flag, mh-store-default-directory) (mh-summary-height, mh-speed-update-interval) (mh-show-threads-flag, mh-tool-bar-search-function) (mh-after-commands-processed-hook, mh-alias-reloaded-hook) (mh-before-commands-processed-hook, mh-before-quit-hook) (mh-before-send-letter-hook, mh-delete-msg-hook) (mh-find-path-hook, mh-folder-mode-hook, mh-forward-hook) (mh-inc-folder-hook, mh-insert-signature-hook) (mh-kill-folder-suppress-prompt-hooks, mh-letter-mode-hook) (mh-mh-to-mime-hook, mh-search-mode-hook, mh-quit-hook) (mh-refile-msg-hook, mh-show-hook, mh-show-mode-hook) (mh-unseen-updated-hook, mh-min-colors-defined-flag) (mh-folder-address, mh-folder-body) (mh-folder-cur-msg-number, mh-folder-date, mh-folder-deleted) (mh-folder-followup, mh-folder-msg-number, mh-folder-refiled) (mh-folder-sent-to-me-hint, mh-folder-sent-to-me-sender) (mh-folder-subject, mh-folder-tick, mh-folder-to) (mh-search-folder, mh-letter-header-field, mh-show-cc) (mh-show-date, mh-show-from, mh-show-header, mh-show-pgg-bad) (mh-show-pgg-good, mh-show-pgg-unknown, mh-show-signature) (mh-show-subject, mh-show-to, mh-show-xface, mh-speedbar-folder) (mh-speedbar-folder-with-unseen-messages) (mh-speedbar-selected-folder) (mh-speedbar-selected-folder-with-unseen-messages): Move here from deprecated file mh-customize.el. * mh-exec.el: Move content into mh-e.el and remove. * mh-folder.el: New file. Contains mh-folder-mode from mh-e.el * mh-funcs.el (mh-note-copied, mh-note-printed): Move to new file mh-scan.el. (mh-ephem-message, mh-help, mh-prefix-help): Move to mh-utils.el. * mh-gnus.el (mm-uu-dissect-text-parts): Add. (mh-mail-abbrev-make-syntax-table): Move to mh-utils.el and rename to mail-abbrev-make-syntax-table. * mh-identity.el (mh-identity-menu): New variable for existing menu. (mh-identity-make-menu-no-autoload): New alias for mh-identity-make-menu which can be called from mh-e.el. (mh-identity-list-set): Move to mh-e.el. (mh-identity-add-menu): New function (mh-insert-identity): Add optional argument maybe-insert so that local variable mh-identity-local does not have to be visible. (mh-identity-handler-default): * mh-inc.el (mh-inc-spool-map): Move declaration to mh-e.el (with rest of keymaps). Update key binding for ? to call mh-help with help messages in new argument. (mh-inc-spool-make-no-autoload): New alias for mh-inc-spool-make which can be called from mh-e.el. (mh-inc-spool-list-set): Simplify update of mh-inc-spool-map-help. * mh-init.el: Move content into mh-e.el and remove. * mh-junk.el: Update requires, untabify, and add mh-autoload cookies. * mh-letter.el: New file. Contains mh-letter-mode from mh-comp.el. * mh-limit.el: New file. Contains display limit commands from mh-mime.el. * mh-mime.el: Rearrange for consistency with other files. (mh-buffer-data, mh-mm-inline-media-tests): Move here from mh-utils.el. (mh-folder-inline-mime-part, mh-folder-save-mime-part) (mh-folder-toggle-mime-part, mh-toggle-mime-buttons) (mh-goto-next-button): Move here from mh-e.el. * mh-print.el: Rearrange for consistency with other files. * mh-scan.el: New file. Contains scan line constants and utilities from XXX, mh-funcs, mh-utils.el. * mh-search.el: Rearrange for consistency with other files. (mh-search-mode-map): Drop C-c C-f {dr} bindings since these fields which don't exist in the saved header. Replace C-c C-f f with C-c C-f m per mail-mode consistency. (mh-search-mode): Use mh-set-help instead of setting mh-help-messages. * mh-seq.el (mh-thread-message, mh-thread-container) (mh-thread-id-hash, mh-thread-subject-hash, mh-thread-id-table) (mh-thread-id-index-map, mh-thread-index-id-map) (mh-thread-scan-line-map, mh-thread-scan-line-map-stack) (mh-thread-subject-container-hash, mh-thread-duplicates) (mh-thread-history, mh-thread-body-width) (mh-thread-find-msg-subject mh-thread-initialize-hash) (mh-thread-initialize, mh-thread-id-container) (mh-thread-remove-parent-link, mh-thread-add-link) (mh-thread-ancestor-p, mh-thread-get-message-container) (mh-thread-get-message, mh-thread-canonicalize-id) (mh-thread-prune-subject, mh-thread-container-subject) (mh-thread-rewind-pruning, mh-thread-prune-containers) (mh-thread-sort-containers, mh-thread-group-by-subject) (mh-thread-process-in-reply-to, mh-thread-set-tables) (mh-thread-update-id-index-maps, mh-thread-generate) (mh-thread-inc, mh-thread-generate-scan-lines) (mh-thread-parse-scan-line, mh-thread-update-scan-line-map) (mh-thread-add-spaces, mh-thread-print-scan-lines) (mh-thread-folder, mh-toggle-threads, mh-thread-forget-message) (mh-thread-current-indentation-level, mh-thread-next-sibling) (mh-thread-previous-sibling, mh-thread-immediate-ancestor) (mh-thread-ancestor, mh-thread-find-children) (mh-message-id-regexp, mh-thread-delete, mh-thread-refile): Move to new file mh-thread.el. (mh-subject-to-sequence, mh-subject-to-sequence-unthreaded) (mh-subject-to-sequence-threaded, mh-edit-pick-expr) (mh-pick-args-list, mh-narrow-to-subject, mh-narrow-to-from) (mh-narrow-to-cc, mh-narrow-to-to, mh-narrow-to-header-field) (mh-current-message-header-field, mh-narrow-to-range) (mh-delete-subject, mh-delete-subject-or-thread): Move to new file mh-limit.el. (mh-iterate-on-messages-in-region, mh-iterate-on-range): Move to mh-acros.el. (mh-internal-seqs, mh-catchup, mh-delete-msg-from-seq) (mh-internal-seq, mh-valid-seq-p, mh-seq-containing-msg) (mh-define-sequence, mh-undefine-sequence) (mh-delete-a-msg-from-seq, mh-delete-seq-locally) (mh-folder-size, mh-folder-size-flist, mh-folder-size-folder) (mh-parse-flist-output-line, mh-read-folder-sequences) (mh-read-msg-list, mh-notate-user-sequences) (mh-remove-cur-notation, mh-add-sequence-notation) (mh-remove-sequence-notation, mh-remove-all-notation): Move here from mh-e.el. (mh-make-seq, mh-seq-name, mh-find-seq, mh-seq-to-msgs) (mh-add-msgs-to-seq, mh-notate): Move here from mh-utils.el. * mh-show.el: New file. Contains mh-show-mode from mh-utils.el. * mh-speed.el: Rearrange for consistency with other files. * mh-thread.el: New file. Contains threading code from mh-seq.el. * mh-tool-bar.el: New file. Contains tool bar creation code from deprecated file mh-customize.el. * mh-utils.el (recursive-load-depth-limit): Remove setting. No longer needed. (mh-scan-msg-number-regexp, mh-scan-msg-overflow-regexp) (mh-scan-msg-format-regexp, mh-scan-msg-format-string) (mh-scan-msg-search-regexp, mh-cmd-note, mh-note-seq) (mh-update-scan-format, mh-msg-num-width): Move to new file mh-scan.el. (mh-show-buffer-mode-line-buffer-id, mh-letter-header-font-lock) (mh-header-field-font-lock, mh-header-to-font-lock) (mh-header-cc-font-lock, mh-header-subject-font-lock) (mh-show-font-lock-keywords) (mh-show-font-lock-keywords-with-cite) (mh-show-font-lock-fontify-region) (mh-gnus-article-highlight-citation, mh-showing-with-headers) (mh-start-of-uncleaned-message, mh-invalidate-show-buffer) (mh-unvisit-file, mh-defun-show-buffer, mh-show-mode-map) (mh-show-sequence-menu, mh-show-message-menu) (mh-show-folder-menu, mh-show-mode, mh-show-addr) (mh-maybe-show, mh-show, mh-show-msg, mh-show-unquote-From) (mh-msg-folder, mh-display-msg, mh-clean-msg-header): Move to new file mh-show.el. (mh-mail-header-separator, mh-signature-separator-regexp) (mh-signature-separator, mh-globals-hash, mh-user-path) (mh-draft-folder, mh-unseen-seq, mh-previous-seq, mh-inbox) (mh-previous-window-config, mh-current-folder mh-show-buffer) (mh-showing-mode, mh-show-mode-map, mh-show-folder-buffer) (mh-showing-mode, mh-seq-list, mh-seen-list, mh-summary-height) (mh-list-to-string, mh-list-to-string-1): Move to mh-e.el. (mh-buffer-data, mh-mm-inline-media-tests): Move to mh-mime.el. (mh-address-mail-regexp, mh-goto-address-find-address-at-point): Move to mh-alias.el. (mh-letter-font-lock-keywords): Move to new file mh-letter.el. (mh-folder-filename, mh-msg-count, mh-recenter, mh-msg-filename) (mh-show-mouse, mh-modify, mh-goto-msg, mh-set-folder-modified-p): Move to new file mh-folder.el. (with-mh-folder-updating, mh-in-show-buffer) (mh-do-at-event-location, mh-seq-msgs): Moved to mh-acros.el. (mh-make-seq, mh-seq-name, mh-notate, mh-find-seq) (mh-seq-to-msgs, mh-add-msgs-to-seq, mh-canonicalize-sequence): Moved to mh-seq.el. (mh-show-xface-function, mh-uncompface-executable, mh-face-to-png) (mh-uncompface, mh-icontopbm, mh-face-foreground-compat) (mh-face-background-compat, mh-face-display-function) (mh-show-xface, mh-picon-directory-list) (mh-picon-existing-directory-list) (mh-picon-cache, mh-picon-image-types) (mh-picon-set-directory-list, mh-picon-get-image) (mh-picon-file-contents, mh-picon-generate-path) (mh-x-image-cache-directory, mh-x-image-scaling-function) (mh-wget-executable, mh-wget-choice, mh-wget-option) (mh-x-image-temp-file, mh-x-image-url, mh-x-image-marker) (mh-x-image-url-cache-file, mh-x-image-scale-with-pnm) (mh-x-image-scale-with-convert) (url-unreserved-chars, url-hexify-string) (mh-x-image-url-cache-canonicalize) (mh-x-image-set-download-state, mh-x-image-get-download-state) (mh-x-image-url-fetch-image, mh-x-image-display) (mh-x-image-scale-and-display, mh-x-image-url-sane-p) (mh-x-image-url-display): Move to new file mh-xface.el. (mh-logo-display): Call mh-image-load-path. (mh-find-path-run, mh-find-path): Move here from deprecated file mh-init.el. (mh-help-messages): Now an alist of modes to an alist of messages. (mh-set-help): New function used to set mh-help-messages (mh-help): Adjust for new format of mh-help-messages. Add help-messages argument. (mh-prefix-help): Refactor to use mh-help. (mh-coalesce-msg-list, mh-greaterp, mh-lessp): Move here from mh-e.el. (mh-clear-sub-folders-cache): New function added to avoid exposing mh-sub-folders-cache variable. * mh-xface.el: New file. Contains X-Face and Face header field display routines from mh-utils.el.
author Bill Wohler <wohler@newt.com>
date Sun, 29 Jan 2006 19:34:57 +0000
parents
children 4bd450a8dbe2
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/mh-e/mh-show.el	Sun Jan 29 19:34:57 2006 +0000
@@ -0,0 +1,906 @@
+;;; mh-show.el --- MH-Show mode
+
+;; Copyright (C) 1993, 1995, 1997,
+;;  2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+;; Author: Bill Wohler <wohler@newt.com>
+;; Maintainer: Bill Wohler <wohler@newt.com>
+;; Keywords: mail
+;; See: mh-e.el
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; Mode for showing messages.
+
+;;; Change Log:
+
+;;; Code:
+
+(require 'mh-e)
+(require 'mh-scan)
+
+(require 'gnus-cite)
+(require 'gnus-util)
+
+(autoload 'mh-make-buffer-data "mh-mime") ;can't be automatically generated
+
+(require 'font-lock)
+
+
+
+;;; MH-Folder Commands
+
+(defvar mh-showing-with-headers nil
+  "If non-nil, MH-Show buffer contains message with all header fields.
+If nil, MH-Show buffer contains message processed normally.")
+
+;;;###mh-autoload
+(defun mh-show (&optional message redisplay-flag)
+  "Display message\\<mh-folder-mode-map>.
+
+If the message under the cursor is already displayed, this command
+scrolls to the beginning of the message. MH-E normally hides a lot of
+the superfluous header fields that mailers add to a message, but if
+you wish to see all of them, use the command \\[mh-header-display].
+
+Two hooks can be used to control how messages are displayed. The
+first hook, `mh-show-mode-hook', is called early on in the
+process of the message display. It is usually used to perform
+some action on the message's content. The second hook,
+`mh-show-hook', is the last thing called after messages are
+displayed. It's used to affect the behavior of MH-E in general or
+when `mh-show-mode-hook' is too early.
+
+From a program, optional argument MESSAGE can be used to display an
+alternative message. The optional argument REDISPLAY-FLAG forces the
+redisplay of the message even if the show buffer was already
+displaying the correct message.
+
+See the \"mh-show\" customization group for a litany of options that
+control what displayed messages look like."
+  (interactive (list nil t))
+  (when (or redisplay-flag
+            (and mh-showing-with-headers
+                 (or mh-mhl-format-file mh-clean-message-header-flag)))
+    (mh-invalidate-show-buffer))
+  (mh-show-msg message))
+
+;;;###mh-autoload
+(defun mh-header-display ()
+  "Display message with all header fields\\<mh-folder-mode-map>.
+
+Use the command \\[mh-show] to show the message normally again."
+  (interactive)
+  (and (not mh-showing-with-headers)
+       (or mh-mhl-format-file mh-clean-message-header-flag)
+       (mh-invalidate-show-buffer))
+  (let ((mh-decode-mime-flag nil)
+        (mh-mhl-format-file nil)
+        (mh-clean-message-header-flag nil))
+    (mh-show-msg nil)
+    (mh-in-show-buffer (mh-show-buffer)
+      (goto-char (point-min))
+      (mh-recenter 0))
+    (setq mh-showing-with-headers t)))
+
+
+
+;;; Support Routines for MH-Folder Commands
+
+;;;###mh-autoload
+(defun mh-maybe-show (&optional msg)
+  "Display message at cursor, but only if in show mode.
+If optional arg MSG is non-nil, display that message instead."
+  (if mh-showing-mode (mh-show msg)))
+
+(defun mh-show-msg (msg)
+  "Show MSG.
+
+The hook `mh-show-hook' is called after the message has been
+displayed."
+  (if (not msg)
+      (setq msg (mh-get-msg-num t)))
+  (mh-showing-mode t)
+  (setq mh-page-to-next-msg-flag nil)
+  (let ((folder mh-current-folder)
+        (folders (list mh-current-folder))
+        (clean-message-header mh-clean-message-header-flag)
+        (show-window (get-buffer-window mh-show-buffer))
+        (display-mime-buttons-flag mh-display-buttons-for-inline-parts-flag))
+    (if (not (eq (next-window (minibuffer-window)) (selected-window)))
+        (delete-other-windows))         ; force ourself to the top window
+    (mh-in-show-buffer (mh-show-buffer)
+      (setq mh-display-buttons-for-inline-parts-flag display-mime-buttons-flag)
+      (if (and show-window
+               (equal (mh-msg-filename msg folder) buffer-file-name))
+          (progn                        ;just back up to start
+            (goto-char (point-min))
+            (if (not clean-message-header)
+                (mh-start-of-uncleaned-message)))
+        (mh-display-msg msg folder)))
+    (if (not (= (1+ (window-height)) (frame-height))) ;not horizontally split
+        (shrink-window (- (window-height) (or mh-summary-height
+                                              (mh-summary-height)))))
+    (mh-recenter nil)
+    ;; The following line is a nop which forces update of the scan line so
+    ;; that font-lock will update it (if needed)...
+    (mh-notate nil nil mh-cmd-note)
+    (if (not (memq msg mh-seen-list))
+        (setq mh-seen-list (cons msg mh-seen-list)))
+    (when mh-update-sequences-after-mh-show-flag
+      (mh-update-sequences)
+      (when mh-index-data
+        (setq folders
+              (append (mh-index-delete-from-sequence mh-unseen-seq (list msg))
+                      folders)))
+      (when (mh-speed-flists-active-p)
+        (apply #'mh-speed-flists t folders)))
+    (run-hooks 'mh-show-hook)))
+
+;;;###mh-autoload
+(defun mh-showing-mode (&optional arg)
+  "Change whether messages should be displayed.
+
+With ARG, display messages iff ARG is positive."
+  (setq mh-showing-mode
+        (if (null arg)
+            (not mh-showing-mode)
+          (> (prefix-numeric-value arg) 0))))
+
+;;;###mh-autoload
+(defun mh-start-of-uncleaned-message ()
+  "Position uninteresting headers off the top of the window."
+  (let ((case-fold-search t))
+    (re-search-forward
+     "^To:\\|^Cc:\\|^From:\\|^Subject:\\|^Date:" nil t)
+    (beginning-of-line)
+    (mh-recenter 0)))
+
+(defvar mh-show-buffer-mode-line-buffer-id "    {show-%s} %d"
+  "Format string to produce `mode-line-buffer-identification' for show buffers.
+
+First argument is folder name. Second is message number.")
+
+;;;###mh-autoload
+(defun mh-display-msg (msg-num folder-name)
+  "Display MSG-NUM of FOLDER-NAME.
+Sets the current buffer to the show buffer."
+  (let ((folder (mh-msg-folder folder-name)))
+    (set-buffer folder)
+    ;; When Gnus uses external displayers it has to keep handles longer. So
+    ;; we will delete these handles when mh-quit is called on the folder. It
+    ;; would be nicer if there are weak pointers in emacs lisp, then we could
+    ;; get the garbage collector to do this for us.
+    (unless (mh-buffer-data)
+      (setf (mh-buffer-data) (mh-make-buffer-data)))
+    ;; Bind variables in folder buffer in case they are local
+    (let ((formfile mh-mhl-format-file)
+          (clean-message-header mh-clean-message-header-flag)
+          (invisible-headers mh-invisible-header-fields-compiled)
+          (visible-headers nil)
+          (msg-filename (mh-msg-filename msg-num folder-name))
+          (show-buffer mh-show-buffer)
+          (mm-inline-media-tests mh-mm-inline-media-tests))
+      (if (not (file-exists-p msg-filename))
+          (error "Message %d does not exist" msg-num))
+      (if (and (> mh-show-maximum-size 0)
+               (> (elt (file-attributes msg-filename) 7)
+                  mh-show-maximum-size)
+               (not (y-or-n-p
+                     (format
+                      "Message %d (%d bytes) exceeds %d bytes. Display it? "
+                      msg-num (elt (file-attributes msg-filename) 7)
+                      mh-show-maximum-size))))
+          (error "Message %d not displayed" msg-num))
+      (set-buffer show-buffer)
+      (cond ((not (equal msg-filename buffer-file-name))
+             (mh-unvisit-file)
+             (setq buffer-read-only nil)
+             ;; Cleanup old mime handles
+             (mh-mime-cleanup)
+             (erase-buffer)
+             ;; Changing contents, so this hook needs to be reinitialized.
+             ;; pgp.el uses this.
+             (if (boundp 'write-contents-hooks) ;Emacs 19
+                 (kill-local-variable 'write-contents-hooks))
+             (if formfile
+                 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
+                                         (if (stringp formfile)
+                                             (list "-form" formfile))
+                                         msg-filename)
+               (insert-file-contents-literally msg-filename))
+             ;; Use mm to display buffer
+             (when (and mh-decode-mime-flag (not formfile))
+               (mh-add-missing-mime-version-header)
+               (setf (mh-buffer-data) (mh-make-buffer-data))
+               (mh-mime-display))
+             (mh-show-mode)
+             ;; Header cleanup
+             (goto-char (point-min))
+             (cond (clean-message-header
+                    (mh-clean-msg-header (point-min)
+                                         invisible-headers
+                                         visible-headers)
+                    (goto-char (point-min)))
+                   (t
+                    (mh-start-of-uncleaned-message)))
+             (mh-decode-message-header)
+             ;; the parts of visiting we want to do (no locking)
+             (or (eq buffer-undo-list t) ;don't save undo info for prev msgs
+                 (setq buffer-undo-list nil))
+             (set-buffer-auto-saved)
+             ;; the parts of set-visited-file-name we want to do (no locking)
+             (setq buffer-file-name msg-filename)
+             (setq buffer-backed-up nil)
+             (auto-save-mode 1)
+             (set-mark nil)
+             (unwind-protect
+                 (when (and mh-decode-mime-flag (not formfile))
+                   (setq buffer-read-only nil)
+                   (mh-display-smileys)
+                   (mh-display-emphasis))
+               (setq buffer-read-only t))
+             (set-buffer-modified-p nil)
+             (setq mh-show-folder-buffer folder)
+             (setq mode-line-buffer-identification
+                   (list (format mh-show-buffer-mode-line-buffer-id
+                                 folder-name msg-num)))
+             (mh-logo-display)
+             (set-buffer folder)
+             (setq mh-showing-with-headers nil))))))
+
+(defun mh-msg-folder (folder-name)
+  "Return the name of the buffer for FOLDER-NAME."
+  folder-name)
+
+;;;###mh-autoload
+(defun mh-clean-msg-header (start invisible-headers visible-headers)
+  "Flush extraneous lines in message header.
+
+Header is cleaned from START to the end of the message header.
+INVISIBLE-HEADERS contains a regular expression specifying lines
+to delete from the header. VISIBLE-HEADERS contains a regular
+expression specifying the lines to display. INVISIBLE-HEADERS is
+ignored if VISIBLE-HEADERS is non-nil."
+  ;; XXX Note that MH-E no longer supports the `mh-visible-headers'
+  ;; variable, so this function could be trimmed of this feature too."
+  (let ((case-fold-search t)
+        (buffer-read-only nil))
+    (save-restriction
+      (goto-char start)
+      (if (search-forward "\n\n" nil 'move)
+          (backward-char 1))
+      (narrow-to-region start (point))
+      (goto-char (point-min))
+      (if visible-headers
+          (while (< (point) (point-max))
+            (cond ((looking-at visible-headers)
+                   (forward-line 1)
+                   (while (looking-at "[ \t]") (forward-line 1)))
+                  (t
+                   (mh-delete-line 1)
+                   (while (looking-at "[ \t]")
+                     (mh-delete-line 1)))))
+        (while (re-search-forward invisible-headers nil t)
+          (beginning-of-line)
+          (mh-delete-line 1)
+          (while (looking-at "[ \t]")
+            (mh-delete-line 1)))))
+    (let ((mh-compose-skipped-header-fields ()))
+      (mh-letter-hide-all-skipped-fields))
+    (unlock-buffer)))
+
+;;;###mh-autoload
+(defun mh-invalidate-show-buffer ()
+  "Invalidate the show buffer so we must update it to use it."
+  (if (get-buffer mh-show-buffer)
+      (save-excursion
+        (set-buffer mh-show-buffer)
+        (mh-unvisit-file))))
+
+(defun mh-unvisit-file ()
+  "Separate current buffer from the message file it was visiting."
+  (or (not (buffer-modified-p))
+      (null buffer-file-name)           ;we've been here before
+      (yes-or-no-p (format "Message %s modified; flush changes? "
+                           (file-name-nondirectory buffer-file-name)))
+      (error "Flushing changes not confirmed"))
+  (clear-visited-file-modtime)
+  (unlock-buffer)
+  (setq buffer-file-name nil))
+
+(defun mh-summary-height ()
+  "Return ideal value for the variable `mh-summary-height'.
+The current frame height is taken into consideration."
+  (or (and (fboundp 'frame-height)
+           (> (frame-height) 24)
+           (min 10 (/ (frame-height) 6)))
+      4))
+
+
+
+;; Infrastructure to generate show-buffer functions from folder functions
+;; XEmacs does not have deactivate-mark? What is the equivalent of
+;; transient-mark-mode for XEmacs? Should we be restoring the mark in the
+;; folder buffer after the operation has been carried out.
+(defmacro mh-defun-show-buffer (function original-function
+                                         &optional dont-return)
+  "Define FUNCTION to run ORIGINAL-FUNCTION in folder buffer.
+If the buffer we start in is still visible and DONT-RETURN is nil
+then switch to it after that."
+  `(defun ,function ()
+     ,(format "Calls %s from the message's folder.\n%s\nSee \"%s\" for more info.\n"
+              original-function
+              (if dont-return ""
+                "When function completes, returns to the show buffer if it is
+still visible.\n")
+              original-function)
+     (interactive)
+     (when (buffer-live-p (get-buffer mh-show-folder-buffer))
+       (let ((config (current-window-configuration))
+             (folder-buffer mh-show-folder-buffer)
+             (normal-exit nil)
+             ,@(if dont-return () '((cur-buffer-name (buffer-name)))))
+         (pop-to-buffer mh-show-folder-buffer nil)
+         (unless (equal (buffer-name
+                         (window-buffer (frame-first-window (selected-frame))))
+                        folder-buffer)
+           (delete-other-windows))
+         (mh-goto-cur-msg t)
+         (mh-funcall-if-exists deactivate-mark)
+         (unwind-protect
+             (prog1 (call-interactively (function ,original-function))
+               (setq normal-exit t))
+           (mh-funcall-if-exists deactivate-mark)
+           (when (eq major-mode 'mh-folder-mode)
+             (mh-funcall-if-exists hl-line-highlight))
+           (cond ((not normal-exit)
+                  (set-window-configuration config))
+                 ,(if dont-return
+                      `(t (setq mh-previous-window-config config))
+                    `((and (get-buffer cur-buffer-name)
+                           (window-live-p (get-buffer-window
+                                           (get-buffer cur-buffer-name))))
+                      (pop-to-buffer (get-buffer cur-buffer-name) nil)))))))))
+
+;; Generate interactive functions for the show buffer from the corresponding
+;; folder functions.
+(mh-defun-show-buffer mh-show-previous-undeleted-msg
+                      mh-previous-undeleted-msg)
+(mh-defun-show-buffer mh-show-next-undeleted-msg
+                      mh-next-undeleted-msg)
+(mh-defun-show-buffer mh-show-quit mh-quit)
+(mh-defun-show-buffer mh-show-delete-msg mh-delete-msg)
+(mh-defun-show-buffer mh-show-refile-msg mh-refile-msg)
+(mh-defun-show-buffer mh-show-undo mh-undo)
+(mh-defun-show-buffer mh-show-execute-commands mh-execute-commands)
+(mh-defun-show-buffer mh-show-reply mh-reply t)
+(mh-defun-show-buffer mh-show-redistribute mh-redistribute)
+(mh-defun-show-buffer mh-show-forward mh-forward t)
+(mh-defun-show-buffer mh-show-header-display mh-header-display)
+(mh-defun-show-buffer mh-show-refile-or-write-again
+                      mh-refile-or-write-again)
+(mh-defun-show-buffer mh-show-show mh-show)
+(mh-defun-show-buffer mh-show-write-message-to-file
+                      mh-write-msg-to-file)
+(mh-defun-show-buffer mh-show-extract-rejected-mail
+                      mh-extract-rejected-mail t)
+(mh-defun-show-buffer mh-show-delete-msg-no-motion
+                      mh-delete-msg-no-motion)
+(mh-defun-show-buffer mh-show-first-msg mh-first-msg)
+(mh-defun-show-buffer mh-show-last-msg mh-last-msg)
+(mh-defun-show-buffer mh-show-copy-msg mh-copy-msg)
+(mh-defun-show-buffer mh-show-edit-again mh-edit-again t)
+(mh-defun-show-buffer mh-show-goto-msg mh-goto-msg)
+(mh-defun-show-buffer mh-show-inc-folder mh-inc-folder)
+(mh-defun-show-buffer mh-show-delete-subject-or-thread
+                      mh-delete-subject-or-thread)
+(mh-defun-show-buffer mh-show-delete-subject mh-delete-subject)
+(mh-defun-show-buffer mh-show-print-msg mh-print-msg)
+(mh-defun-show-buffer mh-show-send mh-send t)
+(mh-defun-show-buffer mh-show-toggle-showing mh-toggle-showing t)
+(mh-defun-show-buffer mh-show-pipe-msg mh-pipe-msg t)
+(mh-defun-show-buffer mh-show-sort-folder mh-sort-folder)
+(mh-defun-show-buffer mh-show-visit-folder mh-visit-folder t)
+(mh-defun-show-buffer mh-show-rescan-folder mh-rescan-folder)
+(mh-defun-show-buffer mh-show-pack-folder mh-pack-folder)
+(mh-defun-show-buffer mh-show-kill-folder mh-kill-folder t)
+(mh-defun-show-buffer mh-show-list-folders mh-list-folders t)
+(mh-defun-show-buffer mh-show-undo-folder mh-undo-folder)
+(mh-defun-show-buffer mh-show-delete-msg-from-seq
+                      mh-delete-msg-from-seq)
+(mh-defun-show-buffer mh-show-delete-seq mh-delete-seq)
+(mh-defun-show-buffer mh-show-list-sequences mh-list-sequences)
+(mh-defun-show-buffer mh-show-narrow-to-seq mh-narrow-to-seq)
+(mh-defun-show-buffer mh-show-put-msg-in-seq mh-put-msg-in-seq)
+(mh-defun-show-buffer mh-show-msg-is-in-seq mh-msg-is-in-seq)
+(mh-defun-show-buffer mh-show-widen mh-widen)
+(mh-defun-show-buffer mh-show-narrow-to-subject mh-narrow-to-subject)
+(mh-defun-show-buffer mh-show-narrow-to-from mh-narrow-to-from)
+(mh-defun-show-buffer mh-show-narrow-to-cc mh-narrow-to-cc)
+(mh-defun-show-buffer mh-show-narrow-to-range mh-narrow-to-range)
+(mh-defun-show-buffer mh-show-narrow-to-to mh-narrow-to-to)
+(mh-defun-show-buffer mh-show-store-msg mh-store-msg)
+(mh-defun-show-buffer mh-show-page-digest mh-page-digest)
+(mh-defun-show-buffer mh-show-page-digest-backwards
+                      mh-page-digest-backwards)
+(mh-defun-show-buffer mh-show-burst-digest mh-burst-digest)
+(mh-defun-show-buffer mh-show-page-msg mh-page-msg)
+(mh-defun-show-buffer mh-show-previous-page mh-previous-page)
+(mh-defun-show-buffer mh-show-modify mh-modify t)
+(mh-defun-show-buffer mh-show-next-button mh-next-button)
+(mh-defun-show-buffer mh-show-prev-button mh-prev-button)
+(mh-defun-show-buffer mh-show-toggle-mime-part mh-folder-toggle-mime-part)
+(mh-defun-show-buffer mh-show-save-mime-part mh-folder-save-mime-part)
+(mh-defun-show-buffer mh-show-inline-mime-part mh-folder-inline-mime-part)
+(mh-defun-show-buffer mh-show-toggle-threads mh-toggle-threads)
+(mh-defun-show-buffer mh-show-thread-delete mh-thread-delete)
+(mh-defun-show-buffer mh-show-thread-refile mh-thread-refile)
+(mh-defun-show-buffer mh-show-update-sequences mh-update-sequences)
+(mh-defun-show-buffer mh-show-next-unread-msg mh-next-unread-msg)
+(mh-defun-show-buffer mh-show-previous-unread-msg mh-previous-unread-msg)
+(mh-defun-show-buffer mh-show-thread-ancestor mh-thread-ancestor)
+(mh-defun-show-buffer mh-show-thread-next-sibling mh-thread-next-sibling)
+(mh-defun-show-buffer mh-show-thread-previous-sibling
+                      mh-thread-previous-sibling)
+(mh-defun-show-buffer mh-show-index-visit-folder mh-index-visit-folder t)
+(mh-defun-show-buffer mh-show-toggle-tick mh-toggle-tick)
+(mh-defun-show-buffer mh-show-narrow-to-tick mh-narrow-to-tick)
+(mh-defun-show-buffer mh-show-junk-blacklist mh-junk-blacklist)
+(mh-defun-show-buffer mh-show-junk-whitelist mh-junk-whitelist)
+(mh-defun-show-buffer mh-show-index-new-messages mh-index-new-messages)
+(mh-defun-show-buffer mh-show-index-ticked-messages mh-index-ticked-messages)
+(mh-defun-show-buffer mh-show-index-sequenced-messages
+                      mh-index-sequenced-messages)
+(mh-defun-show-buffer mh-show-catchup mh-catchup)
+(mh-defun-show-buffer mh-show-ps-print-toggle-color mh-ps-print-toggle-color)
+(mh-defun-show-buffer mh-show-ps-print-toggle-faces mh-ps-print-toggle-faces)
+(mh-defun-show-buffer mh-show-ps-print-msg-file mh-ps-print-msg-file)
+(mh-defun-show-buffer mh-show-ps-print-msg mh-ps-print-msg)
+(mh-defun-show-buffer mh-show-toggle-mime-buttons mh-toggle-mime-buttons)
+(mh-defun-show-buffer mh-show-display-with-external-viewer
+                      mh-display-with-external-viewer)
+
+
+
+;;; Sequence Menu
+
+(easy-menu-define
+  mh-show-sequence-menu mh-show-mode-map "Menu for MH-E folder-sequence."
+  '("Sequence"
+    ["Add Message to Sequence..."       mh-show-put-msg-in-seq t]
+    ["List Sequences for Message"       mh-show-msg-is-in-seq t]
+    ["Delete Message from Sequence..."  mh-show-delete-msg-from-seq t]
+    ["List Sequences in Folder..."      mh-show-list-sequences t]
+    ["Delete Sequence..."               mh-show-delete-seq t]
+    ["Narrow to Sequence..."            mh-show-narrow-to-seq t]
+    ["Widen from Sequence"              mh-show-widen t]
+    "--"
+    ["Narrow to Subject Sequence"       mh-show-narrow-to-subject t]
+    ["Narrow to Tick Sequence"          mh-show-narrow-to-tick
+     (save-excursion
+       (set-buffer mh-show-folder-buffer)
+       (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq))))]
+    ["Delete Rest of Same Subject"      mh-show-delete-subject t]
+    ["Toggle Tick Mark"                 mh-show-toggle-tick t]
+    "--"
+    ["Push State Out to MH"             mh-show-update-sequences t]))
+
+;;; Message Menu
+
+(easy-menu-define
+  mh-show-message-menu mh-show-mode-map "Menu for MH-E folder-message."
+  '("Message"
+    ["Show Message"                     mh-show-show t]
+    ["Show Message with Header"         mh-show-header-display t]
+    ["Next Message"                     mh-show-next-undeleted-msg t]
+    ["Previous Message"                 mh-show-previous-undeleted-msg t]
+    ["Go to First Message"              mh-show-first-msg t]
+    ["Go to Last Message"               mh-show-last-msg t]
+    ["Go to Message by Number..."       mh-show-goto-msg t]
+    ["Modify Message"                   mh-show-modify t]
+    ["Delete Message"                   mh-show-delete-msg t]
+    ["Refile Message"                   mh-show-refile-msg t]
+    ["Undo Delete/Refile"               mh-show-undo t]
+    ["Process Delete/Refile"            mh-show-execute-commands t]
+    "--"
+    ["Compose a New Message"            mh-send t]
+    ["Reply to Message..."              mh-show-reply t]
+    ["Forward Message..."               mh-show-forward t]
+    ["Redistribute Message..."          mh-show-redistribute t]
+    ["Edit Message Again"               mh-show-edit-again t]
+    ["Re-edit a Bounced Message"        mh-show-extract-rejected-mail t]
+    "--"
+    ["Copy Message to Folder..."        mh-show-copy-msg t]
+    ["Print Message"                    mh-show-print-msg t]
+    ["Write Message to File..."         mh-show-write-msg-to-file t]
+    ["Pipe Message to Command..."       mh-show-pipe-msg t]
+    ["Unpack Uuencoded Message..."      mh-show-store-msg t]
+    ["Burst Digest Message"             mh-show-burst-digest t]))
+
+;;; Folder Menu
+
+(easy-menu-define
+  mh-show-folder-menu mh-show-mode-map  "Menu for MH-E folder."
+  '("Folder"
+    ["Incorporate New Mail"             mh-show-inc-folder t]
+    ["Toggle Show/Folder"               mh-show-toggle-showing t]
+    ["Execute Delete/Refile"            mh-show-execute-commands t]
+    ["Rescan Folder"                    mh-show-rescan-folder t]
+    ["Thread Folder"                    mh-show-toggle-threads t]
+    ["Pack Folder"                      mh-show-pack-folder t]
+    ["Sort Folder"                      mh-show-sort-folder t]
+    "--"
+    ["List Folders"                     mh-show-list-folders t]
+    ["Visit a Folder..."                mh-show-visit-folder t]
+    ["View New Messages"                mh-show-index-new-messages t]
+    ["Search..."                        mh-search t]
+    "--"
+    ["Quit MH-E"                        mh-quit t]))
+
+
+
+;;; MH-Show Keys
+
+(gnus-define-keys mh-show-mode-map
+  " "    mh-show-page-msg
+  "!"    mh-show-refile-or-write-again
+  "'"    mh-show-toggle-tick
+  ","    mh-show-header-display
+  "."    mh-show-show
+  ">"    mh-show-write-message-to-file
+  "?"    mh-help
+  "E"    mh-show-extract-rejected-mail
+  "M"    mh-show-modify
+  "\177" mh-show-previous-page
+  "\C-d" mh-show-delete-msg-no-motion
+  "\t"   mh-show-next-button
+  [backtab] mh-show-prev-button
+  "\M-\t" mh-show-prev-button
+  "\ed"  mh-show-redistribute
+  "^"    mh-show-refile-msg
+  "c"    mh-show-copy-msg
+  "d"    mh-show-delete-msg
+  "e"    mh-show-edit-again
+  "f"    mh-show-forward
+  "g"    mh-show-goto-msg
+  "i"    mh-show-inc-folder
+  "k"    mh-show-delete-subject-or-thread
+  "m"    mh-show-send
+  "n"    mh-show-next-undeleted-msg
+  "\M-n" mh-show-next-unread-msg
+  "o"    mh-show-refile-msg
+  "p"    mh-show-previous-undeleted-msg
+  "\M-p" mh-show-previous-unread-msg
+  "q"    mh-show-quit
+  "r"    mh-show-reply
+  "s"    mh-show-send
+  "t"    mh-show-toggle-showing
+  "u"    mh-show-undo
+  "x"    mh-show-execute-commands
+  "v"    mh-show-index-visit-folder
+  "|"    mh-show-pipe-msg)
+
+(gnus-define-keys (mh-show-folder-map "F" mh-show-mode-map)
+  "?"    mh-prefix-help
+  "'"    mh-index-ticked-messages
+  "S"    mh-show-sort-folder
+  "c"    mh-show-catchup
+  "f"    mh-show-visit-folder
+  "k"    mh-show-kill-folder
+  "l"    mh-show-list-folders
+  "n"    mh-index-new-messages
+  "o"    mh-show-visit-folder
+  "q"    mh-show-index-sequenced-messages
+  "r"    mh-show-rescan-folder
+  "s"    mh-search
+  "t"    mh-show-toggle-threads
+  "u"    mh-show-undo-folder
+  "v"    mh-show-visit-folder)
+
+(gnus-define-keys (mh-show-sequence-map "S" mh-show-mode-map)
+  "'"    mh-show-narrow-to-tick
+  "?"    mh-prefix-help
+  "d"    mh-show-delete-msg-from-seq
+  "k"    mh-show-delete-seq
+  "l"    mh-show-list-sequences
+  "n"    mh-show-narrow-to-seq
+  "p"    mh-show-put-msg-in-seq
+  "s"    mh-show-msg-is-in-seq
+  "w"    mh-show-widen)
+
+(define-key mh-show-mode-map "I" mh-inc-spool-map)
+
+(gnus-define-keys (mh-show-junk-map "J" mh-show-mode-map)
+  "?"    mh-prefix-help
+  "b"    mh-show-junk-blacklist
+  "w"    mh-show-junk-whitelist)
+
+(gnus-define-keys (mh-show-ps-print-map "P" mh-show-mode-map)
+  "?"   mh-prefix-help
+  "C"   mh-show-ps-print-toggle-color
+  "F"   mh-show-ps-print-toggle-faces
+  "f"   mh-show-ps-print-msg-file
+  "l"   mh-show-print-msg
+  "p"   mh-show-ps-print-msg)
+
+(gnus-define-keys (mh-show-thread-map "T" mh-show-mode-map)
+  "?"    mh-prefix-help
+  "u"    mh-show-thread-ancestor
+  "p"    mh-show-thread-previous-sibling
+  "n"    mh-show-thread-next-sibling
+  "t"    mh-show-toggle-threads
+  "d"    mh-show-thread-delete
+  "o"    mh-show-thread-refile)
+
+(gnus-define-keys (mh-show-limit-map "/" mh-show-mode-map)
+  "'"    mh-show-narrow-to-tick
+  "?"    mh-prefix-help
+  "c"    mh-show-narrow-to-cc
+  "g"    mh-show-narrow-to-range
+  "m"    mh-show-narrow-to-from
+  "s"    mh-show-narrow-to-subject
+  "t"    mh-show-narrow-to-to
+  "w"    mh-show-widen)
+
+(gnus-define-keys (mh-show-extract-map "X" mh-show-mode-map)
+  "?"    mh-prefix-help
+  "s"    mh-show-store-msg
+  "u"    mh-show-store-msg)
+
+(gnus-define-keys (mh-show-digest-map "D" mh-show-mode-map)
+  "?"    mh-prefix-help
+  " "    mh-show-page-digest
+  "\177" mh-show-page-digest-backwards
+  "b"    mh-show-burst-digest)
+
+(gnus-define-keys (mh-show-mime-map "K" mh-show-mode-map)
+  "?"           mh-prefix-help
+  "a"           mh-mime-save-parts
+  "e"           mh-show-display-with-external-viewer
+  "v"           mh-show-toggle-mime-part
+  "o"           mh-show-save-mime-part
+  "i"           mh-show-inline-mime-part
+  "t"           mh-show-toggle-mime-buttons
+  "\t"          mh-show-next-button
+  [backtab]     mh-show-prev-button
+  "\M-\t"       mh-show-prev-button)
+
+
+
+;;; MH-Show Font Lock
+
+(defun mh-header-field-font-lock (field limit)
+  "Return the value of a header field FIELD to font-lock.
+Argument LIMIT limits search."
+  (if (= (point) limit)
+      nil
+    (let* ((mail-header-end (mh-mail-header-end))
+           (lesser-limit (if (< mail-header-end limit) mail-header-end limit))
+           (case-fold-search t))
+      (when (and (< (point) mail-header-end) ;Only within header
+                 (re-search-forward (format "^%s" field) lesser-limit t))
+        (let ((match-one-b (match-beginning 0))
+              (match-one-e (match-end 0)))
+          (mh-header-field-end)
+          (if (> (point) limit)         ;Don't search for end beyond limit
+              (goto-char limit))
+          (set-match-data (list match-one-b match-one-e
+                                (1+ match-one-e) (point)))
+          t)))))
+
+(defun mh-header-to-font-lock (limit)
+  "Return the value of a header field To to font-lock.
+Argument LIMIT limits search."
+  (mh-header-field-font-lock "To:" limit))
+
+(defun mh-header-cc-font-lock (limit)
+  "Return the value of a header field cc to font-lock.
+Argument LIMIT limits search."
+  (mh-header-field-font-lock "cc:" limit))
+
+(defun mh-header-subject-font-lock (limit)
+  "Return the value of a header field Subject to font-lock.
+Argument LIMIT limits search."
+  (mh-header-field-font-lock "Subject:" limit))
+
+(defun mh-letter-header-font-lock (limit)
+  "Return the entire mail header to font-lock.
+Argument LIMIT limits search."
+  (if (= (point) limit)
+      nil
+    (let* ((mail-header-end (save-match-data (mh-mail-header-end)))
+           (lesser-limit (if (< mail-header-end limit) mail-header-end limit)))
+      (when (mh-in-header-p)
+        (set-match-data (list 1 lesser-limit))
+        (goto-char lesser-limit)
+        t))))
+
+(defun mh-show-font-lock-fontify-region (beg end loudly)
+  "Limit font-lock in `mh-show-mode' to the header.
+
+Used when the option `mh-highlight-citation-style' is set to
+\"Gnus\", leaving the body to be dealt with by Gnus highlighting.
+The region between BEG and END is given over to be fontified and
+LOUDLY controls if a user sees a message about the fontification
+operation."
+  (let ((header-end (mh-mail-header-end)))
+    (cond
+     ((and (< beg header-end)(< end header-end))
+      (font-lock-default-fontify-region beg end loudly))
+     ((and (< beg header-end)(>= end header-end))
+      (font-lock-default-fontify-region beg header-end loudly))
+     (t
+      nil))))
+
+(defvar mh-show-font-lock-keywords
+  '(("^\\(From:\\|Sender:\\)\\(.*\\)"
+     (1 'default)
+     (2 'mh-show-from))
+    (mh-header-to-font-lock
+     (0 'default)
+     (1 'mh-show-to))
+    (mh-header-cc-font-lock
+     (0 'default)
+     (1 'mh-show-cc))
+    ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$"
+     (1 'default)
+     (2 'mh-show-from))
+    (mh-header-subject-font-lock
+     (0 'default)
+     (1 'mh-show-subject))
+    ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)"
+     (1 'default)
+     (2 'mh-show-cc))
+    ("^\\(In-reply-to\\|Date\\):\\(.*\\)$"
+     (1 'default)
+     (2 'mh-show-date))
+    (mh-letter-header-font-lock
+     (0 'mh-show-header append t)))
+  "Additional expressions to highlight in MH-Show buffers.")
+
+;;;###mh-autoload
+(defun mh-show-font-lock-keywords ()
+  "Return variable `mh-show-font-lock-keywords'."
+  mh-show-font-lock-keywords)
+
+(defvar mh-show-font-lock-keywords-with-cite
+  (let* ((cite-chars "[>|}]")
+         (cite-prefix "A-Za-z")
+         (cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
+    (append
+     mh-show-font-lock-keywords
+     (list
+      ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
+      `(,cite-chars
+        (,(concat "\\=[ \t]*"
+                  "\\(\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
+                  "\\(" cite-chars "[ \t]*\\)\\)+"
+                  "\\(.*\\)")
+         (beginning-of-line) (end-of-line)
+         (2 font-lock-constant-face nil t)
+         (4 font-lock-comment-face nil t))))))
+  "Additional expressions to highlight in MH-Show buffers.")
+
+;;;###mh-autoload
+(defun mh-show-font-lock-keywords-with-cite ()
+  "Return variable `mh-show-font-lock-keywords-with-cite'."
+  mh-show-font-lock-keywords-with-cite)
+
+
+
+;;; MH-Show Mode
+
+;; Ensure new buffers won't get this mode if default-major-mode is nil.
+(put 'mh-show-mode 'mode-class 'special)
+
+;; Shush compiler.
+(eval-when-compile (defvar font-lock-auto-fontify))
+
+;;;###mh-autoload
+(define-derived-mode mh-show-mode text-mode "MH-Show"
+  "Major mode for showing messages in MH-E.\\<mh-show-mode-map>
+
+The hook `mh-show-mode-hook' is called upon entry to this mode.
+
+See also `mh-folder-mode'.
+
+\\{mh-show-mode-map}"
+  (set (make-local-variable 'mail-header-separator) mh-mail-header-separator)
+  (setq paragraph-start (default-value 'paragraph-start))
+  (mh-show-unquote-From)
+  (mh-show-xface)
+  (mh-show-addr)
+  (setq buffer-invisibility-spec '((vanish . t) t))
+  (set (make-local-variable 'line-move-ignore-invisible) t)
+  (make-local-variable 'font-lock-defaults)
+  ;;(set (make-local-variable 'font-lock-support-mode) nil)
+  (cond
+   ((equal mh-highlight-citation-style 'font-lock)
+    (setq font-lock-defaults '(mh-show-font-lock-keywords-with-cite t)))
+   ((equal mh-highlight-citation-style 'gnus)
+    (setq font-lock-defaults '((mh-show-font-lock-keywords)
+                               t nil nil nil
+                               (font-lock-fontify-region-function
+                                . mh-show-font-lock-fontify-region)))
+    (mh-gnus-article-highlight-citation))
+   (t
+    (setq font-lock-defaults '(mh-show-font-lock-keywords t))))
+  (if (and mh-xemacs-flag
+           font-lock-auto-fontify)
+      (turn-on-font-lock))
+  (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map)
+  (mh-funcall-if-exists mh-tool-bar-init :show)
+  (when mh-decode-mime-flag
+    (mh-make-local-hook 'kill-buffer-hook)
+    (add-hook 'kill-buffer-hook 'mh-mime-cleanup nil t))
+  (easy-menu-add mh-show-sequence-menu)
+  (easy-menu-add mh-show-message-menu)
+  (easy-menu-add mh-show-folder-menu)
+  (make-local-variable 'mh-show-folder-buffer)
+  (buffer-disable-undo)
+  (setq buffer-read-only t)
+  (use-local-map mh-show-mode-map))
+
+
+
+;;; Support Routines
+
+(defun mh-show-unquote-From ()
+  "Decode >From at beginning of lines for `mh-show-mode'."
+  (save-excursion
+    (let ((modified (buffer-modified-p))
+          (case-fold-search nil)
+          (buffer-read-only nil))
+      (goto-char (mh-mail-header-end))
+      (while (re-search-forward "^>From" nil t)
+        (replace-match "From"))
+      (set-buffer-modified-p modified))))
+
+;;;###mh-autoload
+(defun mh-show-addr ()
+  "Use `goto-address'."
+  (when mh-show-use-goto-addr-flag
+    (require 'goto-addr nil t)
+    (if (fboundp 'goto-address)
+        (goto-address))))
+
+;;;###mh-autoload
+(defun mh-gnus-article-highlight-citation ()
+  "Highlight cited text in current buffer using Gnus."
+  (interactive)
+  ;; Don't allow Gnus to create buttons while highlighting, maybe this is bad
+  ;; style?
+  (flet ((gnus-article-add-button (&rest args) nil))
+    (let* ((modified (buffer-modified-p))
+           (gnus-article-buffer (buffer-name))
+           (gnus-cite-face-list `(,@(cdr gnus-cite-face-list)
+                                    ,(car gnus-cite-face-list))))
+      (gnus-article-highlight-citation t)
+      (set-buffer-modified-p modified))))
+
+(provide 'mh-show)
+
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; sentence-end-double-space: nil
+;; End:
+
+;;; mh-show.el ends here