diff --git a/src/ChangeLog b/src/ChangeLog
index 9ea3c6a6eb23782b93247c3f18c7a7a0ce063a4b..f25d1fff82a350aae1e6741910fc311d698a88c9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+1999-10-09  David Byers  <davby@ida.liu.se>
+
+	* view-text.el: Updated all functions to format imported e-mail
+	properly
+
+1999-09-29  David Byers  <davby@ida.liu.se>
+
+	* edit-text.el (kom-insert-last-info-nodename): New command.
+	(kom-yank-info-nodename): New command.
+
+1999-08-28  David Byers  <davby@ida.liu.se>
+
+	* completing-read.el (lyskom-read-session-resolve-ambiguity): Bug
+	fix in printing session list.
+
 Tue Sep 28 14:56:43 1999  David Byers  <davby@sen2.ida.liu.se>
 
 	* Released 0.46-BETA-7
diff --git a/src/TODO b/src/TODO
index 2ba588941a1755e3c6c9432b3c1cd9edbffe003b..970ce78b0b68618273a1696d191c6a88a9037e4c 100644
--- a/src/TODO
+++ b/src/TODO
@@ -3,9 +3,18 @@
 Att g�ra i elisp-klienten
 =========================
 
+N�gon form at reply till importerade brev som anv�nder mx-reply-to
+eller mx-to, mx-cc om de finns.
+
+
             Om du fixar n�gonting som st�r med p� den h�r
             listan, gl�m inte att ta bort det fr�n listan!
 
+Testa vad som h�nder om man har en ogiltig misc-item eller aux-item i
+headersarna n�r man adderar en mottagare eller flyttar ett inl�gg
+eller adderar en aux-item eller tar bord en aux-item.
+
+
 initiate-get-membership skulle kunna fylla i positionen f�r
 medlemskapet automatiskt. Tyv�rr g�r det inte att g�ra s� i
 query-read-texts.
diff --git a/src/async.el b/src/async.el
index 325ab717dfc85834b7576c71ac44d58ab8c9a6c2..623e86c95b8416ac8032793636d46699c19ff229 100644
--- a/src/async.el
+++ b/src/async.el
@@ -278,10 +278,7 @@ this function shall be with current-buffer the BUFFER."
     (lyskom-format-insert-before-prompt 'no-longer-member-n conf-no))
   (lyskom-remove-membership conf-no lyskom-membership)
   (when (eq conf-no lyskom-current-conf)
-    (set-read-list-empty lyskom-reading-list)
-    (lyskom-run-hook-with-args 'lyskom-change-conf-hook
-                               lyskom-current-conf 0)
-    (setq lyskom-current-conf 0))
+    (lyskom-leave-current-conf))
   (read-list-delete-read-info conf-no lyskom-to-do-list)
   (lyskom-update-prompt))
 
@@ -303,10 +300,7 @@ this function shall be with current-buffer the BUFFER."
     (cond ((membership-type->passive (membership->type membership))
            (lyskom-replace-membership membership lyskom-membership)
            (when (eq conf-no lyskom-current-conf)
-             (set-read-list-empty lyskom-reading-list)
-             (lyskom-run-hook-with-args 'lyskom-change-conf-hook
-                                        lyskom-current-conf 0)
-             (setq lyskom-current-conf 0))
+             (lyskom-leave-current-conf))
            (read-list-delete-read-info conf-no lyskom-to-do-list)
            (lyskom-update-prompt))
 
diff --git a/src/aux-items.el b/src/aux-items.el
index 053678cd1cf41c85e787e74ebd9d7c763fb368c9..e2f718f4744475422719477d01335edbe680a0b1 100644
--- a/src/aux-items.el
+++ b/src/aux-items.el
@@ -107,6 +107,13 @@ return non-nil if the item is to be included in the list."
       (setq item-list (cdr item-list)))
     (nreverse result)))
 
