Synch with Gnus.
[elisp/gnus.git-] / lisp / gnus-art.el
index 0dc292b..a95f96c 100644 (file)
     "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
     "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
     "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
-    "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
+    "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
     "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
     "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
     "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
@@ -215,7 +215,9 @@ regexp.  If it matches, the text in question is not a signature."
    ;; gnus-xmas.el overrides this for XEmacs.
    ((and (fboundp 'image-type-available-p)
         (image-type-available-p 'xbm))
-    'gnus-article-display-xface)
+    (if (module-installed-p 'x-face-e21)
+       'x-face-decode-message-header
+      'gnus-article-display-xface))
    ((and (not (featurep 'xemacs))
         window-system
         (module-installed-p 'x-face-mule))
@@ -229,6 +231,9 @@ display -"))
 If it is a string, the command will be executed in a sub-shell
 asynchronously.         The compressed face will be piped to this command."
   :type '(choice string
+                (function-item
+                 :tag "x-face-decode-message-header (x-face-e21)"
+                 x-face-decode-message-header)
                 (function-item gnus-article-display-xface)
                 (function-item x-face-mule-gnus-article-display-x-face)
                 function)
@@ -1015,6 +1020,7 @@ See the manual for details."
 
 (defcustom gnus-treat-x-pgp-sig nil
   "Verify X-PGP-Sig.
+To automatically treat X-PGP-Sig, set it to head.
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See the manual for details."
   :group 'gnus-article-treat
@@ -1108,11 +1114,12 @@ Initialized from `text-mode-syntax-table.")
 
 (defsubst gnus-article-hide-text (b e props)
   "Set text PROPS on the B to E region, extending `intangible' 1 past B."
-  (add-text-properties b e props)
+  (gnus-add-text-properties-when 'article-type nil b e props)
   (when (memq 'intangible props)
     (put-text-property
      (max (1- b) (point-min))
      b 'intangible (cddr (memq 'intangible props)))))
+
 (defsubst gnus-article-unhide-text (b e)
   "Remove hidden text properties from region between B and E."
   (remove-text-properties b e gnus-hidden-properties)
@@ -2144,24 +2151,16 @@ means show, 0 means toggle."
        'hidden
       nil)))
 
-(defun gnus-article-show-hidden-text (type &optional hide)
+(defun gnus-article-show-hidden-text (type &optional dummy)
   "Show all hidden text of type TYPE.
-If HIDE, hide the text instead."
-  (save-excursion
-    (let ((buffer-read-only nil)
-         (inhibit-point-motion-hooks t)
-         (end (point-min))
-         beg)
-      (while (setq beg (text-property-any end (point-max) 'article-type type))
-       (goto-char beg)
-       (setq end (or
-                  (text-property-not-all beg (point-max) 'article-type type)
-                  (point-max)))
-       (if hide
-           (gnus-article-hide-text beg end gnus-hidden-properties)
-         (gnus-article-unhide-text beg end))
-       (goto-char end))
-      t)))
+Originally it is hide instead of DUMMY."
+  (let ((buffer-read-only nil)
+       (inhibit-point-motion-hooks t))
+    (gnus-remove-text-properties-when 
+     'article-type type
+     (point-min) (point-max) 
+     (cons 'article-type (cons type
+                              gnus-hidden-properties)))))
 
 (defconst article-time-units
   `((year . ,(* 365.25 24 60 60))
@@ -2757,8 +2756,6 @@ If variable `gnus-use-long-file-name' is non-nil, it is
         (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
        gnus-article-save-directory)))
 
-(autoload 'mm-uu-pgp-signed-test "mm-uu")
-
 (defun article-verify-x-pgp-sig ()
   "Verify X-PGP-Sig."
   (interactive)
@@ -2766,7 +2763,9 @@ If variable `gnus-use-long-file-name' is non-nil, it is
       (let ((sig (with-current-buffer gnus-original-article-buffer
                   (gnus-fetch-field "X-PGP-Sig")))
            items info headers)
-       (when (and sig (mm-uu-pgp-signed-test))
+       (when (and sig 
+                  mml2015-use
+                  (mml2015-clear-verify-function))
          (with-temp-buffer
            (insert-buffer gnus-original-article-buffer)
            (setq items (split-string sig))
@@ -2912,6 +2911,8 @@ If variable `gnus-use-long-file-name' is non-nil, it is
   ">" end-of-buffer
   "\C-c\C-i" gnus-info-find-node
   "\C-c\C-b" gnus-bug
+  "\C-hk" gnus-article-describe-key
+  "\C-hc" gnus-article-describe-key-briefly
 
   "\C-d" gnus-article-read-summary-keys
   "\M-*" gnus-article-read-summary-keys
@@ -2942,6 +2943,9 @@ If variable `gnus-use-long-file-name' is non-nil, it is
            (decf c))
          keys))))
 
+(eval-when-compile 
+  (defvar gnus-article-commands-menu))
+
 (defun gnus-article-make-menu-bar ()
   (gnus-turn-off-edit-menu 'article)
   (unless (boundp 'gnus-article-article-menu)
@@ -2971,7 +2975,12 @@ If variable `gnus-use-long-file-name' is non-nil, it is
       (define-key gnus-article-mode-map [menu-bar post]
        (cons "Post" gnus-summary-post-menu)))
 
-    (gnus-run-hooks 'gnus-article-menu-hook)))
+    (gnus-run-hooks 'gnus-article-menu-hook))
+  ;; Add the menu.
+  (when (boundp 'gnus-article-commands-menu)
+    (easy-menu-add gnus-article-commands-menu gnus-article-mode-map))
+  (when (boundp 'gnus-summary-post-menu)
+    (easy-menu-add gnus-summary-post-menu gnus-article-mode-map)))
 
 (defun gnus-article-mode ()
   "Major mode for displaying an article.
@@ -4421,6 +4430,36 @@ Argument LINES specifies lines to be scrolled down."
          (switch-to-buffer gnus-article-buffer)
           (ding))))))
 
+(defun gnus-article-describe-key (key)
+  "Display documentation of the function invoked by KEY.  KEY is a string."
+  (interactive "kDescribe key: ")
+  (gnus-article-check-buffer)
+  (if (eq (key-binding key) 'gnus-article-read-summary-keys)
+      (save-excursion
+       (set-buffer gnus-article-current-summary)
+       (let (gnus-pick-mode)
+         (push (elt key 0) unread-command-events)
+         (setq key (if (featurep 'xemacs)
+                       (events-to-keys (read-key-sequence "Describe key: "))
+                     (read-key-sequence "Describe key: "))))
+       (describe-key key))
+    (describe-key key)))
+
+(defun gnus-article-describe-key-briefly (key &optional insert)
+  "Display documentation of the function invoked by KEY.  KEY is a string."
+  (interactive "kDescribe key: \nP")
+  (gnus-article-check-buffer)
+  (if (eq (key-binding key) 'gnus-article-read-summary-keys)
+      (save-excursion
+       (set-buffer gnus-article-current-summary)
+       (let (gnus-pick-mode)
+         (push (elt key 0) unread-command-events)
+         (setq key (if (featurep 'xemacs)
+                       (events-to-keys (read-key-sequence "Describe key: "))
+                     (read-key-sequence "Describe key: "))))
+       (describe-key-briefly key insert))
+    (describe-key-briefly key insert)))
+
 (defun gnus-article-hide (&optional arg force)
   "Hide all the gruft in the current article.
 This means that PGP stuff, signatures, cited text and (some)
@@ -5181,9 +5220,15 @@ specified by `gnus-button-alist'."
          (inhibit-point-motion-hooks t)
          (limit (next-single-property-change end 'mime-view-entity
                                              nil (point-max))))
-      (if (get-text-property end 'invisible)
-         (gnus-article-unhide-text end limit)
-       (gnus-article-hide-text end limit gnus-hidden-properties)))))
+      (if (text-property-any end limit 'article-type 'signature)
+         (gnus-remove-text-properties-when
+          'article-type 'signature end limit
+          (cons 'article-type (cons 'signature
+                                    gnus-hidden-properties)))
+       (gnus-add-text-properties-when
+        'article-type nil end limit
+        (cons 'article-type (cons 'signature
+                                  gnus-hidden-properties)))))))
 
 (defun gnus-button-entry ()
   ;; Return the first entry in `gnus-button-alist' matching this place.
@@ -5623,19 +5668,25 @@ For example:
            (gnus-cache-update-article
             (car gnus-article-current) (cdr gnus-article-current))))))))
 
-(defvar gnus-mime-security-button-line-format "%{%([[%t:%i]]%)%}\n"
+(defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
   "The following specs can be used:
 %t  The security MIME type
-%i  Additional info")
+%i  Additional info
+%d  Details
+%D  Details if button is pressed")
 
-(defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]]%)%}\n"
+(defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
   "The following specs can be used:
 %t  The security MIME type
-%i  Additional info")
+%i  Additional info
+%d  Details
+%D  Details if button is pressed")
 
 (defvar gnus-mime-security-button-line-format-alist
   '((?t gnus-tmp-type ?s)
-    (?i gnus-tmp-info ?s)))
+    (?i gnus-tmp-info ?s)
+    (?d gnus-tmp-details ?s)
+    (?D gnus-tmp-pressed-details ?s)))
 
 (defvar gnus-mime-security-button-map
   (let ((map (make-sparse-keymap)))
@@ -5646,6 +5697,11 @@ For example:
 
 (defvar gnus-mime-security-details-buffer nil)
 
+(defvar gnus-mime-security-button-pressed nil)
+
+(defvar gnus-mime-security-show-details-inline t
+  "If non-nil, show details in the article buffer.")
+
 (defun gnus-mime-security-verify-or-decrypt (handle)
   (mm-remove-parts (cdr handle))
   (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
@@ -5669,7 +5725,23 @@ For example:
 (defun gnus-mime-security-show-details (handle)
   (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
     (if details
-       (progn
+       (if gnus-mime-security-show-details-inline
+           (let ((gnus-mime-security-button-pressed t)
+                 (gnus-mime-security-button-line-format 
+                  (get-text-property (point) 'gnus-line-format))
+               buffer-read-only)
+             (forward-char -1)
+             (while (eq (get-text-property (point) 'gnus-line-format)
+                        gnus-mime-security-button-line-format)
+               (forward-char -1))
+             (forward-char)
+             (delete-region (point)
+                            (or (text-property-not-all 
+                                 (point) (point-max)
+                               'gnus-line-format   
+                               gnus-mime-security-button-line-format)
+                                (point-max)))
+             (gnus-insert-mime-security-button handle))
          (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
              (with-current-buffer gnus-mime-security-details-buffer
                (erase-buffer)
@@ -5677,7 +5749,8 @@ For example:
            (setq gnus-mime-security-details-buffer
                  (gnus-get-buffer-create "*MIME Security Details*")))
          (with-current-buffer gnus-mime-security-details-buffer
-           (insert details))
+           (insert details)
+           (goto-char (point-min)))
          (pop-to-buffer gnus-mime-security-details-buffer))
       (gnus-message 5 "No details."))))
 
@@ -5699,7 +5772,15 @@ For example:
         (gnus-tmp-info
          (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
              "Undecided"))
+        (gnus-tmp-details
+         (mm-handle-multipart-ctl-parameter handle 'gnus-details))
+        gnus-tmp-pressed-details
         b e)
+    (setq gnus-tmp-details
+         (if gnus-tmp-details
+             (concat "\n" gnus-tmp-details) ""))
+    (setq gnus-tmp-pressed-details 
+         (if gnus-mime-security-button-pressed gnus-tmp-details ""))
     (unless (bolp)
       (insert "\n"))
     (setq b (point))
@@ -5709,6 +5790,7 @@ For example:
      `(local-map ,gnus-mime-security-button-map
                 keymap ,gnus-mime-security-button-map
                 gnus-callback gnus-mime-security-press-button
+                gnus-line-format ,gnus-mime-security-button-line-format 
                 article-type annotation
                 gnus-data ,handle))
     (setq e (point))