Document gnus-block-private-groups.
[gnus] / lisp / gnus-art.el
index d759583..1362f1d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gnus-art.el --- article mode commands for Gnus
 
-;; Copyright (C) 1996-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2015 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -1140,7 +1140,7 @@ predicate.  See Info node `(gnus)Customizing Articles'."
   :type gnus-article-treat-custom)
 (put 'gnus-treat-highlight-signature 'highlight t)
 
-(defcustom gnus-treat-buttonize 100000
+(defcustom gnus-treat-buttonize '(and 100000 (typep "text/plain"))
   "Add buttons.
 Valid values are nil, t, `head', `first', `last', an integer or a
 predicate.  See Info node `(gnus)Customizing Articles'."
@@ -1627,6 +1627,8 @@ It is a string, such as \"PGP\". If nil, ask user."
   :type 'string
   :group 'mime-security)
 
+(defvar idna-program)
+
 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
                              (mm-coding-system-p 'utf-8)
                              idna-program
@@ -1842,7 +1844,7 @@ Initialized from `text-mode-syntax-table.")
        (incf i)))
       i))
 
-(defun article-hide-headers (&optional arg delete)
+(defun article-hide-headers (&optional _arg _delete)
   "Hide unwanted headers and possibly sort them as well."
   (interactive)
   ;; This function might be inhibited.
@@ -2412,7 +2414,7 @@ long lines if and only if arg is positive."
       (if (and wash-face-p (memq 'face gnus-article-wash-types))
          (gnus-delete-images 'face)
        (let ((from (message-fetch-field "from"))
-             face faces)
+             faces)
          (save-current-buffer
            (when (and wash-face-p
                       (gnus-buffer-live-p gnus-original-article-buffer)
@@ -2462,7 +2464,7 @@ long lines if and only if arg is positive."
          (gnus-delete-images 'xface)
        ;; Display X-Faces.
        (let ((from (message-fetch-field "from"))
-             x-faces face)
+             x-faces)
          (save-current-buffer
            (when (and wash-face-p
                       (gnus-buffer-live-p gnus-original-article-buffer)
@@ -2791,11 +2793,12 @@ summary buffer."
     (setq gnus-article-browse-html-temp-list nil))
   gnus-article-browse-html-temp-list)
 
-(defun gnus-article-browse-html-save-cid-content (cid handles directory)
+(defun gnus-article-browse-html-save-cid-content (cid handles directory abs)
   "Find CID content in HANDLES and save it in a file in DIRECTORY.
-Return file name."
+Return absolute file name if ABS is non-nil, otherwise relative to
+the parent of DIRECTORY."
   (save-match-data
-    (let (file type)
+    (let (file afile)
       (catch 'found
        (dolist (handle handles)
          (cond
@@ -2805,19 +2808,21 @@ Return file name."
           ((not (or (bufferp (car handle)) (stringp (car handle)))))
           ((equal (mm-handle-media-supertype handle) "multipart")
            (when (setq file (gnus-article-browse-html-save-cid-content
-                             cid handle directory))
+                             cid handle directory abs))
              (throw 'found file)))
           ((equal (concat "<" cid ">") (mm-handle-id handle))
-           (setq file
-                 (expand-file-name
-                  (or (mm-handle-filename handle)
-                      (concat
-                       (make-temp-name "cid")
-                       (car (rassoc (car (mm-handle-type handle))
-                                    mailcap-mime-extensions))))
-                  directory))
-           (mm-save-part-to-file handle file)
-           (throw 'found file))))))))
+           (setq file (or (mm-handle-filename handle)
+                          (concat
+                           (make-temp-name "cid")
+                           (car (rassoc (car (mm-handle-type handle))
+                                        mailcap-mime-extensions))))
+                 afile (expand-file-name file directory))
+           (mm-save-part-to-file handle afile)
+           (throw 'found (if abs
+                             afile
+                           (concat (file-name-nondirectory
+                                    (directory-file-name directory))
+                                   "/" file))))))))))
 
 (defun gnus-article-browse-html-parts (list &optional header)
   "View all \"text/html\" parts from LIST.
@@ -2853,8 +2858,13 @@ message header will be added to the bodies of the \"text/html\" parts."
               (insert content)
               ;; resolve cid contents
               (let ((case-fold-search t)
-                    cid-file)
+                    abs st cid-file)
                 (goto-char (point-min))
+                (when (re-search-forward "<head[\t\n >]" nil t)
+                  (setq st (match-end 0)
+                        abs (or
+                             (not (re-search-forward "</head[\t\n >]" nil t))
+                             (re-search-backward "<base[\t\n >]" st t))))
                 (while (re-search-forward "\
 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
                                           nil t)
@@ -2868,17 +2878,19 @@ message header will be added to the bodies of the \"text/html\" parts."
                                (match-string 2)
                                (with-current-buffer gnus-article-buffer
                                  gnus-article-mime-handles)
-                               cid-dir))
-                    (when (eq system-type 'cygwin)
+                               cid-dir abs))
+                    (when abs
                       (setq cid-file
-                            (concat "/" (substring
+                            (if (eq system-type 'cygwin)
+                                (concat "file:///"
+                                        (substring
                                          (with-output-to-string
                                            (call-process "cygpath" nil
                                                          standard-output
                                                          nil "-m" cid-file))
-                                         0 -1))))
-                    (replace-match (concat "file://" cid-file)
-                                   nil nil nil 1))))
+                                         0 -1))
+                              (concat "file://" cid-file))))
+                    (replace-match cid-file nil nil nil 1))))
               (unless content (setq content (buffer-string))))
             (when (or charset header (not file))
               (setq tmp-file (mm-make-temp-file
@@ -3083,7 +3095,7 @@ images if any to the browser, and deletes them when exiting the group
        (gnus-summary-show-article)))))
 
 (defun article-hide-list-identifiers ()
-  "Remove list identifies from the Subject header.
+  "Remove list identifiers from the Subject header.
 The `gnus-list-identifiers' variable specifies what to do."
   (interactive)
   (let ((inhibit-point-motion-hooks t)
@@ -3397,7 +3409,7 @@ means show, 0 means toggle."
        'hidden
       nil)))
 
