From: jrs@world.std.com (Rick Sladkey)
Subject: patch to VM-5.32 to handle RFC 1153 Digests
Organization: The Internet
Date: Mon, 25 Jan 1993 07:23:19 GMT

I have had a lot of problems with the heuristics VM uses when trying
to burst digest formats other that RFC 934.  Since RFC 1153 (SIMTEL 
style) digests are quite common and a bone fide standard, I added
explicit support for RFC 1153 digests to VM-5.32.  I didn't add
support for building digests but this at least handles bursting
gracefully.

To use it, just add the following line to you ~/.vm:

(setq vm-rfc1153-digest-format t)

The default is to expect RFC 934 style digests.
-----
*** vm-digest.el.orig	Mon Mar  2 00:39:22 1992
--- vm-digest.el	Mon Jan 25 01:55:27 1993
***************
*** 1,4 ****
! ;;; Support code for RFC934 digests
  ;;; Copyright (C) 1989, 1990 Kyle E. Jones
  ;;;
  ;;; This program is free software; you can redistribute it and/or modify
--- 1,4 ----
! ;;; Support code for RFC934 and RFC1153 digests
  ;;; Copyright (C) 1989, 1990 Kyle E. Jones
  ;;;
  ;;; This program is free software; you can redistribute it and/or modify
***************
*** 57,64 ****
  you will be moved to the first new or unread message.
  
  By default VM expects digests to be in the standard RFC 934 format.
! A prefix will inveigle VM into coping with other digest formats,
! with mixed results."
    (interactive "P")
    (vm-follow-summary-cursor)
    (vm-select-folder-buffer)
--- 57,66 ----
  you will be moved to the first new or unread message.
  
  By default VM expects digests to be in the standard RFC 934 format.
! If vm-rfc1153-digest-format is non-nil, VM expects the digests to
! be in RFC 1153 format, i.e. messages are separated by lines of
! exactly 30 dashes.  A prefix will inveigle VM into coping with
! other digest formats, with mixed results."
    (interactive "P")
    (vm-follow-summary-cursor)
    (vm-select-folder-buffer)
***************
*** 72,78 ****
  	(text-start (vm-marker nil))
  	(buffer-read-only)
  	(old-buffer-modified-p (buffer-modified-p))
! 	(m (car vm-message-pointer)))
      (save-excursion
        (vm-save-restriction
         (condition-case error-data
--- 74,92 ----
  	(text-start (vm-marker nil))
  	(buffer-read-only)
  	(old-buffer-modified-p (buffer-modified-p))
! 	(m (car vm-message-pointer))
! 	(final-message-separator-regex
! 	 (if vm-rfc1153-digest-format
! 	     (concat "\\(\n+" (make-string 30 ?-) "\n+\\)+")
! 	   "\\(^-[^ ].*\n+\\|^-\n+\\)+"))
! 	(first-message-separator-regex
! 	 (if vm-rfc1153-digest-format
! 	     (concat "^" (make-string 70 ?-) "\n+")
! 	   "^-[^ ]"))
! 	(message-separator-regex
! 	 (if vm-rfc1153-digest-format
! 	     (concat "\\(\\(\n+\\)\\|\\(^\\)\\)\\(" (make-string 30 ?-) "\n+\\)+")
! 	   "\\(\\(\n+\\)\\|\\(^\\)\\)\\(-[^ ].*\n+\\|-\n+\\)+")))
      (save-excursion
        (vm-save-restriction
         (condition-case error-data
***************
*** 85,91 ****
  				      (vm-text-end-of
  				       (car vm-message-pointer)))
  	     (if (not
! 		  (re-search-backward "\\(^-[^ ].*\n+\\|^-\n+\\)+" start t))
  		 (error "final message separator not found")
  	       (setq end (point-marker))
  	       ;; Reverse searchs are funky.  The above expression simply
--- 99,105 ----
  				      (vm-text-end-of
  				       (car vm-message-pointer)))
  	     (if (not
! 		  (re-search-backward final-message-separator-regex start t))
  		 (error "final message separator not found")
  	       (setq end (point-marker))
  	       ;; Reverse searchs are funky.  The above expression simply
***************
*** 95,101 ****
  	       (while
  		   (and
  		    (save-excursion
! 		      (re-search-backward "\\(^-[^ ].*\n+\\|^-\n+\\)+" start t)
  		      (= end (match-end 0))))
  		 (set-marker end (match-beginning 0))
  		 (goto-char end))
--- 109,115 ----
  	       (while
  		   (and
  		    (save-excursion
! 		      (re-search-backward final-message-separator-regex start t)
  		      (= end (match-end 0))))
  		 (set-marker end (match-beginning 0))
  		 (goto-char end))
***************
*** 103,111 ****
  	       (set-marker end (point))
  	       (delete-region end (point-max)))
  	     (goto-char start)
! 	     (if (not (re-search-forward "^-[^ ]" end t))
  		 (error "first message separator not found")
  	       (delete-region start (match-beginning 0)))
  	     ;; Now that we know that the digest has the basics covered
  	     ;; try to detect and fix any bogus message separators,
  	     ;; if the user requested it.
--- 117,127 ----
  	       (set-marker end (point))
  	       (delete-region end (point-max)))
  	     (goto-char start)
! 	     (if (not (re-search-forward first-message-separator-regex end t))
  		 (error "first message separator not found")
  	       (delete-region start (match-beginning 0)))
+ 	     (if vm-rfc1153-digest-format
+ 		 (insert "\n" (make-string 30 ?-) "\n"))
  	     ;; Now that we know that the digest has the basics covered
  	     ;; try to detect and fix any bogus message separators,
  	     ;; if the user requested it.
***************
*** 118,126 ****
  				    (current-time-string) "\n")
  		     trailer "\n\n"))
  	     (goto-char start)
