comparison 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
comparison
equal deleted inserted replaced
68464:79464a6167f5 68465:37d03b3298bf
1 ;;; mh-show.el --- MH-Show mode
2
3 ;; Copyright (C) 1993, 1995, 1997,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5
6 ;; Author: Bill Wohler <wohler@newt.com>
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
8 ;; Keywords: mail
9 ;; See: mh-e.el
10
11 ;; This file is part of GNU Emacs.
12
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)
16 ;; any later version.
17
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.
22
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.
27
28 ;;; Commentary:
29
30 ;; Mode for showing messages.
31
32 ;;; Change Log:
33
34 ;;; Code:
35
36 (require 'mh-e)
37 (require 'mh-scan)
38
39 (require 'gnus-cite)
40 (require 'gnus-util)
41
42 (autoload 'mh-make-buffer-data "mh-mime") ;can't be automatically generated
43
44 (require 'font-lock)
45
46
47
48 ;;; MH-Folder Commands
49
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.")
53
54 ;;;###mh-autoload
55 (defun mh-show (&optional message redisplay-flag)
56 "Display message\\<mh-folder-mode-map>.
57
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].
62
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.
70
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.
75
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))
84
85 ;;;###mh-autoload
86 (defun mh-header-display ()
87 "Display message with all header fields\\<mh-folder-mode-map>.
88
89 Use the command \\[mh-show] to show the message normally again."
90 (interactive)
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))
97 (mh-show-msg nil)
98 (mh-in-show-buffer (mh-show-buffer)
99 (goto-char (point-min))
100 (mh-recenter 0))
101 (setq mh-showing-with-headers t)))
102
103
104
105 ;;; Support Routines for MH-Folder Commands
106
107 ;;;###mh-autoload
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)))
112
113 (defun mh-show-msg (msg)
114 "Show MSG.
115
116 The hook `mh-show-hook' is called after the message has been
117 displayed."
118 (if (not msg)
119 (setq msg (mh-get-msg-num t)))
120 (mh-showing-mode 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)
131 (if (and show-window
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)))))
141 (mh-recenter nil)
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)
149 (when mh-index-data
150 (setq folders
151 (append (mh-index-delete-from-sequence mh-unseen-seq (list msg))
152 folders)))
153 (when (mh-speed-flists-active-p)
154 (apply #'mh-speed-flists t folders)))
155 (run-hooks 'mh-show-hook)))
156
157 ;;;###mh-autoload
158 (defun mh-showing-mode (&optional arg)
159 "Change whether messages should be displayed.
160
161 With ARG, display messages iff ARG is positive."
162 (setq mh-showing-mode
163 (if (null arg)
164 (not mh-showing-mode)
165 (> (prefix-numeric-value arg) 0))))
166
167 ;;;###mh-autoload
168 (defun mh-start-of-uncleaned-message ()
169 "Position uninteresting headers off the top of the window."
170 (let ((case-fold-search t))
171 (re-search-forward
172 "^To:\\|^Cc:\\|^From:\\|^Subject:\\|^Date:" nil t)
173 (beginning-of-line)
174 (mh-recenter 0)))
175
176 (defvar mh-show-buffer-mode-line-buffer-id " {show-%s} %d"
177 "Format string to produce `mode-line-buffer-identification' for show buffers.
178
179 First argument is folder name. Second is message number.")
180
181 ;;;###mh-autoload
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)))
186 (set-buffer folder)
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)
206 (not (y-or-n-p
207 (format
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))
214 (mh-unvisit-file)
215 (setq buffer-read-only nil)
216 ;; Cleanup old mime handles
217 (mh-mime-cleanup)
218 (erase-buffer)
219 ;; Changing contents, so this hook needs to be reinitialized.
220 ;; pgp.el uses this.
221 (if (boundp 'write-contents-hooks) ;Emacs 19
222 (kill-local-variable 'write-contents-hooks))
223 (if formfile
224 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
225 (if (stringp formfile)
226 (list "-form" formfile))
227 msg-filename)
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))
233 (mh-mime-display))
234 (mh-show-mode)
235 ;; Header cleanup
236 (goto-char (point-min))
237 (cond (clean-message-header
238 (mh-clean-msg-header (point-min)
239 invisible-headers
240 visible-headers)
241 (goto-char (point-min)))
242 (t
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)
252 (auto-save-mode 1)
253 (set-mark nil)
254 (unwind-protect
255 (when (and mh-decode-mime-flag (not formfile))
256 (setq buffer-read-only nil)
257 (mh-display-smileys)
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)))
265 (mh-logo-display)
266 (set-buffer folder)
267 (setq mh-showing-with-headers nil))))))
268
269 (defun mh-msg-folder (folder-name)
270 "Return the name of the buffer for FOLDER-NAME."
271 folder-name)
272
273 ;;;###mh-autoload
274 (defun mh-clean-msg-header (start invisible-headers visible-headers)
275 "Flush extraneous lines in message header.
276
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))
286 (save-restriction
287 (goto-char start)
288 (if (search-forward "\n\n" nil 'move)
289 (backward-char 1))
290 (narrow-to-region start (point))
291 (goto-char (point-min))
292 (if visible-headers
293 (while (< (point) (point-max))
294 (cond ((looking-at visible-headers)
295 (forward-line 1)
296 (while (looking-at "[ \t]") (forward-line 1)))
297 (t
298 (mh-delete-line 1)
299 (while (looking-at "[ \t]")
300 (mh-delete-line 1)))))
301 (while (re-search-forward invisible-headers nil t)
302 (beginning-of-line)
303 (mh-delete-line 1)
304 (while (looking-at "[ \t]")
305 (mh-delete-line 1)))))
306 (let ((mh-compose-skipped-header-fields ()))
307 (mh-letter-hide-all-skipped-fields))
308 (unlock-buffer)))
309
310 ;;;###mh-autoload
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)
314 (save-excursion
315 (set-buffer mh-show-buffer)
316 (mh-unvisit-file))))
317
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)
326 (unlock-buffer)
327 (setq buffer-file-name nil))
328
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)))
335 4))
336
337
338
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."
348 `(defun ,function ()
349 ,(format "Calls %s from the message's folder.\n%s\nSee \"%s\" for more info.\n"
350 original-function
351 (if dont-return ""
352 "When function completes, returns to the show buffer if it is
353 still visible.\n")
354 original-function)
355 (interactive)
356 (when (buffer-live-p (get-buffer mh-show-folder-buffer))
357 (let ((config (current-window-configuration))
358 (folder-buffer mh-show-folder-buffer)
359 (normal-exit nil)
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))))
364 folder-buffer)
365 (delete-other-windows))
366 (mh-goto-cur-msg t)
367 (mh-funcall-if-exists deactivate-mark)
368 (unwind-protect
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))
376 ,(if dont-return
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)))))))))
382
383 ;; Generate interactive functions for the show buffer from the corresponding
384 ;; folder functions.
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)
480
481
482
483 ;;; Sequence Menu
484
485 (easy-menu-define
486 mh-show-sequence-menu mh-show-mode-map "Menu for MH-E folder-sequence."
487 '("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]
495 "--"
496 ["Narrow to Subject Sequence" mh-show-narrow-to-subject t]
497 ["Narrow to Tick Sequence" mh-show-narrow-to-tick
498 (save-excursion
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]
503 "--"
504 ["Push State Out to MH" mh-show-update-sequences t]))
505
506 ;;; Message Menu
507
508 (easy-menu-define
509 mh-show-message-menu mh-show-mode-map "Menu for MH-E folder-message."
510 '("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]
523 "--"
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]
530 "--"
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]))
537
538 ;;; Folder Menu
539
540 (easy-menu-define
541 mh-show-folder-menu mh-show-mode-map "Menu for MH-E folder."
542 '("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]
550 "--"
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]
555 "--"
556 ["Quit MH-E" mh-quit t]))
557
558
559
560 ;;; MH-Show Keys
561
562 (gnus-define-keys mh-show-mode-map
563 " " mh-show-page-msg
564 "!" mh-show-refile-or-write-again
565 "'" mh-show-toggle-tick
566 "," mh-show-header-display
567 "." mh-show-show
568 ">" mh-show-write-message-to-file
569 "?" mh-help
570 "E" mh-show-extract-rejected-mail
571 "M" mh-show-modify
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
579 "c" mh-show-copy-msg
580 "d" mh-show-delete-msg
581 "e" mh-show-edit-again
582 "f" mh-show-forward
583 "g" mh-show-goto-msg
584 "i" mh-show-inc-folder
585 "k" mh-show-delete-subject-or-thread
586 "m" mh-show-send
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
592 "q" mh-show-quit
593 "r" mh-show-reply
594 "s" mh-show-send
595 "t" mh-show-toggle-showing
596 "u" mh-show-undo
597 "x" mh-show-execute-commands
598 "v" mh-show-index-visit-folder
599 "|" mh-show-pipe-msg)
600
601 (gnus-define-keys (mh-show-folder-map "F" mh-show-mode-map)
602 "?" mh-prefix-help
603 "'" mh-index-ticked-messages
604 "S" mh-show-sort-folder
605 "c" mh-show-catchup
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
613 "s" mh-search
614 "t" mh-show-toggle-threads
615 "u" mh-show-undo-folder
616 "v" mh-show-visit-folder)
617
618 (gnus-define-keys (mh-show-sequence-map "S" mh-show-mode-map)
619 "'" mh-show-narrow-to-tick
620 "?" mh-prefix-help
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
627 "w" mh-show-widen)
628
629 (define-key mh-show-mode-map "I" mh-inc-spool-map)
630
631 (gnus-define-keys (mh-show-junk-map "J" mh-show-mode-map)
632 "?" mh-prefix-help
633 "b" mh-show-junk-blacklist
634 "w" mh-show-junk-whitelist)
635
636 (gnus-define-keys (mh-show-ps-print-map "P" mh-show-mode-map)
637 "?" mh-prefix-help
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)
643
644 (gnus-define-keys (mh-show-thread-map "T" mh-show-mode-map)
645 "?" mh-prefix-help
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)
652
653 (gnus-define-keys (mh-show-limit-map "/" mh-show-mode-map)
654 "'" mh-show-narrow-to-tick
655 "?" mh-prefix-help
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
661 "w" mh-show-widen)
662
663 (gnus-define-keys (mh-show-extract-map "X" mh-show-mode-map)
664 "?" mh-prefix-help
665 "s" mh-show-store-msg
666 "u" mh-show-store-msg)
667
668 (gnus-define-keys (mh-show-digest-map "D" mh-show-mode-map)
669 "?" mh-prefix-help
670 " " mh-show-page-digest
671 "\177" mh-show-page-digest-backwards
672 "b" mh-show-burst-digest)
673
674 (gnus-define-keys (mh-show-mime-map "K" mh-show-mode-map)
675 "?" mh-prefix-help
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)
685
686
687
688 ;;; MH-Show Font Lock
689
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)
694 nil
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
704 (goto-char limit))
705 (set-match-data (list match-one-b match-one-e
706 (1+ match-one-e) (point)))
707 t)))))
708
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))
713
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))
718
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))
723
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)
728 nil
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)
734 t))))
735
736 (defun mh-show-font-lock-fontify-region (beg end loudly)
737 "Limit font-lock in `mh-show-mode' to the header.
738
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
743 operation."
744 (let ((header-end (mh-mail-header-end)))
745 (cond
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))
750 (t
751 nil))))
752
753 (defvar mh-show-font-lock-keywords
754 '(("^\\(From:\\|Sender:\\)\\(.*\\)"
755 (1 'default)
756 (2 'mh-show-from))
757 (mh-header-to-font-lock
758 (0 'default)
759 (1 'mh-show-to))
760 (mh-header-cc-font-lock
761 (0 'default)
762 (1 'mh-show-cc))
763 ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$"
764 (1 'default)
765 (2 'mh-show-from))
766 (mh-header-subject-font-lock
767 (0 'default)
768 (1 'mh-show-subject))
769 ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)"
770 (1 'default)
771 (2 'mh-show-cc))
772 ("^\\(In-reply-to\\|Date\\):\\(.*\\)$"
773 (1 'default)
774 (2 'mh-show-date))
775 (mh-letter-header-font-lock
776 (0 'mh-show-header append t)))
777 "Additional expressions to highlight in MH-Show buffers.")
778
779 ;;;###mh-autoload
780 (defun mh-show-font-lock-keywords ()
781 "Return variable `mh-show-font-lock-keywords'."
782 mh-show-font-lock-keywords)
783
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_.@-`'\"")))
788 (append
789 mh-show-font-lock-keywords
790 (list
791 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
792 `(,cite-chars
793 (,(concat "\\=[ \t]*"
794 "\\(\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
795 "\\(" cite-chars "[ \t]*\\)\\)+"
796 "\\(.*\\)")
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.")
801
802 ;;;###mh-autoload
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)
806
807
808
809 ;;; MH-Show Mode
810
811 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
812 (put 'mh-show-mode 'mode-class 'special)
813
814 ;; Shush compiler.
815 (eval-when-compile (defvar font-lock-auto-fontify))
816
817 ;;;###mh-autoload
818 (define-derived-mode mh-show-mode text-mode "MH-Show"
819 "Major mode for showing messages in MH-E.\\<mh-show-mode-map>
820
821 The hook `mh-show-mode-hook' is called upon entry to this mode.
822
823 See also `mh-folder-mode'.
824
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)
829 (mh-show-xface)
830 (mh-show-addr)
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)
835 (cond
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)
840 t nil nil nil
841 (font-lock-fontify-region-function
842 . mh-show-font-lock-fontify-region)))
843 (mh-gnus-article-highlight-citation))
844 (t
845 (setq font-lock-defaults '(mh-show-font-lock-keywords t))))
846 (if (and mh-xemacs-flag
847 font-lock-auto-fontify)
848 (turn-on-font-lock))
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))
861
862
863
864 ;;; Support Routines
865
866 (defun mh-show-unquote-From ()
867 "Decode >From at beginning of lines for `mh-show-mode'."
868 (save-excursion
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))))
876
877 ;;;###mh-autoload
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)
883 (goto-address))))
884
885 ;;;###mh-autoload
886 (defun mh-gnus-article-highlight-citation ()
887 "Highlight cited text in current buffer using Gnus."
888 (interactive)
889 ;; Don't allow Gnus to create buttons while highlighting, maybe this is bad
890 ;; style?
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))))
898
899 (provide 'mh-show)
900
901 ;; Local Variables:
902 ;; indent-tabs-mode: nil
903 ;; sentence-end-double-space: nil
904 ;; End:
905
906 ;;; mh-show.el ends here