From 66eb80f0aae96a44e090d431c92ec1812a8c65d8 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Wed, 24 Oct 2001 22:59:58 +0000 Subject: [PATCH] Synch with Oort Gnus. --- lisp/ChangeLog | 7 ++++++ lisp/gnus.el | 67 ++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 99ca398..0f80117 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2001-10-24 Per Abrahamsen + + * gnus.el (gnus-expand-group-parameter): New function. + (gnus-expand-group-parameters): Call it. + (gnus-group-fast-parameter): New function. + (gnus-group-find-parameter): Call it. + 2001-10-23 Per Abrahamsen * gnus.el (gnus-news-group-p): Rewrote. Now accepts a header diff --git a/lisp/gnus.el b/lisp/gnus.el index 700d760..daed3a0 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -2877,6 +2877,15 @@ You should probably use `gnus-find-method-for-group' instead." params-list)))) params-list)) +(defun gnus-expand-group-parameter (match value group) + "Use MATCH to expand VALUE in GROUP." + (with-temp-buffer + (insert group) + (goto-char (point-min)) + (while (re-search-forward match nil t) + (replace-match value)) + (buffer-string))) + (defun gnus-expand-group-parameters (match parameters group) "Go through PARAMETERS and expand them according to the match data." (let (new) @@ -2884,28 +2893,58 @@ You should probably use `gnus-find-method-for-group' instead." (if (and (stringp (cdr elem)) (string-match "\\\\" (cdr elem))) (push (cons (car elem) - (with-temp-buffer - (insert group) - (goto-char (point-min)) - (while (re-search-forward match nil t) - (replace-match (cdr elem))) - (buffer-string))) + (gnus-expand-group-parameter match (cdr elem) group)) new) (push elem new))) new)) +(defun gnus-group-fast-parameter (group symbol &optional allow-list) + "For GROUP, return the value of SYMBOL. + +You should call this in the `gnus-group-buffer' buffer. +The function `gnus-group-find-parameter' will do that for you." + ;; The speed trick: No cons'ing and quit early. + (or (let ((params (funcall gnus-group-get-parameter-function group))) + ;; Start easy, check the "real" group parameters. + (gnus-group-parameter-value params symbol allow-list)) + ;; We didn't found it there, try `gnus-parameters'. + (let ((result nil) + (head nil) + (tail gnus-parameters)) + ;; A good old-fashioned non-cl loop. + (while tail + (setq head (car tail) + tail (cdr tail)) + ;; The car is regexp matching for matching the group name. + (when (string-match (car head) group) + ;; The cdr is the parameters. + (setq result (gnus-group-parameter-value (cdr head) + symbol allow-list)) + (when result + ;; Expand if necessary. + (if (and (stringp result) (string-match "\\\\" result)) + (setq result (gnus-expand-group-parameter (car head) + result group))) + ;; Exit the loop early. + (setq tail nil)))) + ;; Done. + result))) + (defun gnus-group-find-parameter (group &optional symbol allow-list) "Return the group parameters for GROUP. -If SYMBOL, return the value of that symbol in the group parameters." +If SYMBOL, return the value of that symbol in the group parameters. + +If you call this function inside a loop, consider using the faster +`gnus-group-fast-parameter' instead." (save-excursion (set-buffer gnus-group-buffer) - (let ((parameters - (nconc - (copy-sequence - (funcall gnus-group-get-parameter-function group)) - (gnus-parameters-get-parameter group)))) - (if symbol - (gnus-group-parameter-value parameters symbol allow-list) + (if symbol + (gnus-group-fast-parameter group symbol allow-list) + (let ((parameters + (nconc + (copy-sequence + (funcall gnus-group-get-parameter-function group)) + (gnus-parameters-get-parameter group)))) parameters)))) (defun gnus-group-get-parameter (group &optional symbol allow-list) -- 1.7.10.4