- (set-buffer (get-buffer-create " *nnmaildir nov*"))
- (when (file-exists-p novfile) ;; If not, force reparsing the message.
- (if nov nil ;; It's already in memory.
- ;; Else read the data from the NOV file.
- (erase-buffer)
- (nnheader-insert-file-contents novfile)
- (setq nov (read (current-buffer)))
- (nnmaildir--art-set-msgid article (car nov))
- (setq nov (cadr nov)))
- ;; If the NOV's modtime matches the file's current modtime,
- ;; and it has the right length (i.e., it wasn't produced by
- ;; a too-much older version of nnmaildir), then we may use
- ;; this NOV data rather than parsing the message file,
- ;; unless nnmail-extra-headers has been augmented since this
- ;; data was last parsed.
- (when (and (equal mtime (nnmaildir--nov-get-mtime nov))
- (= (length nov) (length (nnmaildir--nov-new))))
- ;; This NOV data is potentially up-to-date.
- (setq old-neh (nnmaildir--nov-get-neh nov)
- new-neh nnmail-extra-headers)
- (if (equal new-neh old-neh) (throw 'return nov)) ;; Common case.
- ;; They're not equal, but maybe the new is a subset of the old...
- (if (null new-neh) (throw 'return nov))
- (while new-neh
- (if (memq (car new-neh) old-neh)
- (progn
- (setq new-neh (cdr new-neh))
- (if new-neh nil (throw 'return nov)))
- (setq new-neh nil)))))
- ;; Parse the NOV data out of the message.
- (erase-buffer)
- (nnheader-insert-file-contents file)
- (insert "\n")
- (goto-char (point-min))
- (save-restriction
- (if (search-forward "\n\n" nil 'noerror)
- (progn
- (setq nov-mid (count-lines (point) (point-max)))
- (narrow-to-region (point-min) (1- (point))))
- (setq nov-mid 0))
- (goto-char (point-min))
- (delete-char 1)
- (nnheader-fold-continuation-lines)
- (setq nov (nnheader-parse-head 'naked)
- field (or (mail-header-lines nov) 0)))
- (if (or (zerop field) (nnmaildir--param pgname 'distrust-Lines:)) nil
- (setq nov-mid field))
- (setq nov-mid (number-to-string nov-mid)
- nov-mid (concat (number-to-string attr) "\t" nov-mid)
- field (or (mail-header-references nov) "")
- pos 0)
- (save-match-data
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq nov-mid (concat field "\t" nov-mid)
- extra (mail-header-extra nov)
- nov-end "")
- (while extra
- (setq field (car extra) extra (cdr extra)
- val (cdr field) field (symbol-name (car field))
- pos 0)
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq pos 0)
- (while (string-match "\t" val pos)
- (aset val (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq nov-end (concat nov-end "\t" field ": " val)))
- (setq nov-end (if (zerop (length nov-end)) "" (substring nov-end 1))
- field (or (mail-header-subject nov) "")
- pos 0)
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq nov-beg field
- field (or (mail-header-from nov) "")
- pos 0)
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq nov-beg (concat nov-beg "\t" field)
- field (or (mail-header-date nov) "")
- pos 0)
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq nov-beg (concat nov-beg "\t" field)
- field (mail-header-id nov)
- pos 0)
- (while (string-match "\t" field pos)
- (aset field (match-beginning 0) ? )
- (setq pos (match-end 0)))
- (setq msgid field))
- (if (or (null msgid) (nnheader-fake-message-id-p msgid))
- (setq msgid (concat "<" prefix "@nnmaildir>")))
- (erase-buffer)
- (setq nov (nnmaildir--nov-new))
- (nnmaildir--nov-set-beg nov nov-beg)
- (nnmaildir--nov-set-mid nov nov-mid)
- (nnmaildir--nov-set-end nov nov-end)
- (nnmaildir--nov-set-mtime nov mtime)
- (nnmaildir--nov-set-neh nov (copy-sequence nnmail-extra-headers))
- (prin1 (list msgid nov) (current-buffer))
- (setq file (concat novfile ":"))
- (nnmaildir--unlink file)
- (write-region (point-min) (point-max) file nil 'no-message))
+ (set-buffer (get-buffer-create " *nnmaildir nov*"))
+ (when (file-exists-p novfile) ;; If not, force reparsing the message.
+ (if nov nil ;; It's already in memory.
+ ;; Else read the data from the NOV file.
+ (erase-buffer)
+ (nnheader-insert-file-contents novfile)
+ (setq nov (read (current-buffer)))
+ (nnmaildir--art-set-msgid article (car nov))
+ (setq nov (cadr nov)))
+ ;; If the NOV's modtime matches the file's current modtime,
+ ;; and it has the right length (i.e., it wasn't produced by
+ ;; a too-much older version of nnmaildir), then we may use
+ ;; this NOV data rather than parsing the message file,
+ ;; unless nnmail-extra-headers has been augmented since this
+ ;; data was last parsed.
+ (when (and (equal mtime (nnmaildir--nov-get-mtime nov))
+ (= (length nov) (length (nnmaildir--nov-new))))
+ ;; This NOV data is potentially up-to-date.
+ (setq old-neh (nnmaildir--nov-get-neh nov)
+ new-neh nnmail-extra-headers)
+ (if (equal new-neh old-neh) (throw 'return nov)) ;; Common case.
+ ;; They're not equal, but maybe the new is a subset of the old...
+ (if (null new-neh) (throw 'return nov))
+ (while new-neh
+ (if (memq (car new-neh) old-neh)
+ (progn
+ (setq new-neh (cdr new-neh))
+ (if new-neh nil (throw 'return nov)))
+ (setq new-neh nil)))))
+ ;; Parse the NOV data out of the message.
+ (erase-buffer)
+ (nnheader-insert-file-contents file)
+ (insert "\n")
+ (goto-char (point-min))
+ (save-restriction
+ (if (search-forward "\n\n" nil 'noerror)
+ (progn
+ (setq nov-mid (count-lines (point) (point-max)))
+ (narrow-to-region (point-min) (1- (point))))
+ (setq nov-mid 0))
+ (goto-char (point-min))
+ (delete-char 1)
+ (nnheader-fold-continuation-lines)
+ (setq nov (nnheader-parse-head 'naked)
+ field (or (mail-header-lines nov) 0)))
+ (if (or (zerop field) (nnmaildir--param pgname 'distrust-Lines:)) nil
+ (setq nov-mid field))
+ (setq nov-mid (number-to-string nov-mid)
+ nov-mid (concat (number-to-string attr) "\t" nov-mid)
+ field (or (mail-header-references nov) "")
+ pos 0)
+ (save-match-data
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq nov-mid (concat field "\t" nov-mid)
+ extra (mail-header-extra nov)
+ nov-end "")
+ (while extra
+ (setq field (car extra) extra (cdr extra)
+ val (cdr field) field (symbol-name (car field))
+ pos 0)
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq pos 0)
+ (while (string-match "\t" val pos)
+ (aset val (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq nov-end (concat nov-end "\t" field ": " val)))
+ (setq nov-end (if (zerop (length nov-end)) "" (substring nov-end 1))
+ field (or (mail-header-subject nov) "")
+ pos 0)
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq nov-beg field
+ field (or (mail-header-from nov) "")
+ pos 0)
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq nov-beg (concat nov-beg "\t" field)
+ field (or (mail-header-date nov) "")
+ pos 0)
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq nov-beg (concat nov-beg "\t" field)
+ field (mail-header-id nov)
+ pos 0)
+ (while (string-match "\t" field pos)
+ (aset field (match-beginning 0) ? )
+ (setq pos (match-end 0)))
+ (setq msgid field))
+ (if (or (null msgid) (nnheader-fake-message-id-p msgid))
+ (setq msgid (concat "<" prefix "@nnmaildir>")))
+ (erase-buffer)
+ (setq nov (nnmaildir--nov-new))
+ (nnmaildir--nov-set-beg nov nov-beg)
+ (nnmaildir--nov-set-mid nov nov-mid)
+ (nnmaildir--nov-set-end nov nov-end)
+ (nnmaildir--nov-set-mtime nov mtime)
+ (nnmaildir--nov-set-neh nov (copy-sequence nnmail-extra-headers))
+ (prin1 (list msgid nov) (current-buffer))
+ (setq file (concat novfile ":"))
+ (nnmaildir--unlink file)
+ (write-region (point-min) (point-max) file nil 'no-message))