+2003-05-29 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * gnus-registry.el (gnus-registry-save): allow forced saving even
+ when registry is not dirty. Use gnus-registry-trim to shorten the
+ gnus-registry-alist.
+ (gnus-registry-max-entries): new variable
+ (gnus-registry-trim): new function, trim gnus-registry-alist to
+ size gnus-registry-max-entries, sorting by entry mtime so the
+ newest entries stick around
+
+ * gnus-start.el (gnus-gnus-to-quick-newsrc-format): instead of
+ just one specific variable, allow a list of specific variables
+
2003-05-28 Dave Love <fx@gnu.org>
* rfc2047.el (rfc2047-encode-region): Skip ASCII at beginning and
* lpath.el: Add put-char-table and get-char-table.
-2003-05-28 Teodor Zlatanov <tzz@bwh.harvard.edu>
+2003-05-28 Teodor Zlatanov <tzz@lifelogs.com>
* gnus-registry.el (gnus-registry-dirty): flag for modified registry
(gnus-registry-save, gnus-registry-read)
:group 'gnus-registry
:type 'file)
+(defcustom gnus-registry-max-entries nil
+ "Maximum number of entries in the registry, nil for unlimited."
+ :group 'gnus-registry
+ :type 'integer)
+
;; Function(s) missing in Emacs 20
(when (memq nil (mapcar 'fboundp '(puthash)))
(require 'cl)
(while (re-search-forward " $" nil t)
(replace-match "" t t))))
-(defun gnus-registry-save ()
+(defun gnus-registry-save (&optional force)
;; TODO: delete entries with 0 groups
- (when gnus-registry-dirty
- (setq gnus-registry-alist (hashtable-to-alist gnus-registry-hashtb))
+ (when (or gnus-registry-dirty force)
+ (setq gnus-registry-alist (gnus-registry-trim
+ (hashtable-to-alist gnus-registry-hashtb)))
(gnus-registry-cache-save)
(setq gnus-registry-dirty nil)))
(setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))
(setq gnus-registry-dirty nil))
+(defun gnus-registry-trim (alist)
+ "Trim alist to size, using gnus-registry-max-entries."
+ (unless (null gnus-registry-max-entries)
+ (let ((timehash (make-hash-table
+ :size 4096
+ :test 'equal)))
+ (maphash
+ (lambda (key value)
+ (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
+ gnus-registry-hashtb)
+
+ (setq alist
+ (nthcdr
+ (- (length alist) gnus-registry-max-entries)
+ (sort alist
+ (lambda (a b)
+ (time-less-p
+ (cdr (gethash (car a) timehash))
+ (cdr (gethash (car b) timehash))))))))))
+
(defun alist-to-hashtable (alist)
"Build a hashtable from the values in ALIST."
(let ((ht (make-hash-table
(gnus-offer-save-summaries)
(gnus-save-newsrc-file)))
-(defun gnus-gnus-to-quick-newsrc-format (&optional minimal name specific-variable)
+(defun gnus-gnus-to-quick-newsrc-format (&optional minimal name &rest specific-variables)
"Print Gnus variables such as gnus-newsrc-alist in lisp format."
(princ ";; -*- emacs-lisp -*-\n")
(if name
(gnus-strip-killed-list)
gnus-killed-list))
(variables
- (if specific-variable
- (list specific-variable)
- (if gnus-save-killed-list gnus-variable-list
- ;; Remove the `gnus-killed-list' from the list of variables
- ;; to be saved, if required.
- (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))))
+ (or specific-variables
+ (if gnus-save-killed-list gnus-variable-list
+ ;; Remove the `gnus-killed-list' from the list of variables
+ ;; to be saved, if required.
+ (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))))
;; Peel off the "dummy" group.
(gnus-newsrc-alist (cdr gnus-newsrc-alist))
variable)