* gnus-spec.el (gnus-parse-format): %C is a complex format.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 8 Jan 2003 04:46:16 +0000 (04:46 +0000)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Wed, 8 Jan 2003 04:46:16 +0000 (04:46 +0000)
(gnus-parse-format): Change to %~.

* message.el (message-generate-headers): Don't generate optional
empty headers.

lisp/ChangeLog
lisp/gnus-spec.el
lisp/message.el

index 54ec47e..b40b5f3 100644 (file)
@@ -1,3 +1,11 @@
+2003-01-08  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-spec.el (gnus-parse-format): %C is a complex format.
+       (gnus-parse-format): Change to %~.
+
+       * message.el (message-generate-headers): Don't generate optional
+       empty headers.
+
 2003-01-07  Reiner Steib  <Reiner.Steib@gmx.de>
 
        * message.el (message-cross-post-default)
index cf65253..6153848 100644 (file)
@@ -409,14 +409,14 @@ characters when given a pad value."
   ;; them will have the balloon-help text property.
   (let ((case-fold-search nil))
     (if (string-match
-        "\\`\\(.*\\)%[0-9]?[{(«]\\(.*\\)%[0-9]?[»})]\\(.*\n?\\)\\'\\|%[-0-9]*="
+        "\\`\\(.*\\)%[0-9]?[{(«]\\(.*\\)%[0-9]?[»})]\\(.*\n?\\)\\'\\|%[-0-9]*=\\|%[-0-9]*~"
         format)
        (gnus-parse-complex-format format spec-alist)
       ;; This is a simple format.
       (gnus-parse-simple-format format spec-alist insert))))
 
 (defun gnus-parse-complex-format (format spec-alist)
-  (let (found-C)
+  (let ((cursor-spec nil))
     (save-excursion
       (gnus-set-work-buffer)
       (insert format)
@@ -445,9 +445,9 @@ characters when given a pad value."
       ;; Convert point position commands.
       (goto-char (point-min))
       (let ((case-fold-search nil))
-       (while (re-search-forward "%\\([-0-9]+\\)?C" nil t)
+       (while (re-search-forward "%\\([-0-9]+\\)?~" nil t)
          (replace-match "\"(point)\"" t t)
-         (setq found-C t)))
+         (setq cursor-spec t)))
       ;; Convert TAB commands.
       (goto-char (point-min))
       (while (re-search-forward "%\\([-0-9]+\\)=" nil t)
@@ -455,7 +455,7 @@ characters when given a pad value."
       ;; Convert the buffer into the spec.
       (goto-char (point-min))
       (let ((form (read (current-buffer))))
-       (if found-C
+       (if cursor-spec
            `(let (gnus-position)
               ,@(gnus-complex-form-to-spec form spec-alist)
               (if gnus-position
index d82916d..ee05396 100644 (file)
@@ -4566,6 +4566,7 @@ Headers already prepared in the buffer are not modified."
           (User-Agent message-newsreader)
           (Expires (message-make-expires))
           (case-fold-search t)
+          (optionalp nil)
           header value elem)
       ;; First we remove any old generated headers.
       (let ((headers message-deletable-headers))
@@ -4587,7 +4588,8 @@ Headers already prepared in the buffer are not modified."
        (setq elem (pop headers))
        (if (consp elem)
            (if (eq (car elem) 'optional)
-               (setq header (cdr elem))
+               (setq header (cdr elem)
+                     optionalp t)
              (setq header (car elem)))
          (setq header elem))
        (when (or (not (re-search-forward
@@ -4603,7 +4605,7 @@ Headers already prepared in the buffer are not modified."
                    ;; The header was found.  We insert a space after the
                    ;; colon, if there is none.
                    (if (/= (char-after) ? ) (insert " ") (forward-char 1))
-                   ;; Find out whether the header is empty...
+                   ;; Find out whether the header is empty.
                    (looking-at "[ \t]*\n[^ \t]")))
          ;; So we find out what value we should insert.
          (setq value
@@ -4660,7 +4662,10 @@ Headers already prepared in the buffer are not modified."
                ;; The value of this header was empty, so we clear
                ;; totally and insert the new value.
                (delete-region (point) (gnus-point-at-eol))
-               (insert value))
+               ;; If the header is optional, and the header was
+               ;; empty, we con't insert it anyway.
+               (unless optionalp
+                 (insert value)))
              ;; Add the deletable property to the headers that require it.
              (and (memq header message-deletable-headers)
                   (progn (beginning-of-line) (looking-at "[^:]+: "))