*** empty log message ***
[gnus] / lisp / gnus-art.el
index 41820ca..164fbed 100644 (file)
@@ -413,8 +413,7 @@ The following additional specs are available:
   :group 'gnus-article-various)
 
 (defcustom gnus-article-prepare-hook nil
-  "*A hook called after an article has been prepared in the article buffer.
-If you want to run a special decoding program like nkf, use this hook."
+  "*A hook called after an article has been prepared in the article buffer."
   :type 'hook
   :group 'gnus-article-various)
 
@@ -615,7 +614,7 @@ on parts -- for instance, adding Vcard info to a database."
 (defvar gnus-inhibit-treatment nil
   "Whether to inhibit treatment.")
 
-(defcustom gnus-treat-highlight-signature 'last
+(defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
   "Highlight the signature."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
@@ -675,6 +674,12 @@ on parts -- for instance, adding Vcard info to a database."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
 
+(defcustom gnus-treat-strip-banner t
+  "Strip banners from articles.
+The banner to be stripped is specified in the `banner' group parameter."
+  :group 'gnus-article-treat
+  :type gnus-article-treat-custom)
+
 (defcustom gnus-treat-highlight-headers 'head
   "Highlight the headers."
   :group 'gnus-article-treat
@@ -705,6 +710,17 @@ on parts -- for instance, adding Vcard info to a database."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
 
+(defcustom gnus-treat-date-iso8601 nil
+  "Display the date in the ISO8601 format."
+  :group 'gnus-article-treat
+  :type gnus-article-treat-custom)
+
+(defcustom gnus-treat-date-user-defined nil
+  "Display the date in a user-defined format.
+The format is defined by the `gnus-article-time-format' variable."
+  :group 'gnus-article-treat
+  :type gnus-article-treat-custom)
+
 (defcustom gnus-treat-strip-trailing-blank-lines nil
   "Strip trailing blank lines."
   :group 'gnus-article-treat
@@ -736,7 +752,9 @@ on parts -- for instance, adding Vcard info to a database."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
 
-(defcustom gnus-treat-display-smileys (if gnus-xemacs t nil)
+(defcustom gnus-treat-display-smileys (if (and gnus-xemacs
+                                              (featurep 'xpm))
+                                         t nil)
   "Display smileys."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
@@ -746,17 +764,27 @@ on parts -- for instance, adding Vcard info to a database."
   :group 'gnus-article-treat
   :type gnus-article-treat-custom)
 
+(defcustom gnus-treat-capitalize-sentences nil
+  "Capitalize sentence-starting words."
+  :group 'gnus-article-treat
+  :type gnus-article-treat-custom)
+
+(defcustom gnus-treat-fill-long-lines nil
+  "Fill long lines."
+  :group 'gnus-article-treat
+  :type gnus-article-treat-custom)
+
 ;;; Internal variables
 
 (defvar article-goto-body-goes-to-point-min-p nil)
 
 (defvar gnus-article-mime-handle-alist-1 nil)
 (defvar gnus-treatment-function-alist
-  '((gnus-treat-highlight-signature gnus-article-highlight-signature)
+  '((gnus-treat-strip-banner gnus-article-strip-banner)
+    (gnus-treat-highlight-signature gnus-article-highlight-signature)
     (gnus-treat-buttonize gnus-article-add-buttons)
-    (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
-    (gnus-treat-emphasize gnus-article-emphasize)
     (gnus-treat-fill-article gnus-article-fill-cited-article)
+    (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
     (gnus-treat-strip-cr gnus-article-remove-cr)
     (gnus-treat-hide-headers gnus-article-hide-headers)
     (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
@@ -767,10 +795,13 @@ on parts -- for instance, adding Vcard info to a database."
     (gnus-treat-highlight-headers gnus-article-highlight-headers)
     (gnus-treat-highlight-citation gnus-article-highlight-citation)
     (gnus-treat-highlight-signature gnus-article-highlight-signature)
+    (gnus-treat-emphasize gnus-article-emphasize)
     (gnus-treat-date-ut gnus-article-date-ut)
     (gnus-treat-date-local gnus-article-date-local)
     (gnus-treat-date-lapsed gnus-article-date-lapsed)
     (gnus-treat-date-original gnus-article-date-original)
+    (gnus-treat-date-user-defined gnus-article-date-user)
+    (gnus-treat-date-iso8601 gnus-article-date-iso8601)
     (gnus-treat-strip-trailing-blank-lines
      gnus-article-remove-trailing-blank-lines)
     (gnus-treat-strip-leading-blank-lines
@@ -779,6 +810,7 @@ on parts -- for instance, adding Vcard info to a database."
      gnus-article-strip-multiple-blank-lines)
     (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
     (gnus-treat-overstrike gnus-article-treat-overstrike)
+    (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
     (gnus-treat-display-xface gnus-article-display-x-face)
     (gnus-treat-display-smileys gnus-smiley-display)
     (gnus-treat-display-picons gnus-article-display-picons)))
@@ -1161,22 +1193,35 @@ MAP is an alist where the elements are on the form (\"from\" \"to\")."
              (put-text-property
               (point) (1+ (point)) 'face 'underline)))))))))
 
-(defun article-fill ()
-  "Format too long lines."
+(defun article-fill-long-lines ()
+  "Fill lines that are wider than the window width."
   (interactive)
   (save-excursion
-    (let ((buffer-read-only nil))
-      (widen)
+    (let ((buffer-read-only nil)
+         (width (window-width (get-buffer-window (current-buffer)))))
+      (save-restriction
+       (widen)
+       (article-goto-body)
+       (let ((adaptive-fill-mode nil))
+         (while (not (eobp))
+           (end-of-line)
+           (when (>= (current-column) (min fill-column width))
+             (narrow-to-region (point) (gnus-point-at-bol))
+             (fill-paragraph nil)
+             (goto-char (point-max))
+             (widen))
+           (forward-line 1)))))))
+
+(defun article-capitalize-sentences ()
+  "Capitalize the first word in each sentence."
+  (interactive)
+  (save-excursion
+    (let ((buffer-read-only nil)
+         (paragraph-start "^[\n\^L]"))
       (article-goto-body)
-      (end-of-line 1)
-      (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
-           (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
-           (adaptive-fill-mode t))
-       (while (not (eobp))
-         (and (>= (current-column) (min fill-column (window-width)))
-              (/= (preceding-char) ?:)
-              (fill-paragraph nil))
-         (end-of-line 2))))))
+      (while (not (eobp))
+       (capitalize-word 1)
+       (forward-sentence)))))
 
 (defun article-remove-cr ()
   "Translate CRLF pairs into LF, and then CR into LF.."
@@ -1218,7 +1263,7 @@ MAP is an alist where the elements are on the form (\"from\" \"to\")."
          (case-fold-search t)
          from last)
       (save-restriction
-       (nnheader-narrow-to-headers)
+       (goto-char (point-min))
        (setq from (message-fetch-field "from"))
        (goto-char (point-min))
        (while (and gnus-article-x-face-command
@@ -1278,9 +1323,8 @@ If PROMPT (the prefix), prompt for a coding system to use."
             (case-fold-search t)
             (ct (message-fetch-field "Content-Type" t))
             (cte (message-fetch-field "Content-Transfer-Encoding" t))
-            (ctl (and ct (condition-case ()
-                             (mail-header-parse-content-type ct)
-                           (error nil))))
+            (ctl (and ct (ignore-errors
+                           (mail-header-parse-content-type ct))))
             (charset (cond
                       (prompt
                        (mm-read-coding-system "Charset to decode: "))
@@ -1393,6 +1437,27 @@ always hide."
             (gnus-article-hide-text-type
              (match-beginning 0) (match-end 0) 'pem))))))
 
+(defun article-strip-banner ()
+  "Strip the banner specified by the `banner' group parameter."
+  (interactive)
+  (save-excursion
+    (save-restriction
+    (let ((inhibit-point-motion-hooks t)
+         (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
+         (gnus-signature-limit nil)
+         buffer-read-only beg end)
+      (when banner
+       (article-goto-body)
+       (cond
+        ((eq banner 'signature)
+         (when (gnus-article-narrow-to-signature)
+           (widen)
+           (forward-line -1)
+           (delete-region (point) (point-max))))
+        ((stringp banner)
+         (while (re-search-forward banner nil t)
+           (delete-region (match-beginning 0) (match-end 0))))))))))
+
 (defun article-hide-signature (&optional arg)
   "Hide the signature in the current article.
 If given a negative prefix, always show; if given a positive prefix,
@@ -1421,6 +1486,8 @@ always hide."
   "Place point at the start of the body."
   (goto-char (point-min))
   (cond
+   ;; This variable is only bound when dealing with separate
+   ;; MIME body parts.
    (article-goto-body-goes-to-point-min-p
     t)
    ((search-forward "\n\n" nil t)
@@ -1710,7 +1777,7 @@ how much time has lapsed since DATE."
      ((eq type 'iso8601)
       (concat
        "Date: "
-       (format-time-string "%Y%M%DT%h%m%s" time)))
+       (format-time-string "%Y%m%dT%H%M%S" time)))
      ;; Do an X-Sent lapsed format.
      ((eq type 'lapsed)
       ;; If the date is seriously mangled, the timezone functions are
@@ -2163,12 +2230,14 @@ If variable `gnus-use-long-file-name' is non-nil, it is
    '(article-hide-headers
      article-hide-boring-headers
      article-treat-overstrike
-     (article-fill . gnus-article-word-wrap)
+     article-fill-long-lines
+     article-capitalize-sentences
      article-remove-cr
      article-display-x-face
      article-de-quoted-unreadable
      article-mime-decode-quoted-printable
      article-hide-pgp
+     article-strip-banner
      article-hide-pem
      article-hide-signature
      article-remove-trailing-blank-lines
@@ -2204,6 +2273,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
   " " gnus-article-goto-next-page
   "\177" gnus-article-goto-prev-page
   [delete] gnus-article-goto-prev-page
+  [backspace] gnus-article-goto-prev-page
   "\C-c^" gnus-article-refer-article
   "h" gnus-article-show-summary
   "s" gnus-article-show-summary
@@ -2864,7 +2934,8 @@ If ALL-HEADERS is non-nil, no headers are hidden."
        (if (and (setq not-attachment
                       (or (not (mm-handle-disposition handle))
                           (equal (car (mm-handle-disposition handle))
-                                 "inline")))
+                                 "inline")
+                          (mm-attachment-override-p type)))
                 (mm-automatic-display-p type)
                 (or (mm-inlinable-part-p type)
                     (mm-automatic-external-display-p type)))
@@ -4166,34 +4237,59 @@ For example:
   (let ((length (- (point-max) (point-min)))
        (alist gnus-treatment-function-alist)
        (article-goto-body-goes-to-point-min-p t)
+       (treated-type
+        (or (not type)
+            (catch 'found
+              (let ((list gnus-article-treat-types))
+                (while list
+                  (when (string-match (pop list) type)
+                    (throw 'found t)))))))
        val elem)
-    (when (and (gnus-visual-p 'article-highlight 'highlight)
-              (or (not type)
-                  (catch 'found
-                    (let ((list gnus-article-treat-types))
-                      (while list
-                        (when (string-match (pop list) type)
-                          (throw 'found t)))))))
+    (when (gnus-visual-p 'article-highlight 'highlight)
       (gnus-run-hooks 'gnus-part-display-hook)
       (while (setq elem (pop alist))
        (setq val (symbol-value (car elem)))
-       (when (cond
-              (condition
-               (eq condition val))
-              ((null val)
-               nil)
-              ((eq val t)
-               t)
-              ((eq val 'head)
-               nil)
-              ((eq val 'last)
-               (eq part-number total-parts))
-              ((numberp val)
-               (< length val))
-              (t
-               (eval val)))
+       (when (and (or (consp val)
+                      treated-type)
+                  (gnus-treat-predicate val))
          (funcall (cadr elem)))))))
 
+;; Dynamic variables.
+(defvar part-number)
+(defvar total-parts)
+(defvar type)
+(defvar condition)
+(defvar length)
+(defun gnus-treat-predicate (val)
+  (cond
+   (condition
+    (eq condition val))
+   ((null val)
+    nil)
+   ((eq val t)
+    t)
+   ((eq val 'head)
+    nil)
+   ((eq val 'last)
+    (eq part-number total-parts))
+   ((numberp val)
+    (< length val))
+   ((listp val)
+    (let ((pred (pop val)))
+      (cond
+       ((eq pred 'or)
+       (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
+       ((eq pred 'and)
+       (apply 'gnus-and (mapcar 'gnus-tread-predicate val)))
+       ((eq pred 'not)
+       (not (gnus-treat-predicate val)))
+       ((eq pred 'typep)
+       (equal (cadr val) type))
+       (t
+       (error "%S is not a valid predicate" pred)))))
+   (t
+    (error "%S is not a valid value" val))))
+
 (gnus-ems-redefine)
 
 (provide 'gnus-art)