Skip to content

Instantly share code, notes, and snippets.

@arnested
Created February 23, 2012 18:58
Show Gist options
  • Save arnested/1894367 to your computer and use it in GitHub Desktop.
Save arnested/1894367 to your computer and use it in GitHub Desktop.
;;; gnus-auto-subscribe.el --- auto subscribe groups
;; Copyright (C) 2005 Arne J,Ax(Brgensen
;; Author: Arne J,Ax(Brgensen <arne@arnested.dk>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;; USA.
;;; Commentary:
;;; Code:
(require 'gnus)
(require 'gnus-start)
(require 'gnus-group)
(require 'time-date)
(defvar gnus-auto-subscribe-default-period 10)
;;;###autoload
(defun gnus-auto-subscribe-groups nil
"Subscribe groups with `auto-subscribe' group parameter."
(let ((newsrc (cdr gnus-newsrc-alist))
(period))
(dolist (info newsrc)
(let* ((group (gnus-info-group info))
(spec (gnus-group-find-parameter group 'auto-subscribe t)))
(when spec
(unless (listp spec)
(setq spec (list spec)))
(if (eq (car-safe spec) t)
(setq period gnus-auto-subscribe-default-period)
(setq period (car spec)))
(when (stringp period)
(setq period (string-to-number period)))
(if (cadr spec)
(when (>= (days-between (current-time-string) (cadr spec))
period)
(gnus-group-set-parameter group 'auto-subscribe
(list (car spec) (current-time-string)))
(gnus-group-unsubscribe-group group gnus-level-default-subscribed))
(gnus-group-set-parameter group 'auto-subscribe
(list (car spec) (current-time-string)))))))))
(provide 'gnus-auto-subscribe)
;;; gnus-auto-subscribe.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment