- (insert "Subject: " (file-name-nondirectory file) "\n"
- "Message-ID: <nneething-"
- (int-to-string
- (setq nneething-message-id-number
- (1+ nneething-message-id-number)))
- "@" (system-name) ">\n"
- "Date: " (current-time-string (nth 5 atts)) "\n"
- (nneething-from-line (nth 2 atts))
- "Chars: " (int-to-string (nth 7 atts)) "\n")))
-
-(defun nneething-from-line (uid)
- (let ((login (condition-case nil
- (user-login-name uid)
- (error
- (cond ((= uid (user-uid)) (user-login-name))
- ((zerop uid) "root")
- (t (int-to-string uid))))))
- (name (condition-case nil
- (user-full-name uid)
- (error
- (cond ((= uid (user-uid)) (user-full-name))
- ((zerop uid) "Ms. Root"))))))
- (concat "From: " login "@" (system-name)
+ (insert
+ "Subject: " (file-name-nondirectory file) (or extra-msg "") "\n"
+ "Message-ID: <nneething-" (nneething-encode-file-name file)
+ "@" (system-name) ">\n"
+ (if (equal '(0 0) (nth 5 atts)) ""
+ (concat "Date: " (current-time-string (nth 5 atts)) "\n"))
+ (or (when buffer
+ (with-current-buffer buffer
+ (when (re-search-forward "<[a-zA-Z0-9_]@[-a-zA-Z0-9_]>" 1000 t)
+ (concat "From: " (match-string 0) "\n"))))
+ (nneething-from-line (nth 2 atts) file))
+ (if (> (string-to-number (int-to-string (nth 7 atts))) 0)
+ (concat "Chars: " (int-to-string (nth 7 atts)) "\n")
+ "")
+ (if buffer
+ (with-current-buffer buffer
+ (concat "Lines: " (int-to-string
+ (count-lines (point-min) (point-max)))
+ "\n"))
+ "")
+ (if mime-type
+ (concat "Content-Type: " mime-type
+ (if mime-charset
+ (concat "; charset="
+ (if (stringp mime-charset)
+ mime-charset
+ (symbol-name mime-charset)))
+ "")
+ (if mime-encoding
+ (concat "\nContent-Transfer-Encoding: " mime-encoding)
+ "")
+ "\nMIME-Version: 1.0\n")
+ ""))))
+
+(defun nneething-from-line (uid &optional file)
+ "Return a From header based of UID."
+ (let* ((login (condition-case nil
+ (user-login-name uid)
+ (error
+ (cond ((= uid (user-uid)) (user-login-name))
+ ((zerop uid) "root")
+ (t (int-to-string uid))))))
+ (name (condition-case nil
+ (user-full-name uid)
+ (error
+ (cond ((= uid (user-uid)) (user-full-name))
+ ((zerop uid) "Ms. Root")))))
+ (host (if (string-match "\\`/[^/@]*@\\([^:/]+\\):" file)
+ (prog1
+ (substring file
+ (match-beginning 1)
+ (match-end 1))
+ (when (string-match
+ "/\\(users\\|home\\)/\\([^/]+\\)/" file)
+ (setq login (substring file
+ (match-beginning 2)
+ (match-end 2))
+ name nil)))
+ (system-name))))
+ (concat "From: " login "@" host