! 	     (while (re-search-forward
! 		     "\\(\\(\n+\\)\\|\\(^\\)\\)\\(-[^ ].*\n+\\|-\n+\\)+"
! 		     end 0)
  	       ;; delete message separator
  	       (replace-match "" t t)
  	       ;; stuff separator
--- 134,140 ----
  				    (current-time-string) "\n")
  		     trailer "\n\n"))
  	     (goto-char start)
! 	     (while (re-search-forward message-separator-regex end 0)
  	       ;; delete message separator
  	       (replace-match "" t t)
  	       ;; stuff separator
***************
*** 144,153 ****
  			 (delete-region (match-beginning 0) (match-end 0)))))
  	       ;; find end of message separator and unstuff the message
  	       (goto-char reg-start)
! 	       (set-marker reg-end (if (re-search-forward "\n+-[^ ]" end 0)
  				       (match-beginning 0)
  				     (point)))
! 	       (vm-rfc934-char-unstuff-region reg-start reg-end)
  	       (goto-char reg-end))
  	     (goto-char end)
  	     (insert trailer)
--- 158,169 ----
  			 (delete-region (match-beginning 0) (match-end 0)))))
  	       ;; find end of message separator and unstuff the message
  	       (goto-char reg-start)
! 	       (set-marker reg-end (if (re-search-forward
! 					message-separator-regex end 0)
  				       (match-beginning 0)
  				     (point)))
! 	       (if (not vm-rfc1153-digest-format)
! 		   (vm-rfc934-char-unstuff-region reg-start reg-end))
  	       (goto-char reg-end))
  	     (goto-char end)
  	     (insert trailer)
*** vm-vars.el.orig	Mon Mar  2 00:39:10 1992
--- vm-vars.el	Mon Jan 25 00:39:47 1993
***************
*** 628,633 ****
--- 628,637 ----
  This keymap is used in addition to the keymap used by the major mode
  specified by vm-edit-message-mode.")
  
+ (defvar vm-rfc1153-digest-format nil
+   "*Use RFC 1153 format when building or bursting digests.
+ The default is to use RFC 934 format.")
+ 
  ;; internal vars
  (defvar vm-mode-line-format
    '("" (vm-buffer-modified-p vm-buffer-modified-p "-----")
Newsgroups: gnu.emacs.vm.info