home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / vm-enh.patch < prev    next >
Encoding:
Internet Message Format  |  1990-07-22  |  8.6 KB

  1. From: montnaro@sprite.crd.ge.com (Skip Montanaro)
  2. Newsgroups: gnu.emacs
  3. Subject: Displaying recipient in summary and grouping by recipients in VM
  4. Message-ID: <8908210034.AA01934@sprite.crd.Ge.Com>
  5. Date: 21 Aug 89 00:34:56 GMT
  6. Reply-To: <montanaro@sprite.crd.ge.com> (Skip Montanaro)
  7. Distribution: gnu
  8. Organization: GNUs Not Usenet
  9. Lines: 222
  10.  
  11. I FCC all my mail, and occasionally need to browse that file, either to
  12. delete unwanted messages, or to resend a message. VM allows the user to
  13. group by a number of attributes, but not (any of) the receipient(s). Neither
  14. does it allow you to format the summary line to show the recipient. The
  15. context diffs against 4.39 at the end of this message do that. The "%t"
  16. string in vm-summary-format will cause VM to find the primary recipient of
  17. the message and place it in the summary line, instead of the author. The
  18. primary recipient is defined as the first address in either the To,
  19. Apparently-To, or CC fields (searched in that order). You can group by the
  20. primary recipient as well, by giving "recipient" as field to group by when
  21. prompted.
  22.  
  23. I use the changes by executing the small piece of code in ~/.emacs:
  24.  
  25.     (setq vm-mode-hooks '(hack-vm-summary-format))
  26.  
  27.     (defun hack-vm-summary-format ()
  28.       (if (string= (expand-file-name mail-archive-file-name)
  29.            buffer-file-name)
  30.       (progn
  31.         (make-variable-buffer-local 'vm-summary-format)
  32.         (setq vm-summary-format "%3n %a %-17.17t %3m %2d %3l/%-5c \"%s\"\n")
  33.         (make-variable-buffer-local 'vm-group-by)
  34.         (setq vm-group-by "recipient"))
  35.     (progn
  36.       (setq vm-summary-format "%3n %a %-17.17f %3m %2d %3l/%-5c \"%s\"\n")
  37.       (setq vm-group-by "author"))))
  38.  
  39. (Setting vm-group-by doesn't have an immediate effect when displaying
  40. summaries. I'm still debating whether to add a (vm-group-messages
  41. vm-group-by) to the end of vm-summarize.)
  42.  
  43. One note of caution. I made the changes to 4.37, then discovered I didn't
  44. have the original files anywhere. So I used diff to diff my modified VM 4.37
  45. with the latest version (4.39), edited the output to remove any 4.37-4.39
  46. diffs, then used patch to splice in my changes.  I then remade diffs and
  47. checked them to make sure no 4.37-4.39 changes were undone. I don't think I
  48. botched it, but one never knows...
  49.  
  50. *** vm-group.el.orig    Mon Jul 24 10:51:56 1989
  51. --- vm-group.el    Sun Aug 20 19:07:29 1989
  52. ***************
  53. *** 57,60 ****
  54. --- 57,63 ----
  55.     (string= (vm-full-name-of m1) (vm-full-name-of m2)))
  56.   
  57. + (defun vm-group-by-recipient (m1 m2)
  58. +   (string= (vm-to-of m1) (vm-to-of m2)))
  59.   (defun vm-group-by-date-sent (m1 m2)
  60.     (and (string= (vm-monthday-of m1) (vm-monthday-of m2))
  61. *** vm-summary.el.orig    Mon Jul 24 10:51:57 1989
  62. --- vm-summary.el    Sun Aug 20 19:07:31 1989
  63. ***************
  64. *** 160,167 ****
  65.       (store-match-data nil)
  66.       (while (string-match
  67. ! "%\\(-\\)?\\([0-9]\\)*\\(\\.\\([0-9]+\\)\\)?\\([acdfFhilmnswyz%]\\)"
  68.           format (match-end 0))
  69.         (setq conv-spec (aref format (match-beginning 5)))
  70. !       (if (memq conv-spec '(?a ?c ?d ?f ?F ?h ?i ?l ?m ?n ?s ?w ?y ?z))
  71.         (progn
  72.           (cond ((= conv-spec ?a)
  73. --- 160,167 ----
  74.       (store-match-data nil)
  75.       (while (string-match
  76. ! "%\\(-\\)?\\([0-9]\\)*\\(\\.\\([0-9]+\\)\\)?\\([acdfFhilmnstwyz%]\\)"
  77.           format (match-end 0))
  78.         (setq conv-spec (aref format (match-beginning 5)))
  79. !       (if (memq conv-spec '(?a ?c ?d ?f ?F ?h ?i ?l ?m ?n ?s ?t ?w ?y ?z))
  80.         (progn
  81.           (cond ((= conv-spec ?a)
  82. ***************
  83. *** 198,201 ****
  84. --- 198,204 ----
  85.              (setq sexp (cons (list 'vm-su-subject
  86.                         'vm-su-message) sexp)))
  87. +           ((= conv-spec ?t)
  88. +            (setq sexp (cons (list 'vm-su-to
  89. +                       'vm-su-message) sexp)))
  90.             ((= conv-spec ?w)
  91.              (setq sexp (cons (list 'vm-su-weekday
  92. ***************
  93. *** 388,391 ****
  94. --- 391,435 ----
  95.     (or (vm-from-of m)
  96.         (progn (vm-su-do-author m) (vm-from-of m))))
  97. + (defun vm-su-to (m)
  98. +   (or (vm-to-of m)
  99. +       (progn (vm-su-do-recipient m) (vm-to-of m))))
  100. + ;; Just pick off the first recipient - useful for browsing outgoing archives
  101. + ;; (e.g., FCC'd mail).
  102. + (defun vm-su-do-recipient (message)
  103. +   (let (to pat1 pat2 pat3)
  104. +     (setq to (or (vm-get-header-contents m "To")
  105. +          (vm-get-header-contents m "Apparently-To")
  106. +          (vm-get-header-contents m "CC")))
  107. +     (if (null to)
  108. +     (setq to "???")
  109. +       (progn
  110. +     ;; pick off first address
  111. +     (if (string-match "^[ \t]*\\([^\n,]+\\).*" to)
  112. +         (setq to (substring to (match-beginning 1) (match-end 1))))
  113. +     ;; pat1, pat2, and pat3 are tried in order. 
  114. +     ;; junk < address > junk
  115. +     (setq pat1 "^.*<\\([^> \t\n]+\\).*")
  116. +     ;; addr? ( junk ) addr?
  117. +     (setq pat2 "^[ \t]*\\([^( \t\n]*\\)[ \t]*([^)]*)[ \t]*\\([^ \t\n]*\\)[ \t]*")
  118. +     ;; addr?
  119. +     (setq pat3 "^[ \t]*\\([^ \t\n]+\\)[ \t\n]*")
  120. +     (if (not (string-match pat1 to))
  121. +         (progn
  122. +           (if (not (string-match pat2 to))
  123. +           (progn
  124. +             (if (not (string-match pat3 to))
  125. +             (error "Invalid pattern in vm-su-do-recipient")
  126. +               (setq to (substring to (match-beginning 1)
  127. +                       (match-end 1)))))
  128. +         (if (not (eq (match-beginning 1) (match-end 1)))
  129. +             (setq to (substring to (match-beginning 1)
  130. +                     (match-end 1)))
  131. +           (setq to (substring to (match-beginning 2)
  132. +                       (match-end 2))))))
  133. +       (setq to (substring to (match-beginning 1) (match-end 1))))))
  134. +     (vm-set-to-of m to)))
  135.   
  136.   ;; Some yogurt-headed delivery agents don't even provide a From: header.
  137. *** vm.el.orig    Mon Jul 24 10:51:57 1989
  138. --- vm.el    Sun Aug 20 19:43:27 1989
  139. ***************
  140. *** 175,178 ****
  141. --- 175,179 ----
  142.      n - message number
  143.      s - message subject
  144. +    t - the primary recipient (first recipient from To:, Apparently-To:, CC:)
  145.      w - day of the week message sent
  146.      y - year message sent
  147. ***************
  148. *** 229,235 ****
  149.       Re:'s) to be presented together,
  150.     \"author\", which causes messages with the same author to be presented
  151. !     together, and
  152.     \"date-sent\", which causes message sent on the same day to be
  153. !     presented together.
  154.     \"arrival-time\" which appears only for completeness, this is the
  155.       default behavior and is the same as nil.
  156. --- 230,238 ----
  157.       Re:'s) to be presented together,
  158.     \"author\", which causes messages with the same author to be presented
  159. !     together,
  160. !   \"recipient\", which causes message sent to the same primary recipient to
  161. !     be presented together,
  162.     \"date-sent\", which causes message sent on the same day to be
  163. !     presented together, and
  164.     \"arrival-time\" which appears only for completeness, this is the
  165.       default behavior and is the same as nil.
  166. ***************
  167. *** 368,372 ****
  168.   (defconst vm-header-regexp-format "^%s:[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)")
  169.   (defconst vm-supported-groupings-alist
  170. !   '(("arrival-time") ("subject") ("author") ("date-sent")))
  171.   (defconst vm-total-count 0)
  172.   (defconst vm-new-count 0)
  173. --- 371,375 ----
  174.   (defconst vm-header-regexp-format "^%s:[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)")
  175.   (defconst vm-supported-groupings-alist
  176. !   '(("arrival-time") ("subject") ("author") ("recipient") ("date-sent")))
  177.   (defconst vm-total-count 0)
  178.   (defconst vm-new-count 0)
  179. ***************
  180. *** 413,417 ****
  181.   
  182.   ;; macros and functions dealing with accessing messages struct fields
  183. ! (defun vm-make-message () (make-vector 20 nil))
  184.   
  185.   ;; where message begins (From_ line)
  186. --- 416,420 ----
  187.   
  188.   ;; macros and functions dealing with accessing messages struct fields
  189. ! (defun vm-make-message () (make-vector 21 nil))
  190.   
  191.   ;; where message begins (From_ line)
  192. ***************
  193. *** 461,464 ****
  194. --- 464,468 ----
  195.   (defmacro vm-su-start-of (message) (list 'aref message 18))
  196.   (defmacro vm-su-end-of (message) (list 'aref message 19))
  197. + (defmacro vm-to-of (message) (list 'aref message 20))
  198.   
  199.   (defmacro vm-set-start-of (message start) (list 'aset message 0 start))
  200. ***************
  201. *** 482,485 ****
  202. --- 486,490 ----
  203.   (defmacro vm-set-su-start-of (message start) (list 'aset message 18 start))
  204.   (defmacro vm-set-su-end-of (message end) (list 'aset message 19 end))
  205. + (defmacro vm-set-to-of (message end) (list 'aset message 20 end))
  206.   
  207.   (defun vm-text-end-of (message)
  208. *** vm.texinfo.orig    Mon Jul 24 10:50:23 1989
  209. --- vm.texinfo    Sun Aug 20 19:10:32 1989
  210. ***************
  211. *** 713,716 ****
  212. --- 713,720 ----
  213.   @item author
  214.   Messages with the same author are grouped together.
  215. + @item recipient
  216. + Messages to the same primary recipient are grouped together. The primary
  217. + recipient is the first addressee in the To, Apparently-To, or CC fields
  218. + (in that order of preference).
  219.   @item date-sent
  220.   Messages sent on the same day are grouped together.
  221. ***************
  222. *** 778,781 ****
  223. --- 782,786 ----
  224.      n - message number
  225.      s - message subject
  226. +    t - primary recipient's address
  227.      w - day of the week message sent
  228.      y - year message sent
  229.