-(defun gnus-article-show-hidden-text (type &optional dummy)
+(defun gnus-article-show-hidden-text (type &optional _dummy)
   "Show all hidden text of type TYPE.
 Originally it is hide instead of DUMMY."
   (let ((inhibit-read-only t)
@@ -3436,7 +3448,7 @@ lines forward."
                     gnus-article-date-headers)
                   t))
 
-(defun article-date-ut (&optional type highlight date-position)
+(defun article-date-ut (&optional type _highlight date-position)
   "Convert DATE date to TYPE in the current article.
 The default type is `ut'.  See `gnus-article-date-headers' for
 possible values."
@@ -3444,7 +3456,6 @@ possible values."
   (let* ((case-fold-search t)
         (inhibit-read-only t)
         (inhibit-point-motion-hooks t)
-        (first t)
         (visible-date (mail-fetch-field "Date"))
         pos date bface eface)
     (save-excursion
@@ -3983,7 +3994,7 @@ This format is defined by the `gnus-article-time-format' variable."
       (set dir-var (file-name-directory result)))
     result))
 
-(defun gnus-article-archive-name (group)
+(defun gnus-article-archive-name (_group)
   "Return the first instance of an \"Archive-name\" in the current buffer."
   (let ((case-fold-search t))
     (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
@@ -4215,7 +4226,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
        default
       (or last-file default))))
 
-(defun gnus-plain-save-name (newsgroup headers &optional last-file)
+(defun gnus-plain-save-name (newsgroup _headers &optional last-file)
   "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
 If variable `gnus-use-long-file-name' is non-nil, it is
 ~/News/news.group.  Otherwise, it is like ~/News/news/group/news."
@@ -4228,7 +4239,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
          default-directory))
        gnus-article-save-directory)))
 
