Customizing mh-e Customizing mh-e Customizing Sending
I'll start out by including a function that I use as a front end to
mh-e. [1] It toggles between your
working window configuration, which may be quite involved---windows
filled with source, compilation output, man pages, and other
documentation---and your mh-e window configuration. Like the rest of
the customization described in this chapter, simply add the following
code to `~/.emacs
'. Don't be intimidated by the size of this
example; most customizations are only one line.
Starting mh-e (defvar my-mh-screen-saved nil "Set to non-nil
when mh-e window configuration shown.") (defvar my-normal-screen nil "Normal window configuration.") (defvar my-mh-screen nil "mh-e window configuration.") (defun my-mh-rmail (&optional arg) "Toggle between mh-e and normal screen configurations. With non-nil
or prefix argument, inc mailbox as well when going into mail." (interactive "P") ; user callable function, P=prefix arg (setq my-mh-screen-saved ; save state (cond ;; Bring up mh-e screen if arg or normal window configuration. ;; If arg or +inbox buffer doesn't exist, run mh-rmail. ((or arg (null my-mh-screen-saved)) (setq my-normal-screen (current-window-configuration)) (if (or arg (null (get-buffer "+inbox"))) (mh-rmail) (set-window-configuration my-mh-screen)) t) ; set my-mh-screen-saved tot
;; Otherwise, save mh-e screen and restore normal screen. (t (setq my-mh-screen (current-window-configuration)) (set-window-configuration my-normal-screen) nil)))) ; set my-mh-screen-saved to nil (global-set-key "\C-x\r" 'my-mh-rmail) ; call with C-x RET
If you type an argument (C-u) or if my-mh-screen-saved
is nil
(meaning a non-mh-e window configuration), the current window
configuration is saved, either +inbox is displayed or mh-rmail
is
run, and the mh-e window configuration is shown. Otherwise, the mh-e
window configuration is saved and the original configuration is
displayed.
Now to configure mh-e. The following table lists general mh-e variables and variables that are used while reading mail.
mh-progs
|
Directory containing MH programs (default: dynamic). |
mh-lib
|
Directory containing MH support files and programs (default: dynamic). |
mh-do-not-confirm
|
Don't confirm on non-reversible commands (default: |
mh-summary-height
|
Number of scan lines to show (includes mode line) (default: 4). |
mh-folder-mode-hook
|
Functions to run in MH-Folder mode (default: |
mh-clean-message-header
|
Remove extraneous headers (default: |
mh-invisible-headers
|
Headers to hide (default: ` |
mh-visible-headers
|
Headers to display (default: |
mhl-formfile
|
Format file for |
mh-show-hook
|
Functions to run when showing message (default: |
mh-show-mode-hook
|
Functions to run when showing message (default: |
mh-bury-show-buffer
|
Leave show buffer at bottom of stack (default: |
mh-show-buffer-mode-line-buffer-id
|
Name of show buffer in mode line (default: ` |
The two variables mh-progs
and mh-lib
are used to tell
mh-e where the MH programs and supporting files are kept, respectively.
mh-e does try to figure out where they are kept for itself by looking in
common places and in the user's `PATH
' environment variable, but if
it cannot find the directories, or finds the wrong ones, you should set
these variables. The name of the directory should be placed in double
quotes, and there should be a
trailing slash (`/
'). See the example in Getting Started.
If you never make mistakes, and you do not like confirmations for your
actions, you can set mh-do-not-confirm
to a non-nil
value to
disable confirmation for unrecoverable commands such as M-k
(mh-kill-folder
) and M-u (mh-undo-folder
). Here's
how you set boolean values:
(setq mh-do-not-confirm t)
The variable mh-summary-height
controls the number of scan lines
displayed in the MH-Folder window, including the mode line. The
default value of 4 means that 3 scan lines are displayed. Here's how
you set numerical values:
(setq mh-summary-height 2) ; only show the current scan line
Normally the buffer for displaying messages is buried at the bottom at
the buffer stack. You may wish to disable this feature by setting
mh-bury-show-buffer
to nil
. One advantage of not burying the
show buffer is that one can delete the show buffer more easily in an
electric buffer list because of its proximity to its associated
MH-Folder buffer. Try running M-x electric-buffer-list to
see what I mean.
The hook mh-folder-mode-hook
is called when a new folder is
created with MH-Folder mode. This could be used to set your own
key bindings, for example:
Create additional key bindings via mh-folder-mode-hook
(defvar my-mh-init-done nil "Non-nil
when one-time mh-e settings made.")
(defun my-mh-folder-mode-hook ()
"Hook to set key bindings in MH-Folder mode."
(if (not my-mh-init-done) ; only need to bind the keys once
(progn
(local-set-key "/" 'search-msg)
(local-set-key "b" 'mh-burst-digest) ; better use of b
(setq my-mh-init-done t))))
;;; Emacs 19
(add-hook 'mh-folder-mode-hook 'my-mh-folder-mode-hook)
;;; Emacs 18
;;; (setq mh-folder-mode-hook (cons 'my-mh-folder-mode-hook
;;; mh-folder-mode-hook))
(defun search-msg ()
"Search for a regexp in the current message."
(interactive) ; user function
(save-window-excursion
(other-window 1) ; go to next window
(isearch-forward-regexp))) ; string search; hit return (ESC
; in Emacs 18) when done
[1] Stephen Gildea's favorite binding is (global-set-key "\C-cr" 'mh-rmail).
Customizing mh-e Customizing mh-e Customizing Sending