From: ShengHuo ZHU Date: Thu, 6 Dec 2001 15:32:18 +0000 (+0000) Subject: 2001-12-06 10:00:00 ShengHuo ZHU X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=commitdiff_plain;h=1e294f2ccb951a4215cd3354cef17e0305433db4 2001-12-06 10:00:00 ShengHuo ZHU * nnweb.el (nnweb-replace-in-string): Removed. * gnus-util.el (gnus-replace-in-string): New. (gnus-mode-string-quote): Use it. * nnrss.el (nnrss-format-string): Use gnus-replace-in-string. * nnwfm.el (nnwfm-create-mapping): Ditto. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2e5afa18b..f916d08cd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2001-12-06 10:00:00 ShengHuo ZHU + + * nnweb.el (nnweb-replace-in-string): Removed. + + * gnus-util.el (gnus-replace-in-string): New. + (gnus-mode-string-quote): Use it. + + * nnrss.el (nnrss-format-string): Use gnus-replace-in-string. + * nnwfm.el (nnwfm-create-mapping): Ditto. + 2001-12-06 01:00:00 ShengHuo ZHU * dgnushack.el (dgnushack-compile): nnrss.el and diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index 2e92f33fd..ec4f49008 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -45,6 +45,22 @@ (autoload 'rmail-count-new-messages "rmail") (autoload 'rmail-show-message "rmail")) +(eval-and-compile + (cond + ((fboundp 'replace-in-string) + (defalias 'gnus-replace-in-string 'replace-in-string)) + ((fboundp 'replace-regexp-in-string) + (defun gnus-replace-in-string (string regexp newtext &optional literal) + (replace-regexp-in-string regexp newtext string nil literal))) + (t + (defun gnus-replace-in-string (string regexp newtext &optional literal) + (let ((start 0) tail) + (while (string-match regexp string start) + (setq tail (- (length string) (match-end 0))) + (setq string (replace-match newtext t t string)) + (setq start (- (length string) tail)))) + string)))) + (defun gnus-boundp (variable) "Return non-nil if VARIABLE is bound and non-nil." (and (boundp variable) @@ -395,13 +411,7 @@ Cache the result as a text property stored in DATE." (defun gnus-mode-string-quote (string) "Quote all \"%\"'s in STRING." - (save-excursion - (gnus-set-work-buffer) - (insert string) - (goto-char (point-min)) - (while (search-forward "%" nil t) - (insert "%")) - (buffer-string))) + (gnus-replace-in-string string "%" "%%")) ;; Make a hash table (default and minimum size is 256). ;; Optional argument HASHSIZE specifies the table size. diff --git a/lisp/nnrss.el b/lisp/nnrss.el index 9d755e827..367cfce75 100644 --- a/lisp/nnrss.el +++ b/lisp/nnrss.el @@ -572,13 +572,8 @@ It is useful when `(setq nnrss-use-local t)'." (if changed (nnrss-save-server-data "")))) -(defun nnrss-replace-in-string (string match newtext) - (while (string-match match string) - (setq string (replace-match newtext t t string))) - string) - (defun nnrss-format-string (string) - (nnrss-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " ")) + (gnus-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " ")) (defun nnrss-node-text (node) (if (and node (listp node)) diff --git a/lisp/nnweb.el b/lisp/nnweb.el index 740b18263..277e24e55 100644 --- a/lisp/nnweb.el +++ b/lisp/nnweb.el @@ -987,11 +987,6 @@ If FOLLOW-REFRESH is non-nil, redirect refresh url in META." (listp (cdr element))) (nnweb-text-1 element))))) -(defun nnweb-replace-in-string (string match newtext) - (while (string-match match string) - (setq string (replace-match newtext t t string))) - string) - (provide 'nnweb) ;;; nnweb.el ends here diff --git a/lisp/nnwfm.el b/lisp/nnwfm.el index ddf072bb1..27d2b72aa 100644 --- a/lisp/nnwfm.el +++ b/lisp/nnwfm.el @@ -233,7 +233,7 @@ (setq description (car (last (nnweb-text (nth 1 row))))) (setq articles (string-to-number - (nnweb-replace-in-string + (gnus-replace-in-string (car (last (nnweb-text (nth 3 row)))) "," ""))) (when (and href (string-match "GroupId=\\([0-9]+\\)" href)) @@ -284,7 +284,7 @@ (while (re-search-forward " wr(" nil t) (forward-char -1) (setq elem (message-tokenize-header - (nnweb-replace-in-string + (gnus-replace-in-string (buffer-substring (1+ (point)) (progn @@ -293,7 +293,7 @@ "\\\\[\"\\\\]" ""))) (push (list (string-to-number (nth 1 elem)) - (nnweb-replace-in-string (nth 2 elem) "\"" "") + (gnus-replace-in-string (nth 2 elem) "\"" "") (string-to-number (nth 5 elem))) forum-contents)) (when (re-search-forward "href=\"\\(Thread.*DateLast=\\([^\"]+\\)\\)"