-(defun gnus-sender-save-name (newsgroup headers &optional last-file)
+(defun gnus-sender-save-name (_newsgroup headers &optional _last-file)
   "Generate file name from sender."
   (let ((from (mail-header-from headers)))
     (expand-file-name
@@ -4425,6 +4436,8 @@ If variable `gnus-use-long-file-name' is non-nil, it is
 (substitute-key-definition
  'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
 
+(defvar gnus-article-send-map)
+
 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
   "W" gnus-article-wide-reply-with-original)
 (if (featurep 'xemacs)
@@ -4608,18 +4621,19 @@ commands:
           (forward-line line)
           (point)))))))
 
-(defun gnus-article-prepare (article &optional all-headers header)
+(defvar gnus-tmp-internal-hook)
+
+(defun gnus-article-prepare (article &optional all-headers _header)
   "Prepare ARTICLE in article mode buffer.
 ARTICLE should either be an article number or a Message-ID.
 If ARTICLE is an id, HEADER should be the article headers.
 If ALL-HEADERS is non-nil, no headers are hidden."
-  (save-excursion
+  (save-excursion                ;FIXME: Shouldn't that be save-current-buffer?
     ;; Make sure we start in a summary buffer.
     (unless (derived-mode-p 'gnus-summary-mode)
       (set-buffer gnus-summary-buffer))
     (setq gnus-summary-buffer (current-buffer))
-    (let* ((gnus-article (if header (mail-header-number header) article))
-          (summary-buffer (current-buffer))
+    (let* ((summary-buffer (current-buffer))
           (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
           (group gnus-newsgroup-name)
           result)
@@ -4718,6 +4732,8 @@ If ALL-HEADERS is non-nil, no headers are hidden."
            (gnus-run-hooks 'gnus-article-prepare-hook)
            t))))))
 
+(defvar gnus-mime-display-attachment-buttons-in-header)
+
 ;;;###autoload
 (defun gnus-article-prepare-display ()
   "Make the current buffer look like a nice article."
@@ -4841,6 +4857,16 @@ Valid specifiers include:
 General format specifiers can also be used.  See Info node
 `(gnus)Formatting Variables'.")
 
+(defvar gnus-tmp-type)
+(defvar gnus-tmp-type-long)
+(defvar gnus-tmp-name)
+(defvar gnus-tmp-description)
+(defvar gnus-tmp-id)
+(defvar gnus-tmp-length)
+(defvar gnus-tmp-dots)
+(defvar gnus-tmp-info)
+(defvar gnus-tmp-pressed-details)
+
 (defvar gnus-mime-button-line-format-alist
   '((?t gnus-tmp-type ?s)
     (?T gnus-tmp-type-long ?s)
@@ -5039,6 +5065,7 @@ and `gnus-mime-delete-part', and not provided at run-time normally."
     (let ((gnus-mime-buttonized-part-id current-id))
       (gnus-article-edit-done))
     (gnus-configure-windows 'article)
+    (sit-for 0)
     (when (and current-id (integerp gnus-auto-select-part))
       (gnus-article-jump-to-part
        (min (max (+ current-id gnus-auto-select-part) 1)
@@ -5067,7 +5094,6 @@ If FILE is given, use it for the external part."
 The current article has a complicated MIME structure, giving up..."))
   (let* ((data (get-text-property (point) 'gnus-data))
         (id (get-text-property (point) 'gnus-part))
-        param
         (handles gnus-article-mime-handles))
     (unless file
       (setq file
@@ -5325,7 +5351,7 @@ Compressed files like .gz and .bz2 are decompressed."
                    (text-property-any (point-min) (point) 'gnus-data handle)))
            (setq handle (get-text-property b 'gnus-data))
            b))
-        start contents charset coding-system)
+        start)
     (when handle
       (when (= b (prog1
                     btn
@@ -5335,28 +5361,15 @@ Compressed files like .gz and .bz2 are decompressed."
                                                              'gnus-data))))
        (setq b btn))
       (if (and (not arg) (mm-handle-undisplayer handle))
-         (mm-remove-part handle)
-       (mm-with-unibyte-buffer
-         (mm-insert-part handle)
-         (setq contents
-               (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
-                   (buffer-string))))
+         (progn
+           (setq b (copy-marker b)
+                 btn (copy-marker btn))
+           (mm-remove-part handle))
        (cond
-        ((not arg)
-         (unless (setq charset (mail-content-type-get
-                                (mm-handle-type handle) 'charset))
-           (unless (setq coding-system
-                         (mm-with-unibyte-buffer
-                           (insert contents)
-                           (mm-find-buffer-file-coding-system)))
-             (setq charset gnus-newsgroup-charset))))
+        ((not arg) nil)
         ((numberp arg)
          (if (mm-handle-undisplayer handle)
-             (mm-remove-part handle))
-         (setq charset
-               (or (cdr (assq arg
-                              gnus-summary-show-article-charset-alist))
-                   (mm-read-coding-system "Charset: "))))
+             (mm-remove-part handle)))
         ((mm-handle-undisplayer handle)
          (mm-remove-part handle)))
        (goto-char start)
@@ -5365,6 +5378,9 @@ Compressed files like .gz and .bz2 are decompressed."
          (forward-line 1))
        (mm-display-inline handle))
       ;; Toggle the button appearance between `[button]...' and `[button]'.
+      (when (markerp btn)
+       (setq btn (prog1 (marker-position btn)
+                   (set-marker btn nil))))
       (goto-char btn)
       (let ((displayed-p (mm-handle-displayed-p handle)))
        (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
@@ -5400,6 +5416,9 @@ Compressed files like .gz and .bz2 are decompressed."
                   '((gnus-treat-highlight-headers
                      gnus-article-highlight-headers))))
              (gnus-treat-article 'head)))))
+      (when (markerp b)
+       (setq b (prog1 (marker-position b)
+                 (set-marker b nil))))
       (goto-char b))))
 
 (defun gnus-mime-set-charset-parameters (handle charset)
@@ -5466,7 +5485,6 @@ specified charset."
   (interactive)
   (gnus-article-check-buffer)
   (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
-        (mm-user-display-methods nil)
         (mm-inlined-types nil)
         (mail-parse-charset gnus-newsgroup-charset)
         (mail-parse-ignored-charsets
@@ -5498,7 +5516,8 @@ If no internal viewer is available, use an external viewer."
         (gnus-mime-view-part-as-type
          nil (lambda (type) (mm-inlinable-p handle type)))
       (when handle
-       (gnus-bind-safe-url-regexp (mm-display-part handle))))))
+       (gnus-bind-safe-url-regexp
+        (mm-display-part handle nil t))))))
 
 (defun gnus-mime-action-on-part (&optional action)
   "Do something with the MIME attachment at \(point\)."
@@ -5722,7 +5741,8 @@ all parts."
                point (previous-single-property-change start 'gnus-data))
          (if (mm-handle-displayed-p handle)
              ;; This will remove the part.
-             (setq retval (mm-display-part handle))
+             (setq point (copy-marker point)
+                   retval (mm-display-part handle))
            (let ((part (or (and (mm-inlinable-p handle)
                                 (mm-inlined-p handle)
                                 t)
@@ -5753,6 +5773,9 @@ all parts."
                                            ,(point-max-marker)))))))
                    (part
                     (mm-display-inline handle))))))
