head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2006.; author jpeek; state Exp; branches; next 1.3; 1.3 date 2006.; author jpeek; state Exp; branches; next 1.2; 1.2 date 2006.; author jpeek; state Exp; branches; next 1.1; 1.1 date 2006.; author jpeek; state Exp; branches; next ; desc @mh-e_65.html page from mh-e section of "MH & nmh: Email for Users & Programmers" @ 1.4 log @Removed 'html/' from end of http://mh-e.sourceforge.net/manual/html/ URLs @ text @ BOOK MOVED: mh-e - Customizing Organizing

BOOK MOVED: mh-e - Customizing Organizing

This section of MH & nmh: Email for Users & Programmers is now the MH-E Manual. It's moved to http://mh-e.sourceforge.net/manual/.

If you aren't taken to the new site in 15 seconds, please click on the link above.

You may also want to visit:

Last change $Date: 2006/05/28 04:27:15 $
Suggestions are welcome: Bill Wohler <wohler@@newt.com>
@ 1.3 log @removed 'Tour-Through-MH_002dE.html' from end of http://mh-e.sourceforge.net/manual/html/ @ text @d4 1 a4 1 content="15;URL=http://mh-e.sourceforge.net/manual/html/"> d15 2 a16 2 href="http://mh-e.sourceforge.net/manual/html/"> http://mh-e.sourceforge.net/manual/html/. d39 1 a39 1 Last change $Date: 2006/05/26 23:59:01 $ @ 1.2 log @Replaced with page pointing people to new MH-E Manual @ text @d4 1 a4 1 content="15;URL=http://mh-e.sourceforge.net/manual/html/Tour-Through-MH_002dE.html"> d15 2 a16 2 href="http://mh-e.sourceforge.net/manual/html/Tour-Through-MH_002dE.html"> http://mh-e.sourceforge.net/manual/html/Tour-Through-MH_002dE.html. d39 1 a39 1 Last change $Date: 2006/05/26 22:12:05 $ @ 1.1 log @Original version from Feb 19 2001 @ text @d3 2 d7 39 a45 134 mh-e - Customizing Organizing Go to the first, previous, next, last section, table of contents.

Organizing Your Mail with Folders

By default, operations on folders work only one level at a time. Set mh-recursive-folders to non-nil to operate on all folders. This mostly means that you'll be able to see all your folders when you press TAB when prompted for a folder name. The variable mh-auto-folder-collect is normally turned on to generate a list of folder names in the background as soon as mh-e is loaded. Otherwise, the list is generated when you need a folder name the first time (as with o (mh-refile-msg)). If you have a lot of folders and you have mh-recursive-folders set, this could take a while, which is why it's nice to do the folder collection in the background.

The function mh-default-folder-for-message-function is used by o (mh-refile-msg) and C-c C-f C-f (mh-to-fcc) to generate a default folder. The generated folder name should be a string with a `+' before it. For each of my correspondents, I use the same name for both an alias and a folder. So, I wrote a function that takes the address in the `From:' header field, finds it in my alias file, and returns the alias, which is used as a default folder name. This is the most complicated example given here, and it demonstrates several features of Emacs Lisp programming. You should be able to drop this into `~/.emacs', however. If you use this to store messages in a subfolder of your Mail directory, you can modify the line that starts `(format +%s...' and insert your subfolder after the folder symbol `+'.

Creating useful default folder for refiling via mh-default-folder-for-message-function

(defun my-mh-folder-from-address ()
  "Determine folder name from address.
Takes the address in the From: header field, and returns its corresponding
alias from the user's personal aliases file. Returns nil if the address
was not found."
  (require 'rfc822)                         ; for the rfc822 functions
  (search-forward-regexp "^From: \\(.*\\)") ; grab header field contents
  (save-excursion                     ; save state
    (let ((addr (car (rfc822-addresses  ; get address
                      (buffer-substring (match-beginning 1)
                                        (match-end 1)))))
          (buffer (get-buffer-create " *temp*")) ; set local variables
      (set-buffer buffer)             ; jump to temporary buffer
      (unwind-protect                 ; run kill-buffer when done
          (progn                      ; function grouping construct
            (insert-file-contents (expand-file-name "aliases"
            (goto-char (point-min))   ; grab aliases file and go to start
            (setq folder
                  ;; Search for the given address, even commented-out
                  ;; addresses are found!
                  ;; The function search-forward-regexp sets values that are
                  ;; later used by match-beginning and match-end.
                  (if (search-forward-regexp (format "^;*\\(.*\\):.*%s"
                                                     addr) nil t)
                      ;; NOTE WELL: this is what the return value looks like.
                      ;; You can modify the format string to match your own
                      ;; Mail hierarchy.
                      (format "+%s" (buffer-substring (match-beginning 1)
                                                      (match-end 1))))))
        (kill-buffer buffer))          ; get rid of our temporary buffer
      folder)))                        ; function's return value

(setq mh-default-folder-for-message-function 'my-mh-folder-from-address)

The hook mh-refile-msg-hook is called after a message is marked to be refiled.

The variable mh-sortm-args holds extra arguments to pass on to the sortm command. Note: this variable is only consulted when a prefix argument is given to M-x mh-sort-folder. It is used to override any arguments given in a sortm: entry in your MH profile (`~/.mh_profile').

Go to the first, previous, next, last section, table of contents. @