tale@pawl.rpi.edu (David C Lawrence) (06/27/89)
Looking over GNUS 3.12 which was recently distributed I found that gnus-user-tale.el was missing something which I contributed that I thought quite useful. (Most of the other personal customizations I had were incorporated so I was able to trim my extensions file by quite a bit.) This is a function which I have as my gnus-Save-newsrc-hook. I like it because it keeps my .newsrc and .newsrc.el trimmed down by not letting unsubscribed groups build up long strings of marked article ranges because of cross-posted articles. (This saves over 14k on my average newsrc.el size.) It also keeps a fairly organized newsrc by sorting unsubscribed groups alphabetically and putting them all at the end of my newsrc. It doesn't do anything to the order of subscribed groups. If you only desire one feature or the other you can call it with the appropriate optional arguments. Here 'tis. --cut-- ;;; Based on an idea by David.Detlefs@DLD.AVALON.CS.CMU.EDU ;;; Suitable for calling as a gnus-Save-newsrc-hook. (defun gnus-reorder-newsrc-file (&optional nosort nocompress) (let (gnus-unsub-assoc reordered) (save-excursion (set-buffer (get-file-buffer gnus-current-startup-file)) (goto-char (point-max)) ;; protect against a totally unsubscribed .newsrc (if (not (re-search-backward "^.*:" nil t)) nil (re-search-forward "^.*! " nil t) (setq gnus-unsub-assoc (memq (assoc (buffer-substring (- (point) 2) (progn (beginning-of-line) (point))) gnus-newsrc-assoc) gnus-newsrc-assoc)) (while (re-search-backward "^.*! " nil t) (let ((position (point)) unsub-line) (setq gnus-unsub-assoc (cons (assoc (buffer-substring (point) (progn (skip-chars-forward "^!") (point))) gnus-newsrc-assoc) gnus-unsub-assoc) unsub-line (buffer-substring position (progn (beginning-of-line) (next-line 1) (point))) reordered t) (delete-region position (point)) (goto-char (point-max)) (insert unsub-line) (goto-char position))) (if (or nosort (not reordered)) nil (sort-lines nil (progn (re-search-forward "! " nil t) (beginning-of-line) (point)) (point-max)) (setq gnus-unsub-assoc (sort gnus-unsub-assoc 'gnus-assoc-lessp))) (if nocompress nil (goto-char (point-min)) (re-search-forward "! " nil t) (while (re-search-forward "," nil t) (let ((compress-group (assoc (buffer-substring (progn (beginning-of-line) (point)) (progn (skip-chars-forward "^!") (point))) gnus-newsrc-assoc)) first-unread) (delete-region (progn (skip-chars-forward "^-,") (point)) (progn (end-of-line) (skip-chars-backward "^-,") (point))) (insert "-") (setcdr (nth 2 compress-group) (cdr (nth (1- (length compress-group)) compress-group))) (setcdr (memq (nth 2 compress-group) compress-group) nil)))) (setq gnus-newsrc-assoc (append (gnus-set-difference gnus-newsrc-assoc gnus-unsub-assoc) gnus-unsub-assoc)))))) (defun gnus-assoc-lessp (list1 list2) "Returns t if the car of LIST1 (a string) is less than the car of LIST2 by doing comparison with string-lessp." (string-lessp (car list1) (car list2))) --end-- -- (setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet")) "I realize the Internet isn't the whole world, but it is the center of it." -- Greg Woods