Importing pgnus-0.53
[elisp/gnus.git-] / lisp / gnus-sum.el
index 8be8168..3da5bfe 100644 (file)
@@ -483,7 +483,7 @@ It uses the same syntax as the `gnus-split-methods' variable."
   :group 'gnus-summary
   :type '(repeat character))
 
-(defcustom gnus-inhibit-user-auto-expire nil
+(defcustom gnus-inhibit-user-auto-expire t
   "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
   :group 'gnus-summary
   :type 'boolean)
@@ -797,6 +797,22 @@ which it may alter in any way.")
   :group 'gnus-summary
   :type 'regexp)
 
+(defcustom gnus-newsgroup-coding-system-alist 
+  '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" . cn-big5)
+    ("^cn\\>\\|\\<chinese\\>" . cn-gb-2312)
+    ("^fj\\>" . iso-2022-jp-2)
+    ("^relcom\\>" . koi8-r))
+  "Alist of Regexps (to match group names) and CODING-SYSTEMs to be applied."
+  :type '(repeat (cons (regexp :tag "Group")
+                      (symbol :tag "Charset")))
+  :group 'gnus)
+
+(defcustom gnus-newsgroup-iso-8859-1-forced-regexp 
+  "^tw\\>\\|^hk\\>\\|^cn\\>\\|\\<chinese\\>"
+  "Regexp of newsgroup in which ISO-8859-1 is forced to other charset."
+  :type 'regexp
+  :group 'gnus)
+
 ;;; Internal variables
 
 (defvar gnus-article-mime-handles nil)
@@ -985,6 +1001,9 @@ variable (string, integer, character, etc).")
 (defvar gnus-last-article nil)
 (defvar gnus-newsgroup-history nil)
 
+(defvar gnus-newsgroup-coding-system nil)
+(defvar gnus-newsgroup-iso-8859-1-forced nil)
+
 (defconst gnus-summary-local-variables
   '(gnus-newsgroup-name
     gnus-newsgroup-begin gnus-newsgroup-end
@@ -1015,7 +1034,8 @@ variable (string, integer, character, etc).")
     (gnus-newsgroup-expunged-tally . 0)
     gnus-cache-removable-articles gnus-newsgroup-cached
     gnus-newsgroup-data gnus-newsgroup-data-reverse
-    gnus-newsgroup-limit gnus-newsgroup-limits)
+    gnus-newsgroup-limit gnus-newsgroup-limits
+    gnus-newsgroup-coding-system gnus-newsgroup-iso-8859-1-forced)
   "Variables that are buffer-local to the summary buffers.")
 
 ;; Byte-compiler warning.
@@ -1287,6 +1307,7 @@ increase the score of each group you read."
     "\C-d" gnus-summary-enter-digest-group
     "\M-\C-d" gnus-summary-read-document
     "\M-\C-e" gnus-summary-edit-parameters
+    "\M-\C-g" gnus-summary-customize-parameters
     "\C-c\C-b" gnus-bug
     "*" gnus-cache-enter-article
     "\M-*" gnus-cache-remove-article
@@ -1509,7 +1530,11 @@ increase the score of each group you read."
     "h" gnus-summary-save-article-folder
     "v" gnus-summary-save-article-vm
     "p" gnus-summary-pipe-output
-    "s" gnus-soup-add-article))
+    "s" gnus-soup-add-article)
+
+  (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
+    "b" gnus-summary-display-buttonized)
+  )
 
 (defun gnus-summary-make-menu-bar ()
   (gnus-turn-off-edit-menu 'summary)
@@ -1806,6 +1831,7 @@ increase the score of each group you read."
        ["Edit local kill file" gnus-summary-edit-local-kill t]
        ["Edit main kill file" gnus-summary-edit-global-kill t]
        ["Edit group parameters" gnus-summary-edit-parameters t]
+       ["Customize group parameters" gnus-summary-customize-parameters t]
        ["Send a bug report" gnus-bug t]
        ("Exit"
        ["Catchup and exit" gnus-summary-catchup-and-exit t]
@@ -2372,7 +2398,9 @@ marks of articles."
          (original gnus-original-article-buffer)
          (gac gnus-article-current)
          (reffed gnus-reffed-article-number)
-         (score-file gnus-current-score-file))
+         (score-file gnus-current-score-file)
+         (coding-system gnus-newsgroup-coding-system)
+         (iso-8859-1-forced gnus-newsgroup-iso-8859-1-forced))
       (save-excursion
        (set-buffer gnus-group-buffer)
        (setq gnus-newsgroup-name name
@@ -2385,7 +2413,9 @@ marks of articles."
              gnus-article-buffer article-buffer
              gnus-original-article-buffer original
              gnus-reffed-article-number reffed
-             gnus-current-score-file score-file)
+             gnus-current-score-file score-file
+             gnus-newsgroup-coding-system coding-system
+             gnus-newsgroup-iso-8859-1-forced iso-8859-1-forced)
        ;; The article buffer also has local variables.
        (when (gnus-buffer-live-p gnus-article-buffer)
          (set-buffer gnus-article-buffer)
@@ -2460,7 +2490,9 @@ marks of articles."
 
 (defun gnus-summary-from-or-to-or-newsgroups (header)
   (let ((to (cdr (assq 'To (mail-header-extra header))))
-       (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header)))))
+       (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
+       (rfc2047-default-charset gnus-newsgroup-coding-system)
+       (mm-charset-iso-8859-1-forced gnus-newsgroup-iso-8859-1-forced))
     (cond
      ((and to
           gnus-ignored-from-addresses
@@ -3979,6 +4011,7 @@ If SELECT-ARTICLES, only select those articles from GROUP."
     (setq gnus-newsgroup-name group)
     (setq gnus-newsgroup-unselected nil)
     (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
+    (gnus-newsgroup-setup-coding-system)
 
     ;; Adjust and set lists of article marks.
     (when info
@@ -4489,7 +4522,9 @@ The resulting hash table is returned, or nil if no Xrefs were found."
         (or dependencies
             (save-excursion (set-buffer gnus-summary-buffer)
                             gnus-newsgroup-dependencies)))
-       headers id end ref)
+       headers id end ref
+       (rfc2047-default-charset gnus-newsgroup-coding-system)
+       (mm-charset-iso-8859-1-forced gnus-newsgroup-iso-8859-1-forced))
     (save-excursion
       (set-buffer nntp-server-buffer)
       ;; Translate all TAB characters into SPACE characters.
@@ -4642,7 +4677,9 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
   ;; Get the Xref when the users reads the articles since most/some
   ;; NNTP servers do not include Xrefs when using XOVER.
   (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
-  (let ((cur nntp-server-buffer)
+  (let ((rfc2047-default-charset gnus-newsgroup-coding-system)
+       (mm-charset-iso-8859-1-forced gnus-newsgroup-iso-8859-1-forced)
+       (cur nntp-server-buffer)
        (dependencies (or dependencies gnus-newsgroup-dependencies))
        number headers header)
     (save-excursion
@@ -6602,6 +6639,11 @@ or `gnus-select-method', no matter what backend the article comes from."
   (interactive)
   (gnus-group-edit-group gnus-newsgroup-name 'params))
 
+(defun gnus-summary-customize-parameters ()
+  "Customize the group parameters of the current group."
+  (interactive)
+  (gnus-group-customize gnus-newsgroup-name))
+
 (defun gnus-summary-enter-digest-group (&optional force)
   "Enter an nndoc group based on the current article.
 If FORCE, force a digest interpretation.  If not, try
@@ -6925,6 +6967,10 @@ article massaging functions being run."
   (if (not arg)
       ;; Select the article the normal way.
       (gnus-summary-select-article nil 'force)
+    ;; We have to require this here to make sure that the following
+    ;; dynamic binding isn't shadowed by autoloading.
+    (require 'gnus-async)
+    (require 'gnus-art)
     ;; Bind the article treatment functions to nil.
     (let ((gnus-have-all-headers t)
          gnus-article-display-hook
@@ -9099,6 +9145,48 @@ save those articles instead."
           (gnus-summary-exit))
         buffers)))))
 
+(defun gnus-newsgroup-setup-coding-system ()
+  "Setup newsgroup default coding system."
+  (setq gnus-newsgroup-coding-system
+       (or (and gnus-newsgroup-name
+                (or (gnus-group-find-parameter
+                     gnus-newsgroup-name 'charset)
+                    (let ((alist gnus-newsgroup-coding-system-alist) 
+                          elem (charset nil))
+                      (while alist
+                        (if (string-match 
+                             (car (setq elem (pop alist)))
+                             gnus-newsgroup-name)
+                            (setq alist nil
+                                  charset (cdr elem))))
+                      charset)))
+           rfc2047-default-charset))
+  (setq gnus-newsgroup-iso-8859-1-forced 
+       (and gnus-newsgroup-name
+            (or (gnus-group-find-parameter
+                 gnus-newsgroup-name 'iso-8859-1-forced)
+                (string-match  gnus-newsgroup-iso-8859-1-forced-regexp 
+                               gnus-newsgroup-name))))
+  (if (stringp gnus-newsgroup-coding-system)
+      (setq gnus-newsgroup-coding-system
+           (intern (downcase gnus-newsgroup-coding-system))))
+  (setq gnus-newsgroup-iso-8859-1-forced
+       (if (stringp gnus-newsgroup-iso-8859-1-forced)
+           (intern (downcase gnus-newsgroup-iso-8859-1-forced))
+         (and gnus-newsgroup-iso-8859-1-forced
+              gnus-newsgroup-coding-system))))
+
+;;;
+;;; MIME Commands
+;;;
+
+(defun gnus-summary-display-buttonized (&optional arg)
+  "Display the current buffer fully MIME-buttonized."
+  (interactive "P")
+  (require 'gnus-art)
+  (let ((gnus-unbuttonized-mime-types nil))
+    (gnus-summary-show-article arg)))
+    
 (gnus-ems-redefine)
 
 (provide 'gnus-sum)