+      (when (markerp point)
+       (setq point (prog1 (marker-position point)
+                     (set-marker point nil))))
       (goto-char point)
       ;; Toggle the button appearance between `[button]...' and `[button]'.
       (let ((displayed-p (mm-handle-displayed-p handle)))
@@ -5834,11 +5857,12 @@ all parts."
     (when gnus-break-pages
       (gnus-narrow-to-page))))
 
-(defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
+(defun gnus-insert-mime-button (handle id &optional displayed)
   (let ((gnus-tmp-name
         (or (mm-handle-filename handle)
             (mail-content-type-get (mm-handle-type handle) 'url)
             ""))
+        (gnus-tmp-id id)
        (gnus-tmp-type (mm-handle-media-type handle))
        (gnus-tmp-description (or (mm-handle-description handle) ""))
        (gnus-tmp-dots
@@ -5889,7 +5913,7 @@ all parts."
            "hide" "show")
        (aref gnus-down-mouse-3 0))))))
 
-(defun gnus-widget-press-button (elems el)
+(defun gnus-widget-press-button (elems _el)
   (goto-char (widget-get elems :from))
   (gnus-article-press-button))
 
@@ -5907,8 +5931,7 @@ all parts."
          ;; may change the point.  So we set the window point.
          (set-window-point window point)))
       (let ((handles ihandles)
-           (inhibit-read-only t)
-           handle)
+           (inhibit-read-only t))
        (cond (handles)
              ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
               (when gnus-article-emulate-mime
@@ -6093,7 +6116,7 @@ If nil, don't show those extra buttons."
              (gnus-article-insert-newline)
            (if (prog1
                    (= (skip-chars-backward "\n") -1)
-                 (forward-char 1))
+                 (unless (eobp) (forward-char 1)))
                (gnus-article-insert-newline)
              (put-text-property (point) (point-max) 'gnus-undeletable t))
            (goto-char (point-max)))
@@ -6140,7 +6163,7 @@ If nil, don't show those extra buttons."
   (let* ((preferred (or preferred (mm-preferred-alternative handles)))
         (ihandles handles)
         (point (point))
-        handle (inhibit-read-only t) from props begend not-pref)
+        handle (inhibit-read-only t) from begend not-pref)
     (save-window-excursion
       (save-restriction
        (when ibegend
@@ -6336,6 +6359,40 @@ Provided for backwards compatibility."
     (when image
       (gnus-add-image 'shr image))))
 
+(defun gnus-article-mime-handles (&optional alist id all)
+  (if alist
+      (let ((i 1) newid flat)
+       (dolist (handle alist flat)
+         (setq newid (append id (list i))
+               i (1+ i))
+         (if (stringp (car handle))
+             (setq flat (nconc flat (gnus-article-mime-handles
+                                     (cdr handle) newid all)))
+           (delq (rassq handle all) all)
+           (setq flat (nconc flat (list (cons newid handle)))))))
+    (let ((flat (list nil)))
+      ;; Assume that elements of `gnus-article-mime-handle-alist'
+      ;; are in the decreasing order, but unnumbered subsidiaries
+      ;; in each element are in the increasing order.
+      (dolist (handle (reverse gnus-article-mime-handle-alist))
+       (if (stringp (cadr handle))
+           (setq flat (nconc flat (gnus-article-mime-handles
+                                   (cddr handle) (list (car handle)) flat)))
+         (delq (rassq (cdr handle) flat) flat)
+         (setq flat (nconc flat (list (cons (list (car handle))
+                                            (cdr handle)))))))
+      (setq flat (cdr flat))
+      (mapc (lambda (handle)
+             (if (cdar handle)
+                 ;; This is a hidden (i.e. unnumbered) handle.
+                 (progn
+                   (setcar handle
+                           (1+ (caar gnus-article-mime-handle-alist)))
+                   (push handle gnus-article-mime-handle-alist))
+               (setcar handle (caar handle))))
+           flat)
+      flat)))
+
 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
   "Show attachments as buttons in the end of the header of an article.
 This function toggles the display when called interactively.  Note that
@@ -6343,108 +6400,69 @@ buttons to be added to the header are only the ones that aren't inlined
 in the body.  Use `gnus-header-face-alist' to highlight buttons."
   (interactive (list t))
   (gnus-with-article-buffer
-    (gmm-labels
-       ;; Function that returns a flattened version of
-       ;; `gnus-article-mime-handle-alist'.
-       ((flattened-alist
-         (&optional alist id all)
-         (if alist
-             (let ((i 1) newid flat)
-               (dolist (handle alist flat)
-                 (setq newid (append id (list i))
-                       i (1+ i))
-                 (if (stringp (car handle))
-                     (setq flat (nconc flat (flattened-alist (cdr handle)
-                                                             newid all)))
-                   (delq (rassq handle all) all)
-                   (setq flat (nconc flat (list (cons newid handle)))))))
-           (let ((flat (list nil)))
-             ;; Assume that elements of `gnus-article-mime-handle-alist'
-             ;; are in the decreasing order, but unnumbered subsidiaries
-             ;; in each element are in the increasing order.
-             (dolist (handle (reverse gnus-article-mime-handle-alist))
-               (if (stringp (cadr handle))
-                   (setq flat (nconc flat (flattened-alist (cddr handle)
-                                                           (list (car handle))
-                                                           flat)))
-                 (delq (rassq (cdr handle) flat) flat)
-                 (setq flat (nconc flat (list (cons (list (car handle))
-                                                    (cdr handle)))))))
-             (setq flat (cdr flat))
-             (mapc (lambda (handle)
-                     (if (cdar handle)
-                         ;; This is a hidden (i.e. unnumbered) handle.
-                         (progn
-                           (setcar handle
-                                   (1+ (caar gnus-article-mime-handle-alist)))
-                           (push handle gnus-article-mime-handle-alist))
-                       (setcar handle (caar handle))))
-                   flat)
-             flat))))
-      (let ((case-fold-search t) buttons handle type st)
-       (save-excursion
-         (save-restriction
-           (widen)
-           (article-narrow-to-head)
-           ;; Header buttons exist?
-           (while (and (not buttons)
-                       (re-search-forward "^attachments?:[\n ]+" nil t))
-             (when (get-char-property (match-end 0)
-                                      'gnus-button-attachment-extra)
-               (setq buttons (match-beginning 0))))
-           (widen)
+    (let ((case-fold-search t) buttons handle type st)
+      (save-excursion
+       (save-restriction
+         (widen)
+         (article-narrow-to-head)
+         ;; Header buttons exist?
+         (while (and (not buttons)
+                     (re-search-forward "^attachments?:[\n ]+" nil t))
+           (when (get-char-property (match-end 0)
+                                    'gnus-button-attachment-extra)
+             (setq buttons (match-beginning 0))))
+         (widen)
+         (when buttons
+           ;; Delete header buttons.
+           (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
+                                      (match-beginning 0)
+                                    (point-max))))
+         (unless (and interactive buttons)
+           ;; Find buttons.
+           (setq buttons nil)
+           (dolist (button (gnus-article-mime-handles))
+             (setq handle (cdr button)
+                   type (mm-handle-media-type handle))
+             (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
+                                (with-current-buffer gnus-summary-buffer
+                                  gnus-inhibit-images)
+                              gnus-inhibit-images)
+                            (string-match "\\`image/" type))
+                       (mm-inline-override-p handle)
+                       (and (mm-handle-disposition handle)
+                            (not (equal (car (mm-handle-disposition handle))
+                                        "inline"))
+                            (not (mm-attachment-override-p handle)))
+                       (not (mm-automatic-display-p handle))
+                       (not (or (and (mm-inlinable-p handle)
+                                     (mm-inlined-p handle))
+                                (mm-automatic-external-display-p type))))
+               (push button buttons)))
            (when buttons
-             ;; Delete header buttons.
-             (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
-                                        (match-beginning 0)
-                                      (point-max))))
-           (unless (and interactive buttons)
-             ;; Find buttons.
-             (setq buttons nil)
-             (dolist (button (flattened-alist))
-               (setq handle (cdr button)
-                     type (mm-handle-media-type handle))
-               (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
-                                  (with-current-buffer gnus-summary-buffer
-                                    gnus-inhibit-images)
-                                gnus-inhibit-images)
-                              (string-match "\\`image/" type))
-                         (mm-inline-override-p handle)
-                         (and (mm-handle-disposition handle)
-                              (not (equal (car (mm-handle-disposition handle))
-                                          "inline"))
-                              (not (mm-attachment-override-p handle)))
-                         (not (mm-automatic-display-p handle))
-                         (not (or (and (mm-inlinable-p handle)
-                                       (mm-inlined-p handle))
-                                  (mm-automatic-external-display-p type))))
-                 (push button buttons)))
-             (when buttons
-               ;; Add header buttons.
-               (article-goto-body)
-               (forward-line -1)
-               (narrow-to-region (point) (point))
-               (insert "Attachment" (if (cdr buttons) "s" "") ":")
-               (dolist (button (nreverse buttons))
-                 (setq st (point))
-                 (insert " ")
-                 (mm-handle-set-undisplayer
-                  (setq handle (copy-sequence (cdr button))) nil)
-                 (gnus-insert-mime-button handle (car button))
-                 (skip-chars-backward "\t\n ")
-                 (delete-region (point) (point-max))
-                 (when (> (current-column) (window-width))
-                   (goto-char st)
-                   (insert "\n")
-                   (end-of-line)))
-               (insert "\n")
-               (dolist (ovl (gnus-overlays-in (point-min) (point)))
-                 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
-                 (gnus-overlay-put ovl 'face nil))
-               (let ((gnus-treatment-function-alist
-                      '((gnus-treat-highlight-headers
-                         gnus-article-highlight-headers))))
-                 (gnus-treat-article 'head))))))))))
+             ;; Add header buttons.
+             (article-goto-body)
+             (forward-line -1)
+             (narrow-to-region (point) (point))
+             (insert "Attachment" (if (cdr buttons) "s" "") ":")
+             (dolist (button (nreverse buttons))
+               (setq st (point))
+               (insert " ")
+               (mm-handle-set-undisplayer (setq handle (cdr button)) nil)
+               (gnus-insert-mime-button handle (car button))
+               (skip-chars-backward "\t\n ")
+               (delete-region (point) (point-max))
+               (when (> (current-column) (window-width))
+                 (goto-char st)
+                 (insert "\n")
+                 (end-of-line)))
+             (insert "\n")
+             (dolist (ovl (gnus-overlays-in (point-min) (point)))
+               (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
+               (gnus-overlay-put ovl 'face nil))
+             (let ((gnus-treatment-function-alist
+                    '((gnus-treat-highlight-headers
+                       gnus-article-highlight-headers))))
+               (gnus-treat-article 'head)))))))))
 
 ;;; Article savers.
 
@@ -6631,6 +6649,8 @@ specifies."
                      (if header-line-format 1 0)
                      2)))))))
 
+(defvar scroll-in-place)
+
 (defun gnus-article-next-page-1 (lines)
   (condition-case ()
       (let ((scroll-in-place nil)
@@ -6718,7 +6738,9 @@ not have a face in `gnus-article-boring-faces'."
   (unless (derived-mode-p 'gnus-article-mode)
     (error "Command invoked outside of a Gnus article buffer")))
 
-(defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
+(defvar gnus-pick-mode)
+
+(defun gnus-article-read-summary-keys (&optional _arg key not-restore-window)
   "Read a summary buffer key sequence and execute it from the article buffer."
   (interactive "P")
   (gnus-article-check-buffer)
@@ -6731,8 +6753,6 @@ not have a face in `gnus-article-boring-faces'."
           "An" "Ap" [?A (meta return)] [?A delete]))
        (nosave-in-article
         '("AS" "\C-d"))
-       (up-to-top
-        '("n" "Gn" "p" "Gp"))
        keys new-sum-point)
     (with-current-buffer gnus-article-current-summary
       (let (gnus-pick-mode)
@@ -6891,6 +6911,7 @@ KEY is a string or a vector."
 (defvar gnus-agent-summary-mode)
 (defvar gnus-draft-mode)
 (defvar help-xref-stack-item)
+(defvar help-xref-following)
 
 (defun gnus-article-describe-bindings (&optional prefix)
   "Show a list of all defined keys, and their definitions.
@@ -7190,6 +7211,8 @@ If given a prefix, show the hidden text instead."
          (set-buffer buf))))))
 
 (defun gnus-block-private-groups (group)
+  "Allows images in newsgroups to be shown, blocks images in all
+other groups."
   (if (or (gnus-news-group-p group)
          (gnus-member-of-valid 'global group))
       ;; Block nothing in news groups.
@@ -7335,7 +7358,6 @@ groups."
   (let ((func gnus-article-edit-done-function)
        (buf (current-buffer))
        (start (window-start))
-       (p (point))
        (winconf gnus-prev-winconf))
     (widen) ;; Widen it in case that users narrowed the buffer.
     (funcall func arg)
@@ -7964,7 +7986,7 @@ do the highlighting.  See the documentation for those functions."
   (gnus-article-add-buttons)
   (gnus-article-add-buttons-to-head))
 
-(defun gnus-article-highlight-some (&optional force)
+(defun gnus-article-highlight-some (&optional _force)
   "Highlight current article.
 This function calls `gnus-article-highlight-headers',
 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
@@ -8267,9 +8289,11 @@ url is put as the `gnus-button-url' overlay property on the button."
        (error "Unknown news URL syntax"))))
     (list scheme server port group message-id articles)))
 
+(defvar nntp-port-number)
+
 (defun gnus-button-handle-news (url)
   "Fetch a news URL."
-  (destructuring-bind (scheme server port group message-id articles)
+  (destructuring-bind (_scheme server port group message-id _articles)
       (gnus-parse-news-url url)
     (cond
      (message-id
@@ -8391,7 +8415,7 @@ url is put as the `gnus-button-url' overlay property on the button."
   (with-current-buffer gnus-summary-buffer
     (gnus-summary-refer-article message-id)))
 
-(defun gnus-button-fetch-group (address &rest ignore)
+(defun gnus-button-fetch-group (address &rest _ignore)
   "Fetch GROUP specified by ADDRESS."
   (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
                      address)
@@ -8439,15 +8463,15 @@ url is put as the `gnus-button-url' overlay property on the button."
   (setq url (replace-regexp-in-string "\n" " " url))
   (when (string-match "mailto:/*\\(.*\\)" url)
     (setq url (substring url (match-beginning 1) nil)))
-  (let (to args subject func)
-    (setq args (gnus-url-parse-query-string
+  (let* ((args (gnus-url-parse-query-string
                (if (string-match "^\\?" url)
                    (substring url 1)
                  (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
                      (concat "to=" (match-string 1 url) "&"
                              (match-string 2 url))
-                   (concat "to=" url))))
-         subject (cdr-safe (assoc "subject" args)))
+                   (concat "to=" url)))))
+         (subject (cdr-safe (assoc "subject" args)))
+         func)
     (gnus-msg-mail)
     (while args
       (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
@@ -8504,7 +8528,7 @@ url is put as the `gnus-button-url' overlay property on the button."
      :action 'gnus-button-prev-page
      :button-keymap gnus-prev-page-map)))
 
-(defun gnus-button-next-page (&optional args more-args)
+(defun gnus-button-next-page (&optional _args _more-args)
   "Go to the next page."
   (interactive)
   (let ((win (selected-window)))
@@ -8512,7 +8536,7 @@ url is put as the `gnus-button-url' overlay property on the button."
     (gnus-article-next-page)
     (select-window win)))
 
-(defun gnus-button-prev-page (&optional args more-args)
+(defun gnus-button-prev-page (&optional _args _more-args)
   "Go to the prev page."
   (interactive)
   (let ((win (selected-window)))
@@ -8540,7 +8564,7 @@ url is put as the `gnus-button-url' overlay property on the button."
      :action 'gnus-button-next-page
      :button-keymap gnus-next-page-map)))
 
-(defun gnus-article-button-next-page (arg)
+(defun gnus-article-button-next-page (_arg)
   "Go to the next page."
   (interactive "P")
   (let ((win (selected-window)))
@@ -8548,7 +8572,7 @@ url is put as the `gnus-button-url' overlay property on the button."
     (gnus-article-next-page)
     (select-window win)))
 
-(defun gnus-article-button-prev-page (arg)
+(defun gnus-article-button-prev-page (_arg)
   "Go to the prev page."
   (interactive "P")
   (let ((win (selected-window)))
@@ -8599,20 +8623,31 @@ For example:
 
 (defvar gnus-inhibit-article-treatments nil)
 
-(defun gnus-treat-article (gnus-treat-condition
-                          &optional part-number total-parts gnus-treat-type)
-  (let ((gnus-treat-length (- (point-max) (point-min)))
+;; Dynamic variables.
+(defvar part-number)                    ;FIXME: Lacks a "gnus-" prefix.
+(defvar total-parts)                    ;FIXME: Lacks a "gnus-" prefix.
+(defvar gnus-treat-type)
+(defvar gnus-treat-condition)
+(defvar gnus-treat-length)
+
+(defun gnus-treat-article (condition
+                          &optional part-num total type)
+  (let ((gnus-treat-condition condition)
+        (part-number part-num)
+        (total-parts total)
+        (gnus-treat-type type)
+        (gnus-treat-length (- (point-max) (point-min)))
        (alist gnus-treatment-function-alist)
        (article-goto-body-goes-to-point-min-p t)
        (treated-type
-        (or (not gnus-treat-type)
+        (or (not type)
             (catch 'found
               (let ((list gnus-article-treat-types))
                 (while list
-                  (when (string-match (pop list) gnus-treat-type)
+                  (when (string-match (pop list) type)
                     (throw 'found t)))))))
        (highlightp (gnus-visual-p 'article-highlight 'highlight))
-       val elem)
+       val)
     (gnus-run-hooks 'gnus-part-display-hook)
     (dolist (elem alist)
       (setq val
@@ -8630,13 +8665,6 @@ For example:
        (save-restriction
          (funcall (cadr elem)))))))
 
-;; Dynamic variables.
-(defvar part-number)
-(defvar total-parts)
-(defvar gnus-treat-type)
-(defvar gnus-treat-condition)
-(defvar gnus-treat-length)
-
 (defun gnus-treat-predicate (val)
   (cond
    ((null val)
@@ -8885,7 +8913,7 @@ For example:
        (gnus-mime-security-show-details handle)
       (gnus-mime-security-verify-or-decrypt handle))))
 
-(defun gnus-insert-mime-security-button (handle &optional displayed)
+(defun gnus-insert-mime-security-button (handle &optional _displayed)
   (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
         (gnus-tmp-type
          (concat
@@ -8933,7 +8961,7 @@ For example:
      :action 'gnus-widget-press-button
      :button-keymap gnus-mime-security-button-map
      :help-echo
-     (lambda (widget)
+     (lambda (_widget)
        ;; Needed to properly clear the message due to a bug in
        ;; wid-edit (XEmacs only).
        (when (boundp 'help-echo-owns-message)