Function: gnus-newsrc-parse-options
gnus-newsrc-parse-options is an autoloaded and byte-compiled function
defined in gnus-start.el.gz.
Signature
(gnus-newsrc-parse-options OPTIONS)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-start.el.gz
;; Parse options lines to find "options -n !all rec.all" and stuff.
;; The return value will be a list on the form
;; ((regexp1 . ignore)
;; (regexp2 . subscribe)...)
;; When handling new newsgroups, groups that match a `ignore' regexp
;; will be ignored, and groups that match a `subscribe' regexp will be
;; subscribed. A line like
;; options -n !all rec.all
;; will lead to a list that looks like
;; (("^rec\\..+" . subscribe)
;; ("^.+" . ignore))
;; So all "rec.*" groups will be subscribed, while all the other
;; groups will be ignored. Note that "options -n !all rec.all" is very
;; different from "options -n rec.all !all".
(defun gnus-newsrc-parse-options (options)
(let (out eol)
(save-excursion
(gnus-set-work-buffer)
(insert (regexp-quote options))
;; First we treat all continuation lines.
(goto-char (point-min))
(while (re-search-forward "\n[ \t]+" nil t)
(replace-match " " t t))
;; Then we transform all "all"s into ".+"s.
(goto-char (point-min))
(while (re-search-forward "\\ball\\b" nil t)
(replace-match ".+" t t))
(goto-char (point-min))
;; We remove all other options than the "-n" ones.
(while (re-search-forward "[ \t]-[^n][^-]*" nil t)
(replace-match " ")
(forward-char -1))
(goto-char (point-min))
;; We are only interested in "options -n" lines - we
;; ignore the other option lines.
(while (re-search-forward "[ \t]-n" nil t)
(setq eol
(or (save-excursion
(and (re-search-forward "[ \t]-n" (point-at-eol) t)
(- (point) 2)))
(point-at-eol)))
;; Search for all "words"...
(while (re-search-forward "[^ \t,\n]+" eol t)
(if (eq (char-after (match-beginning 0)) ?!)
;; If the word begins with a bang (!), this is a "not"
;; spec. We put this spec (minus the bang) and the
;; symbol `ignore' into the list.
(push (cons (concat
"^" (buffer-substring
(1+ (match-beginning 0))
(match-end 0))
"\\($\\|\\.\\)")
'ignore)
out)
;; There was no bang, so this is a "yes" spec.
(push (cons (concat "^" (match-string 0) "\\($\\|\\.\\)")
'subscribe)
out))))
(setq gnus-newsrc-options-n out))))