+                                        
+(defun lyskom-get-aux-item (item-list tag)
+  "Return all aux-items in ITEM-LIST with tag TAG."
+  (lyskom-match-aux-items item-list
+                          (lambda (el) (eq (aux-item->tag el) tag))))
+
+
 (defun lyskom-aux-item-terminating-button (item obj)
   (if obj
        (lyskom-format " %#1@%[[*]%]" 
diff --git a/src/commands2.el b/src/commands2.el
index 978492e8e19d0d3ffd573eb9cb60f515a5ae2065..7675ff69d7cb496f1845c8d45a273ff7e7ff0d90 100644
--- a/src/commands2.el
+++ b/src/commands2.el
@@ -2248,3 +2248,17 @@ Return-value: 'no-session if there is no suitable session to switch to
                                    (lyskom-create-aux-item-flags
                                     nil nil nil nil nil nil nil nil) 0 ""))))
                    (cache-del-text-stat text-no)))))))
+
+(def-kom-command kom-review-mail-headers (&optional text-no)
+  "Review the mail headers of an imported message"
+  (interactive (list (lyskom-read-text-no-prefix-arg
+                      'review-mail-headers-to-what t)))
+  (let* ((text-stat (blocking-do 'get-text-stat text-no))
+         (headers (and text-stat (lyskom-get-aux-item (text-stat->aux-items text-stat) 24))))
+    (cond ((null text-stat) (lyskom-format-insert 'no-such-text-no text-no))
+          ((null headers) (lyskom-format-insert 'no-mail-headers text-no))
+          (t (lyskom-format-insert 'mail-headers-for text-no)
+             (mapcar (lambda (el) 
+                       (lyskom-insert (aux-item->data el))
+                       (lyskom-insert "\n"))
+                     headers)))))
diff --git a/src/completing-read.el b/src/completing-read.el
index c17281d053f0f86585792ae6b60db92315e8c77d..8c7eae419afc18d5e2f1d81f15c91be6cecd60d4 100644
--- a/src/completing-read.el
+++ b/src/completing-read.el
@@ -953,9 +953,8 @@ the LysKOM rules of string matching."
 					 lyskom-session-no)
 				     "*" " "))
 			 (session-info->pers-no info)
-			 (if (uconf-stat->name confconfstat)
-			     confconfstat
-			   (lyskom-get-string 'not-present-anywhere)))
+			 (or confconfstat
+                             (lyskom-get-string 'not-present-anywhere)))
 			(lyskom-format-insert
 			 format-string-p
 			 ""
diff --git a/src/edit-text.el b/src/edit-text.el
index 36fae99528982e78b2e2be177828a5b869d38a71..9a7c1d9a8be170a33807f9937518a052be738255 100644
--- a/src/edit-text.el
+++ b/src/edit-text.el
@@ -1033,6 +1033,31 @@ text is a member of some recipient of this text."
     (sit-for 0)))
 
 
+;;; ============================================================
+;;; Info node stuff
+
+(defun kom-yank-info-nodename ()
+  "Put the current Info-node on the kill-ring."
+  (interactive)
+  (kill-new (format "*Note %s: (%s)%s,"
+		    Info-current-node
+		    (file-name-nondirectory Info-current-file)
+		    Info-current-node)))
+
+(defun kom-insert-last-info-nodename ()
+  "Insert a reference to the most recently visited info node."
+  (interactive)
+  (condition-case nil
+      (let ((link nil))
+        (save-excursion
+          (set-buffer (get-buffer "*info*"))
+          (setq link (format "*Note %s: (%s)%s,"
+                             Info-current-node
+                             (file-name-nondirectory Info-current-file)
+                             Info-current-node)))
+        (insert link))
+    (error (lyskom-message (lyskom-get-string 'cant-find-info-node)))))
+
 ;;; ================================================================
 ;;;	  Add recipient, copy-recipient - Addera mottagare 
 ;;;
diff --git a/src/english-strings.el b/src/english-strings.el
index 04487c1ba8f6d5cee885af1357f4f762f28e85a7..b2d062e52c9fb3b5f6f9a7bf732629452dcbbc21 100644
--- a/src/english-strings.el
+++ b/src/english-strings.el
@@ -760,6 +760,7 @@ Help: \\[describe-mode] ---")
     (no-get-text . "You were not allowed to retrieve the text.")
     (unknown-header . "Unknown header")
     (transform-error . "Skicka in oformatterat (%#1s)? ")
+    (cant-find-info-node . "Can't find the info buffer")
 
     ; From view-text.el:
     (line . " /1 line/ ")
diff --git a/src/swedish-strings.el b/src/swedish-strings.el
index b413054253255fba9ee6b60f0337952e0c3f3314..45deb235383ab1704c1be30d852f19b18216c025 100644
--- a/src/swedish-strings.el
+++ b/src/swedish-strings.el
@@ -768,6 +768,7 @@ Annat se \\[describe-mode] ---")
     (no-get-text . "Du fick inte h�mta texten.")
     (unknown-header . "Ok�nd information p� raden")
     (transform-error . "Skicka in oformatterat (%#1s)? ")
+    (cant-find-info-node . "Hittar inte info-bufferten")
 
     ;; From view-text.el:
     (line . " /1 rad/ ")
@@ -791,11 +792,17 @@ Annat se \\[describe-mode] ---")
     (yesterday . "ig�r")
     (no-such-text-no . "Det finns inget s�dant inl�gg. (%#1:n)\n")
     (time-yyyy-mm-dd . "%4#1d-%02#2d-%02#3d")
+    (text-created-at . "Skapad: %#1s\n")
+    (text-imported-at . "Importerad: %#1s\n")
+    (text-imported-at-by . "Importerad: %#1s av %#2P\n")
 
     (head-Subject . "�rende: ")
     (Recipient . "Mottagare")
     (Extra-recipient . "Extra kopia")
     (Hidden-recipient . "F�r k�nnedom")
+    (mx-Recipient . "Extern mottagare")
+    (mx-Extra-recipient . "Extern kopiemottagare")
+    (mx-Extern-reply-to . "Externa svar till")
     (Strange-recipient . "Underlig mottagare")
     (send-at . "    S�nt:     %#1s\n")
     (sent-by . "    S�nt av %#1P\n")
@@ -811,6 +818,12 @@ Annat se \\[describe-mode] ---")
     (comment-in-text-by . "Kommentar i text %#1n av %#2P")
     (footnote-in-text-by . "Fotnot i text %#1n av %#2P")
 
+    (attachment-to-text . "Bilaga till text %#1n")
+    (attachment-in-text . "Bilaga i text %#1n")
+    
+    (envelope-sender . "S�nt av: %#1s\n")
+    (attachment-filename . "Bilagans filnamn: \"%#1s\"\n")
+
     (written-by . " av %#1P\n")
 
     ;; From async.el:
@@ -1338,6 +1351,12 @@ Du m
     (what-request-confirm-no . "Vilken text vill du ha l�sbekr�ftelse till: ")
     (adding-request-confirm . "Beg�r l�sbekr�ftelse till inl�gg %#1n...")
     (already-request-confirm . "Inl�gg %#1n har redan beg�ran om l�sbekr�ftelse.\n")
+
+    (review-mail-headers-to-what . "Vilken texts mailhuvuden vill du se? ")
+    (no-mail-headers . "Inl�gg %#1n har inga mailhuvuden\n")
+    (mail-headers-for . "Mailheaders f�r inl�gg %#1n:\n")
+    (email-name-prefix . "")
+    (email-name-suffix . "")
 ))
 
 
@@ -1493,6 +1512,8 @@ Du m
     (kom-add-no-comments      . "F�rhindra kommentarer")
     (kom-add-private-answer   . "Beg�r personligt svar")
     (kom-add-request-confirm  . "Beg�r l�sbekr�ftelse")
+
+    (kom-review-mail-headers  . "�terse mailhuvuden")
     ))
 
 (lyskom-language-var lyskom-language-codes sv
diff --git a/src/utilities.el b/src/utilities.el
index 0074306d54ffba3034ebff6fd0572c9b5b12c420..616177ad95e7ddbe73819b58b23e2be5655d8184 100644
--- a/src/utilities.el
+++ b/src/utilities.el
@@ -92,6 +92,15 @@ If BEFORE is not in the list, then insert EL at the end of the list."
                    (cons el (memq before list)))
            list)))
 
+(defun lyskom-move-in-list (el list pos)
+  "Destructively move EL within LIST so it appears at position POS."
+  (when (memq el list)
+    (setq list (delq el list))
+    (cond ((eq 0 pos) (setq list (cons el list)))
+          (t (setcdr (nthcdr (1- pos) list)
+                     (cons el (nthcdr pos list))))))
+  list)
+
 ;;;
 ;;; +++ FIXME: If cl.el can be guaranteed, this is pointless.
 ;;;
diff --git a/src/vars.el.in b/src/vars.el.in
index 87cb11d0a10ccf86aee04efa317911095ab5e64a..4468041a5c5a7527d3c5aa14b02d768e694f3a2f 100644
--- a/src/vars.el.in
+++ b/src/vars.el.in
@@ -1176,6 +1176,8 @@ Users are encouraged to use their best sense of humor."
     kom-add-private-answer
     kom-add-no-comments
     kom-add-request-confirm
+
+    kom-review-mail-headers
     ))
 
 ;;; ================================================================
diff --git a/src/view-text.el b/src/view-text.el
index f16cf6b22be6f5869704685ca5bbe6570bfa6eeb..e70c557aed15bd940c073f8f54f685e436ea4a13 100644
--- a/src/view-text.el
+++ b/src/view-text.el
@@ -85,18 +85,58 @@ Note that this function must not be called asynchronously."
 	       (setq todo 'next-text))
 	   (blocking-do-multiple ((text-stat (get-text-stat text-no))
 				  (text (get-text text-no)))
-	     (if (and text-stat
-		      text)
+	     (if (and text-stat text)
 		 (progn
                    (run-hooks 'lyskom-view-text-hook)
 		   ;; Use a marker, because the buffer may lose data
 		   ;; at the top if kom-max-buffer-size is set.
 		   (setq start (point-max-marker))
-		   (lyskom-format-insert "%#1n " 
-					 text-stat)
-		   (lyskom-print-date-and-time (text-stat->creation-time
-						text-stat)
-					       'time-y-m-d-h-m)
+		   (lyskom-format-insert "%#1n " text-stat)
+                   (let ((mx-date (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 21)))
+                         (mx-from (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 17)))
+                         (mx-author (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 16)))
+                         (mx-to (lyskom-get-aux-item (text-stat->aux-items text-stat) 19))
+                         (mx-cc (lyskom-get-aux-item (text-stat->aux-items text-stat) 20))
+                         (mx-filename (lyskom-get-aux-item (text-stat->aux-items text-stat) 10104))
+                         (mx-sender (lyskom-get-aux-item (text-stat->aux-items text-stat) 10103))
+                         (mx-reply-to (lyskom-get-aux-item (text-stat->aux-items text-stat) 28)))
+                         
+
+                     ;; Insert date
+
+                     (if mx-date
+                         (if (and 
+                              (condition-case nil
+                                  (progn (require 'calendar)
+                                         (require 'cal-iso)
+                                         t)
+                                nil)
+                              (string-match "\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\) \\([0-9][0-9]\\):\\([0-9][0-9]\\):\\([0-9][0-9]\\) \\([-+][0-9][0-9]\\)?\\([0-9][0-9]\\)?"
+                                           (aux-item->data mx-date)))
+                              (let* ((secs (string-to-number (match-string 6 (aux-item->data mx-date))))
+                                     (mins (string-to-number (match-string 5 (aux-item->data mx-date))))
+                                     (hour (string-to-number (match-string 4 (aux-item->data mx-date))))
+                                     (mday (string-to-number (match-string 3 (aux-item->data mx-date))))
+                                     (mon  (string-to-number (match-string 2 (aux-item->data mx-date))))
+                                     (year (string-to-number (match-string 1 (aux-item->data mx-date))))
+                                     (tzhr (match-string 7 (aux-item->data mx-date)))
+                                     (tzmin (or (match-string 8 (aux-item->data mx-date)) ""))
+                                     (wday (elt 
+                                            (calendar-iso-from-absolute
+                                             (calendar-absolute-from-gregorian
+                                              (list mon mday year)))
+                                            1)))
+                             (lyskom-print-date-and-time
+                              (lyskom-create-time secs mins hour mday mon (- year 1900) wday 0 nil))
+                             (when tzhr 
+                               (lyskom-format-insert " %#1s%#2s " tzhr tzmin)))
+                           (lyskom-format-insert (aux-item->data mx-date)))
+                       (lyskom-print-date-and-time (text-stat->creation-time
+                                                    text-stat)
+                                                   'time-y-m-d-h-m))
+
+                     ;; Insert number of lines
+
 		   (lyskom-insert 
 		    (if (= 1 (text-stat->no-of-lines text-stat))
 			(lyskom-get-string 'line)
@@ -107,12 +147,61 @@ Note that this function must not be called asynchronously."
 					   2 ; compatibility with old KOM. /lw
 					 n)))))
 		   
-		   (if (eq filter 'dontshow)
-		       (lyskom-format-insert "%#1P %#2s\n"
-					     (text-stat->author text-stat)
-					     (lyskom-get-string 'filtered))
-		     (lyskom-format-insert "%#1P\n"
-					   (text-stat->author text-stat)))
+                   ;; Insert the author
+
+                   (lyskom-insert (or (lyskom-format-mx-author mx-from mx-author) ""))
+                   (unless (or mx-from mx-author)
+                     (lyskom-format-insert "%#1P" (text-stat->author text-stat)))
+
+                   ;; Insert filtration prompt
+
+		   (when (eq filter 'dontshow)
+                     (lyskom-insert " ")
+                     (lyskom-insert (lyskom-get-string 'filtered)))
+                   (lyskom-insert "\n")
+
+                   ;; Insert sender
+
+                   (when mx-sender
+                     (lyskom-format-insert 'envelope-sender 
+                                           (aux-item->data (car mx-sender))))
+                   (when mx-filename
+                     (lyskom-format-insert 'attachment-filename
+                                           (aux-item->data (car mx-filename))))
+
+                   ;; Insert imported at
+
+                   (cond ((and mx-from (text-stat->author text-stat))
+                          (lyskom-format-insert 'text-imported-at-by
+                                                (lyskom-return-date-and-time (text-stat->creation-time
+                                                                              text-stat)
+                                                                             'time-y-m-d-h-m)
+                                                (text-stat->author text-stat)))
+                         (mx-from
+                          (lyskom-format-insert 'text-imported-at
+                                                (lyskom-return-date-and-time (text-stat->creation-time
+                                                                              text-stat)
+                                                                             'time-y-m-d-h-m)))
+                         (mx-date (lyskom-format-insert 'text-created-at
+                                                        (lyskom-return-date-and-time (text-stat->creation-time
+                                                                                      text-stat)
+                                                                                     'time-y-m-d-h-m))))
+                   (mapcar (lambda (el)
+                             (lyskom-format-insert "%#1s: %#2s\n"
+                                                   (lyskom-get-string 'mx-Recipient)
+                                                   (aux-item->data el)))
+                           mx-to)
+                   (mapcar (lambda (el)
+                             (lyskom-format-insert "%#1s: %#2s\n"
+                                                   (lyskom-get-string 'mx-Extra-recipient)
+                                                   (aux-item->data el)))
+                           mx-cc)
+                   (mapcar (lambda (el)
+                             (lyskom-format-insert "%#1s: %#2s\n"
+                                                   (lyskom-get-string 'mx-Reply-to)
+                                                   (aux-item->data el)))
+                           mx-reply-to)
+
 		   
 		   (setq end (point-max))
 
@@ -144,19 +233,23 @@ Note that this function must not be called asynchronously."
                              (if lyskom-show-comments ; +++SOJGE
                                  (lyskom-print-header-comm
                                   (misc-info->comm-in misc)
-                                  misc))))
+                                  misc
+                                  text-stat))))
 			  ((eq type 'FOOTN-IN)
 			   (if kom-reading-puts-comments-in-pointers-last
 			       nil
 			     (lyskom-print-header-comm
 			      (misc-info->footn-in misc)
-			      misc)))
+			      misc
+                              text-stat)))
 			  ((eq type 'COMM-TO)
 			   (lyskom-print-header-comm (misc-info->comm-to misc)
-						     misc))
+						     misc
+                                                     text-stat))
 			  ((eq type 'FOOTN-TO)
 			   (lyskom-print-header-comm (misc-info->footn-to misc)
-						     misc))
+						     misc
+                                                     text-stat))
 			  )))
 
                      ;;
@@ -238,7 +331,7 @@ Note that this function must not be called asynchronously."
 			 (lyskom-follow-comments text-stat
 						 conf-stat mark-as-read
 						 priority build-review-tree)))
-		   )
+		   ))
 	       (lyskom-format-insert 'no-such-text-no text-no))
              (let ((aux-items (text-stat->aux-items text-stat)))
                (while aux-items
@@ -530,7 +623,7 @@ blocking-do."
                  (t
                   "(%#1n)"))
            text
-           (or author author-name)
+           (or author-name author)
            end-dash
            format-flag-string))
 
@@ -596,11 +689,16 @@ blocking-do."
   "Insert the name of a conference at a previously reserved place."
   (let* ((text-stat (elt (defer-info->data defer-info) 0))
          (format-flags (elt (defer-info->data defer-info) 1))
-         (name (cond (conf-stat (conf-stat->name conf-stat))
-                      ((= (defer-info->call-par defer-info) 0)
-                       (lyskom-get-string 'person-is-anonymous))
-                      (t (lyskom-format 'person-does-not-exist
-                                        (defer-info->call-par defer-info))))))
+         (name (cond (conf-stat nil)
+                     ((= (defer-info->call-par defer-info) 0)
+                      (lyskom-get-string 'person-is-anonymous))
+                     (t (lyskom-format 'person-does-not-exist
+                                       (defer-info->call-par defer-info)))))
+         (mx-from (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 17)))
+         (mx-author (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 16))))
+
+    (setq name (or (lyskom-format-mx-author mx-from mx-author) name))
+
     (lyskom-replace-deferred defer-info 
                              (lyskom-format-text-footer text-stat
                                                         conf-stat
@@ -775,13 +873,13 @@ Args: TEXT-STAT of the text being read."
       (cond
        ((eq type 'COMM-IN)
         (if lyskom-show-comments        ;+++SOJGE
-            (lyskom-print-header-comm (misc-info->comm-in misc) misc)))
+            (lyskom-print-header-comm (misc-info->comm-in misc) misc text-stat)))
        ((eq type 'FOOTN-IN)
-	(lyskom-print-header-comm (misc-info->footn-in misc) misc))))))
+	(lyskom-print-header-comm (misc-info->footn-in misc) misc text-stat))))))
 
 
 
-(defun lyskom-print-header-comm (text misc)
+(defun lyskom-print-header-comm (text misc read-text-stat)
   "Get author of TEXT-NO and print a header line."
   (let ((text-stat (if kom-deferred-printing
 		       (cache-get-text-stat text)
@@ -789,9 +887,9 @@ Args: TEXT-STAT of the text being read."
 
     ;; Print information about the link
     (cond (text-stat
-           (lyskom-insert-header-comm text-stat misc))
+           (lyskom-insert-header-comm text-stat misc read-text-stat))
           ((not kom-deferred-printing) 
-           (lyskom-insert-header-comm text-stat misc))
+           (lyskom-insert-header-comm text-stat misc read-text-stat))
           (t
            (let ((defer-info (lyskom-create-defer-info
                               'get-text-stat
@@ -800,7 +898,7 @@ Args: TEXT-STAT of the text being read."
                               (point-max-marker)
                               (length lyskom-defer-indicator)
                               nil       ; Filled in later
-                              misc)))
+                              (list misc read-text-stat))))
              (lyskom-format-insert "%#1s\n" lyskom-defer-indicator)
              (lyskom-defer-insertion defer-info))))
 
@@ -814,21 +912,43 @@ Args: TEXT-STAT of the text being read."
 
 (defun lyskom-insert-deferred-header-comm (text-stat defer-info)
   (let* ((author (if text-stat (text-stat->author text-stat) nil))
-	 (misc (defer-info->data defer-info))
+	 (misc (elt (defer-info->data defer-info) 0))
+	 (read-text-stat (elt (defer-info->data defer-info) 1))
 	 (type (misc-info->type misc))
+         (mx-from (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 17)))
+         (mx-author (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 16)))
+         (mx-attachments-in (mapcar
+                             (lambda (el)
+                               (string-to-number (aux-item->data el)))
+                             (lyskom-get-aux-item (text-stat->aux-items read-text-stat) 10101)))
+         (mx-belongs-to (mapcar
+                         (lambda (el)
+                           (string-to-number (aux-item->data el)))
+                         (lyskom-get-aux-item (text-stat->aux-items read-text-stat) 10100)))
 	 fmt data)
+
+    (setq author (or (lyskom-format-mx-author mx-from mx-author) author))
+    
     (cond
      ((eq type 'COMM-TO)
-      (setq fmt (if author 'comment-to-text-by 'comment-to-text)
+      (setq fmt (cond ((memq (misc-info->comm-to misc) mx-belongs-to) 'attachment-to-text)
+                      (author 'comment-to-text-by)
+                      (t 'comment-to-text))
 	    data (misc-info->comm-to misc)))
      ((eq type 'FOOTN-TO)
-      (setq fmt (if author 'footnote-to-text-by 'footnote-to-text)
+      (setq fmt (cond ((memq (misc-info->footn-to misc) mx-belongs-to) 'attachment-to-text)
+                      (author 'footnote-to-text-by)
+                      (t 'footnote-to-text))
 	    data (misc-info->footn-to misc)))
      ((eq type 'COMM-IN)
-      (setq fmt (if author 'comment-in-text-by 'comment-in-text)
+      (setq fmt (cond ((memq (misc-info->comm-in misc) mx-attachments-in) 'attachment-in-text)
+                      (author 'comment-in-text-by)
+                      (t 'comment-in-text))
 	    data (misc-info->comm-in misc)))
      ((eq type 'FOOTN-IN)
-      (setq fmt (if author 'footnote-in-text-by 'footnote-in-text)
+      (setq fmt (cond ((memq (misc-info->footn-in misc) mx-attachments-in) 'attachment-in-text)
+                      (author 'footnote-in-text-by)
+                      (t 'footnote-in-text))
 	    data(misc-info->footn-in misc)))) 
     (set-defer-info->format defer-info fmt)
     ; Note: author is ignored if fmt is not *-by
@@ -836,26 +956,62 @@ Args: TEXT-STAT of the text being read."
 
 
 
-(defun lyskom-insert-header-comm (text-stat misc)
+(defun lyskom-insert-header-comm (text-stat misc read-text-stat)
   "Get author of TEXT-NO and print a header line."
   ;;+++ error kommer att se annorlunda ut.
   (let ((author (if text-stat
 		    (text-stat->author text-stat)
 		  nil))
-	(type (misc-info->type misc)))
+        (mx-from (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 17)))
+        (mx-author (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 16)))
+        (mx-attachments-in (mapcar
+                            (lambda (el)
+                              (string-to-number (aux-item->data el)))
+                            (lyskom-get-aux-item (text-stat->aux-items read-text-stat) 10101)))
+        (mx-belongs-to (mapcar
+                        (lambda (el)
+                          (string-to-number (aux-item->data el)))
+                        (lyskom-get-aux-item (text-stat->aux-items read-text-stat) 10100)))
+        (type (misc-info->type misc)))
+
+    (setq author (or (lyskom-format-mx-author mx-from mx-author) author))
+    
     (cond
      ((eq type 'COMM-TO)
-      (lyskom-format-insert 'comment-to-text (misc-info->comm-to misc)))
+      (lyskom-format-insert (if (memq (misc-info->comm-to misc) mx-belongs-to)
+                                'attachment-to-text
+                              'comment-to-text)
+                            (misc-info->comm-to misc)))
      ((eq type 'FOOTN-TO)
-      (lyskom-format-insert 'footnote-to-text (misc-info->footn-to misc)))
+      (lyskom-format-insert (if (memq (misc-info->footn-to misc) mx-belongs-to)
+                                'attachment-to-text
+                              'footnote-to-text)
+                            (misc-info->footn-to misc)))
      ((eq type 'COMM-IN)
-      (lyskom-format-insert 'comment-in-text (misc-info->comm-in misc)))
+      (lyskom-format-insert (if (memq (misc-info->comm-in misc) mx-attachments-in)
+                                'attachment-in-text
+                              'comment-in-text)
+                            (misc-info->comm-in misc)))
      ((eq type 'FOOTN-IN)
-      (lyskom-format-insert 'footnote-in-text (misc-info->footn-in misc))))
+      (lyskom-format-insert (if (memq (misc-info->footn-in misc) mx-attachments-in)
+                                'attachment-in-text
+                              'footnote-in-text)
+                            (misc-info->footn-in misc))))
     (if author
 	(lyskom-format-insert 'written-by author)
       (lyskom-insert "\n"))))
 
+(defun lyskom-format-mx-author (mx-from mx-author)
+  (let ((author nil))
+    (when (or mx-from mx-author)
+      (setq author (lyskom-get-string 'email-name-prefix))
+      (when mx-author (setq author (concat author (aux-item->data mx-author))))
+      (when (and mx-from mx-author) (setq author (concat author " ")))
+      (when mx-from (setq author (concat author "<" (aux-item->data mx-from) ">")))
+      (setq author (concat (lyskom-get-string 'email-name-suffix) author))
+      )
+    author))
+    
 
 
 ;;; Local Variables: