hallvard@IFI.UIO.NO (Hallvard B Furuseth) (02/08/90)
Here is a patch to gnus.el, to make it understand the options line in .newsrc somewhat better: There may be several options lines. Lines beginning with whitespace after the initial options line are continuation lines. Also, f.ex gnu.all.bug is converted to regexp gnu\..*\.bug, not gnu\.all\.bug. The newsgroup lines, and the options line itself, may NOT begin with whitespace. Hallvard Furuseth hallvard@ifi.uio.no *** gnus.el~ Wed Aug 23 13:50:37 1989 --- gnus.el Thu Feb 8 16:07:54 1990 *************** *** 5329,5347 **** (setq gnus-newsrc-options-n-no nil) (setq gnus-newsrc-assoc nil) ! ;; Save options line to variable. ! (goto-char (point-min)) ! (if (re-search-forward "^[ \t]*options[ \t]*\\(.*[^ \t\n]\\)[ \t]*$" nil t) ! (progn ! (setq gnus-newsrc-options ! (buffer-substring (match-beginning 1) (match-end 1))) ! ;; Compile "-n" option. ! (if (string-match "\\(^\\|[ \t]\\)-n" gnus-newsrc-options) ! (let ((options (substring gnus-newsrc-options (match-end 0))) ! (yes nil) (no nil) ! (yes-or-no nil) ! (newsgroup nil)) (while (string-match ! "^[ \t]*\\(!?\\)\\([^--- \t][^ \t]*\\)" options) (setq yes-or-no (substring options (match-beginning 1) (match-end 1))) --- 5329,5353 ---- (setq gnus-newsrc-options-n-no nil) (setq gnus-newsrc-assoc nil) ! ;; Save options lines to variable. ! (let (options ! (yes nil) (no nil) ! (yes-or-no nil) ! (newsgroup nil)) ! (goto-char (point-min)) ! (while (re-search-forward ! "^options[ \t]+\\(\\(\n[ \t]+\\)?\\(.*[^ \t\n]\\)[ \t]*$\\)+" ! nil t) ! (setq options (buffer-substring (match-beginning 1) (match-end 3)) ! gnus-newsrc-options (concat ! (or gnus-newsrc-options "") ! (if gnus-newsrc-options "\noptions " "") ! options)) ! ;; Compile "-n" option. ! (if (string-match "\\(^\\|[ \t]\\)-n" options) ! (progn ! (setq options (substring options (match-end 0))) (while (string-match ! "^[ \t]*\\(!?\\)\\([^--- \t\n][^ \t\n]*\\)" options) (setq yes-or-no (substring options (match-beginning 1) (match-end 1))) *************** *** 5348,5363 **** (setq newsgroup (regexp-quote ! (substring options ! (match-beginning 2) (match-end 2)))) (setq options (substring options (match-end 2))) ! (cond ((and (string-equal yes-or-no "!") ! (string-equal newsgroup "all")) ! (setq no (cons ".*" no))) ! ((string-equal yes-or-no "!") (setq no (cons newsgroup no))) ! ((string-equal newsgroup "all")) ;Ignore `all'. (t (setq yes (cons newsgroup yes))) )) (if yes (setq gnus-newsrc-options-n-yes --- 5354,5376 ---- (setq newsgroup (regexp-quote ! (concat "." ! (substring options ! (match-beginning 2) (match-end 2)) ! "."))) (setq options (substring options (match-end 2))) ! (while (string-match "\\.all\\\\" newsgroup) ! (setq newsgroup ! (concat ! (substring newsgroup 0 (1+ (match-beginning 0))) ! ".*" ! (substring newsgroup (1- (match-end 0)))))) ! (setq newsgroup (substring newsgroup 2 -2)) ! (cond ((string-equal yes-or-no "!") (setq no (cons newsgroup no))) ! ((string-equal newsgroup ".*")) ;Ignore `all'. (t (setq yes (cons newsgroup yes))) )) + ))) (if yes (setq gnus-newsrc-options-n-yes *************** *** 5380,5389 **** (cdr no))) (car no) "\\)"))) ! )) ! )) ;; Parse body of .newsrc file (goto-char (point-min)) (while (re-search-forward ! "^[ \t]*\\([^!: \t]+\\)[ \t]*\\([!:]\\)[ \t]*\\(.*\\)$" nil t) (setq newsgroup (buffer-substring (match-beginning 1) (match-end 1))) ;; Check duplications of newsgroups. --- 5393,5401 ---- (cdr no))) (car no) "\\)"))) ! ) ;; Parse body of .newsrc file (goto-char (point-min)) (while (re-search-forward ! "^\\([^!: \t\n]+\\)[ \t]*\\([!:]\\)[ \t]*\\(.*\\)$" nil t) (setq newsgroup (buffer-substring (match-beginning 1) (match-end 1))) ;; Check duplications of newsgroups. *************** *** 5474,5478 **** (goto-char (point-min)) (while (re-search-forward ! (concat "^[ \t]*" (regexp-quote group) "[ \t]*[:!]") nil t) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point))) --- 5486,5490 ---- (goto-char (point-min)) (while (re-search-forward ! (concat "^" (regexp-quote group) "[ \t]*[:!]") nil t) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point))) *************** *** 5491,5495 **** (goto-char (point-min)) (re-search-forward ! (concat "^[ \t]*" (regexp-quote next) "[ \t]*[:!]") nil t))) (beginning-of-line)) --- 5503,5507 ---- (goto-char (point-min)) (re-search-forward ! (concat "^" (regexp-quote next) "[ \t]*[:!]") nil t))) (beginning-of-line)) *************** *** 5499,5503 **** (insert "\n")))) ;; Insert after options line. ! (if (looking-at "^[ \t]*options[ \t]") (forward-line 1)) (insert group ;Group name --- 5511,5515 ---- (insert "\n")))) ;; Insert after options line. ! (if (looking-at "^\\(options\\)?[ \t\n]") (forward-line 1)) (insert group ;Group name