6 ; Oort Gnus v0.08 - This release updated agent to no longer use
7 ; history file and to support a compressed alist.
9 (defun gnus-agent-convert-to-compressed-agentview (converting-to)
10 "Iterates over all agentview files to ensure that they have been
11 converted to the compressed format."
13 (let ((search-in (list gnus-agent-directory))
18 (while (setq here (pop search-in))
19 (setq members (directory-files here t))
20 (while (setq member (pop members))
21 (cond ((string-match "/\\.\\.?$" member)
23 ((file-directory-p member)
24 (push member search-in))
25 ((equal (file-name-nondirectory member) ".agentview")
26 (setq converted-something
27 (or (gnus-agent-convert-agentview member)
28 converted-something))))))
30 (if converted-something
31 (gnus-message 4 "Successfully converted Gnus %s offline (agent) files to %s" gnus-newsrc-file-version converting-to))))
33 (defun gnus-agent-convert-agentview (file)
34 "Load FILE and do a `read' there."
36 (nnheader-insert-file-contents file)
37 (goto-char (point-min))
38 (let ((inhibit-quit t)
39 (alist (read (current-buffer)))
40 (version (condition-case nil (read (current-buffer))
48 (gnus-command-method nil))
49 (mm-disable-multibyte) ;; everything is binary
52 (let ((file (concat (file-name-directory file) "/history")))
53 (when (file-exists-p file)
54 (nnheader-insert-file-contents file)
55 (setq history-file file)))
57 (goto-char (point-min))
60 "[^\t\n]+\t\\([0-9]+\\)\t\\([^ \n]+\\) \\([0-9]+\\)")
61 (string= (gnus-agent-article-name ".agentview" (match-string 2))
63 (setq entry (assoc (string-to-number (match-string 3)) alist)))
64 (setcdr entry (string-to-number (match-string 1))))
66 (setq changed-version t)))
68 (setq changed-version t)))
72 (let ((compressed nil))
73 (mapcar (lambda (pair)
74 (let* ((article-id (car pair))
75 (day-of-download (cdr pair))
76 (comp-list (assq day-of-download compressed)))
79 (cons article-id (cdr comp-list)))
81 (cons (list day-of-download article-id)
84 (mapcar (lambda (comp-list)
86 (gnus-compress-sequence
87 (nreverse (cdr comp-list)))))
89 (princ compressed (current-buffer)))
93 (delete-file history-file))
96 ;; End of Oort Gnus v0.08 updates
98 ;; No Gnus v0.3 - This release provides a mechanism for upgrading gnus
99 ;; from previous versions. Therefore, the previous
100 ;; hacks to handle a gnus-agent-expire-days that
101 ;; specifies a list of values can be removed.
103 (defun gnus-agent-unlist-expire-days (converting-to)
104 (when (listp gnus-agent-expire-days)
107 (save-window-excursion
108 (setq buffer (gnus-get-buffer-create " *Gnus agent upgrade*"))
111 (insert "The definition of gnus-agent-expire-days has been changed.\nYou currently have it set to the list:\n ")
112 (gnus-pp gnus-agent-expire-days)
114 (insert "\nIn order to use version '" converting-to "' of gnus, you will need to set\n")
115 (insert "gnus-agent-expire-days to an integer. If you still wish to set different\n")
116 (insert "expiration days to individual groups, you must instead set the\n")
117 (insert "'agent-days-until-old group and/or topic parameter.\n")
119 (insert "If you would like, gnus can iterate over every group comparing its name to the\n")
120 (insert "regular expressions that you currently have in gnus-agent-expire-days. When\n")
121 (insert "gnus finds a match, it will update that group's 'agent-days-until-old group\n")
122 (insert "parameter to the value associated with the regular expression.\n")
124 (insert "Whether gnus assigns group parameters, or not, gnus will terminate with an\n")
125 (insert "ERROR as soon as this function completes. The reason is that you must\n")
126 (insert "manually edit your configuration to either not set gnus-agent-expire-days or\n")
127 (insert "to set it to an integer before gnus can be used.\n")
129 (insert "Once you have successfully edited gnus-agent-expire-days, gnus will be able to\n")
130 (insert "execute past this function.\n")
132 (insert "Should gnus use gnus-agent-expire-days to assign\n")
133 (insert "agent-days-until-old parameters to individual groups? (Y/N)")
135 (switch-to-buffer buffer)
139 (let ((echo-keystrokes 0)
141 (while (progn (setq c (read-char-exclusive))
142 (cond ((or (eq c ?y) (eq c ?Y))
144 (let ((groups (gnus-group-listed-groups)))
146 (let* ((group (pop groups))
147 (days gnus-agent-expire-days)
150 (when (eq 0 (string-match
153 (throw 'found (cadar days)))
154 (setq days (cdr days)))
157 (gnus-group-set-parameter group 'agent-days-until-old
161 ((or (eq c ?n) (eq c ?N))
165 (kill-buffer buffer))
166 (error "Change gnus-agent-expire-days to an integer for gnus to start."))))
168 ;; The gnus-agent-unlist-expire-days has its own conversion prompt.
169 ;; Therefore, hide the default prompt.
170 (gnus-convert-mark-converter-prompt 'gnus-agent-unlist-expire-days t)
172 (defun gnus-agent-unhook-expire-days (converting-to)
173 "Remove every lambda from gnus-group-prepare-hook that mention the
174 symbol gnus-agent-do-once in their definition. This should NOT be
175 necessary as gnus-agent.el no longer adds them. However, it is
176 possible that the hook was persistently saved."
177 (let ((h t)) ; iterate from bgn of hook
179 (let ((func (progn (when (eq h t)
180 ;; init h to list of functions
181 (setq h (cond ((listp gnus-group-prepare-hook)
182 gnus-group-prepare-hook)
183 ((boundp 'gnus-group-prepare-hook)
184 (list gnus-group-prepare-hook)))))
187 (when (cond ((eq (type-of func) 'compiled-function)
188 ;; Search def. of compiled function for gnus-agent-do-once string
194 (setq definition (cons char definition)))))
195 (princ func) ; populates definition with reversed list of characters
196 (let* ((i (length definition))
197 (s (make-string i 0)))
199 (aset s (setq i (1- i)) (pop definition)))
201 (string-match "\\bgnus-agent-do-once\\b" s))))
203 (eq (cadr (nth 2 func)) 'gnus-agent-do-once) ; handles eval'd lambda
206 (remove-hook 'gnus-group-prepare-hook func)
207 ;; I don't what remove-hook is going to actually do to the
208 ;; hook list so start over from the beginning.
211 ;; gnus-agent-unhook-expire-days is safe in that it does not modify
212 ;; the .newsrc.eld file.
213 (gnus-convert-mark-converter-prompt 'gnus-agent-unhook-expire-days t)