2000-12-22 21:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 23 Dec 2000 02:08:08 +0000 (02:08 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 23 Dec 2000 02:08:08 +0000 (02:08 +0000)
* gnus.el (gnus-group-parameters-more): New variable.
* gnus-cus.el (gnus-group-customize): Use it.

* gnus.el (gnus-define-group-parameter): New macro.
(auto-expire): Use it
(total-expire): Use it.
* gnus-art.el (banner): Use it.

* mml.el (mml-parse): save-excursion. Suggested by Lloyd Zusman
<ljz@asfast.com>.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-cus.el
lisp/gnus.el
lisp/mml.el

index d4de092..d43adf3 100644 (file)
@@ -1,3 +1,16 @@
+2000-12-22 21:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * gnus.el (gnus-group-parameters-more): New variable.
+       * gnus-cus.el (gnus-group-customize): Use it.
+
+       * gnus.el (gnus-define-group-parameter): New macro.
+       (auto-expire): Use it
+       (total-expire): Use it.
+       * gnus-art.el (banner): Use it.
+
+       * mml.el (mml-parse): save-excursion. Suggested by Lloyd Zusman
+       <ljz@asfast.com>.
+
 2000-12-22 12:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus-topic.el (gnus-topic-create-topic): Use list.
index 0729e0d..08d4acb 100644 (file)
@@ -238,6 +238,27 @@ For example,
   :type '(repeat (cons symbol regexp))
   :group 'gnus-article-washing)
 
+(gnus-define-group-parameter 
+ banner
+ :variable-document
+ "Alist of regexps (to match group names) and banner."
+ :variable-group gnus-article-washing
+ :parameter-type 
+ '(choice :tag "Banner"
+         :value nil
+         (const :tag "Remove signature" signature)
+         (symbol :tag "Item in `gnus-article-banner-alist'" none)
+         regexp
+         (const :tag "None" nil))
+ :parameter-document 
+ "If non-nil, specify how to remove `banners' from articles.
+
+Symbol `signature' means to remove signatures delimited by
+`gnus-signature-separator'.  Any other symbol is used to look up a
+regular expression to match the banner in `gnus-article-banner-alist'.
+A string is used as a regular expression to match the banner
+directly.")
+
 (defcustom gnus-emphasis-alist
   (let ((format
         "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
@@ -1813,7 +1834,7 @@ always hide."
   (save-excursion
     (save-restriction
       (let ((inhibit-point-motion-hooks t)
-           (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
+           (banner (gnus-parameter-banner gnus-newsgroup-name))
            (gnus-signature-limit nil)
            buffer-read-only beg end)
        (when banner
index 87987e5..4d3aa94 100644 (file)
 ;;; Code:
 
 (require 'wid-edit)
+(require 'gnus)
 (require 'gnus-score)
 (require 'gnus-topic)
+(require 'gnus-art)
 
 ;;; Widgets:
 
@@ -168,29 +170,6 @@ is present and a string, this string will be inserted literally as a
 `gcc' header (this symbol takes precedence over any default `Gcc'
 rules as described later).")
 
-    (banner (choice :tag "Banner"
-                   :value nil
-                   (const :tag "Remove signature" signature)
-                   (symbol :tag "Item in `gnus-article-banner-alist'" none)
-                   regexp
-                   (const :tag "None" nil)) "\
-If non-nil, specify how to remove `banners' from articles.
-
-Symbol `signature' means to remove signatures delimited by
-`gnus-signature-separator'.  Any other symbol is used to look up a
-regular expression to match the banner in `gnus-article-banner-alist'.
-A string is used as a regular expression to match the banner
-directly.")
-
-    (auto-expire (const :tag "Automatic Expire" t) "\
-All articles that are read will be marked as expirable.")
-
-    (total-expire (const :tag "Total Expire" t) "\
-All read articles will be put through the expiry process
-
-This happens even if they are not marked as expirable.
-Use with caution.")
-
     (expiry-wait (choice :tag  "Expire Wait"
                         :value never
                         (const never)
@@ -327,6 +306,7 @@ DOC is a documentation string for the parameter.")
                                (const :format "" ,(nth 0 entry))
                                ,(nth 1 entry)))
                       (append gnus-group-parameters 
+                              (reverse gnus-group-parameters-more)
                               (if group
                                   gnus-extra-group-parameters
                                 gnus-extra-topic-parameters)))))
index f21e9ce..8c96da4 100644 (file)
@@ -848,6 +848,76 @@ be set in `.emacs' instead."
 (require 'gnus-util)
 (require 'nnheader)
 
+(defvar gnus-group-parameters-more nil)
+
+(defmacro gnus-define-group-parameter (param &rest rest)
+  "Define a group parameter PARAM.
+REST is a plist of following:
+:type               One of `bool', `list' or `nil'.
+:function           The name of the function.
+:function-document  The document of the function.
+:parameter-type     The type for customizing the parameter.
+:parameter-document The document for the parameter.
+:variable           The name of the variable.
+:variable-document  The document for the variable.
+:variable-group     The group for customizing the variable.
+:variable-type      The type for customizing the variable.
+:variable-default   The default value of the variable."
+  (let* ((type (plist-get rest :type))
+        (parameter-type (plist-get rest :parameter-type))
+        (parameter-document (plist-get rest :parameter-document))
+        (function (or (plist-get rest :function)
+                      (intern (format "gnus-parameter-%s" param))))
+        (function-document (or (plist-get rest :function-document) ""))
+        (variable (or (plist-get rest :variable)
+                      (intern (format "gnus-parameter-%s-alist" param))))
+        (variable-document (or (plist-get rest :variable-document) ""))
+        (variable-group (plist-get rest :variable-group))
+        (variable-type (or (plist-get rest :variable-type)
+                           `(quote (repeat (list (regexp :tag "Group")
+                                                 ,parameter-type)))))
+        (variable-default (plist-get rest :variable-default)))
+    (list 
+     'progn
+     `(defcustom ,variable ,variable-default
+       ,variable-document
+       :group 'gnus-group-parameter
+       :group ',variable-group
+       :type ,variable-type)
+     `(setq gnus-group-parameters-more
+           (delq (assq ',param gnus-group-parameters-more)
+                 gnus-group-parameters-more))
+     `(add-to-list 'gnus-group-parameters-more
+                  (list ',param
+                        ,parameter-type
+                        ,parameter-document))
+     (if (eq type 'bool)
+        `(defun ,function (group)
+           ,function-document
+           (let ((params (gnus-group-find-parameter group))
+                 val)
+             (cond
+              ((memq ',param params)
+               t)
+              ((setq val (assq ',param params))
+               (cdr val))
+              (,variable
+               (string-match ,variable group)))))
+       `(defun ,function (name)
+         ,function-document
+         (and name
+              (or (gnus-group-find-parameter name ',param)
+                  (let ((alist ,variable)
+                        elem value)
+                    (while (setq elem (pop alist))
+                      (when (and name
+                                 (string-match (car elem) name))
+                        (setq alist nil
+                              value (cdr elem))))
+                    ,(if type
+                         'value
+                       '(if (consp value) (car value) value))))))))))
+
 (defcustom gnus-home-directory "~/"
   "Directory variable that specifies the \"home\" directory.
 All other Gnus path variables are initialized from this variable."
@@ -1364,23 +1434,48 @@ to be desirable; see the manual for further details."
   :type '(choice (const nil)
                 integer))
 
-(defcustom gnus-auto-expirable-newsgroups nil
+(gnus-define-group-parameter 
+ auto-expire
+ :type bool
+ :function gnus-group-auto-expirable-p
+ :function-document
+ "Check whether GROUP is auto-expirable or not."
+ :variable gnus-auto-expirable-newsgroups
+ :variable-default nil
+ :variable-document
   "*Groups in which to automatically mark read articles as expirable.
 If non-nil, this should be a regexp that should match all groups in
 which to perform auto-expiry.  This only makes sense for mail groups."
-  :group 'nnmail-expire
-  :type '(choice (const nil)
-                regexp))
-
-(defcustom gnus-total-expirable-newsgroups nil
-  "*Groups in which to perform expiry of all read articles.
+  :variable-group nnmail-expire
+  :variable-type '(choice (const nil)
+                         regexp)
+  :parameter-type '(const :tag "Automatic Expire" t) 
+  :parameter-document 
+  "All articles that are read will be marked as expirable.")
+
+(gnus-define-group-parameter 
+ total-expire
+ :type bool
+ :function gnus-group-total-expirable-p
+ :function-document
+ "Check whether GROUP is total-expirable or not."
+ :variable gnus-total-expirable-newsgroups 
+ :variable-default nil
+ :variable-document
+ "*Groups in which to perform expiry of all read articles.
 Use with extreme caution.  All groups that match this regexp will be
 expiring - which means that all read articles will be deleted after
 \(say) one week.        (This only goes for mail groups and the like, of
 course.)"
-  :group 'nnmail-expire
-  :type '(choice (const nil)
-                regexp))
+  :variable-group nnmail-expire
+  :variable-type '(choice (const nil)
+                         regexp)
+  :parameter-type '(const :tag "Total Expire" t) 
+  :parameter-document 
+  "All read articles will be put through the expiry process
+
+This happens even if they are not marked as expirable.
+Use with caution.")
 
 (defcustom gnus-group-uncollapsed-levels 1
   "Number of group name elements to leave alone when making a short group name."
@@ -2282,30 +2377,6 @@ that that variable is buffer-local to the summary buffers."
   (let ((group (or group gnus-newsgroup-name)))
     (not (gnus-check-backend-function 'request-replace-article group))))
 
-(defun gnus-group-total-expirable-p (group)
-  "Check whether GROUP is total-expirable or not."
-  (let ((params (gnus-group-find-parameter group))
-       val)
-    (cond
-     ((memq 'total-expire params)
-      t)
-     ((setq val (assq 'total-expire params)) ; (auto-expire . t)
-      (cdr val))
-     (gnus-total-expirable-newsgroups  ; Check var.
-      (string-match gnus-total-expirable-newsgroups group)))))
-
-(defun gnus-group-auto-expirable-p (group)
-  "Check whether GROUP is auto-expirable or not."
-  (let ((params (gnus-group-find-parameter group))
-       val)
-    (cond
-     ((memq 'auto-expire params)
-      t)
-     ((setq val (assq 'auto-expire params)) ; (auto-expire . t)
-      (cdr val))
-     (gnus-auto-expirable-newsgroups   ; Check var.
-      (string-match gnus-auto-expirable-newsgroups group)))))
-
 (defun gnus-virtual-group-p (group)
   "Say whether GROUP is virtual or not."
   (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
index e406c10..4e1a4cd 100644 (file)
@@ -90,13 +90,14 @@ one charsets.")
 
 (defun mml-parse ()
   "Parse the current buffer as an MML document."
-  (goto-char (point-min))
-  (let ((table (syntax-table)))
-    (unwind-protect
-       (progn
-         (set-syntax-table mml-syntax-table)
-         (mml-parse-1))
-      (set-syntax-table table))))
+  (save-excursion
+    (goto-char (point-min))
+    (let ((table (syntax-table)))
+      (unwind-protect
+         (progn
+           (set-syntax-table mml-syntax-table)
+           (mml-parse-1))
+       (set-syntax-table table)))))
 
 (defun mml-parse-1 ()
   "Parse the current buffer as an MML document."