Function: gnus-uu-expand-numbers

gnus-uu-expand-numbers is a byte-compiled function defined in gnus-uu.el.gz.

Signature

(gnus-uu-expand-numbers STRING-LIST &optional TRANSLATE)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-uu.el.gz
(defun gnus-uu-expand-numbers (string-list &optional translate)
  ;; Takes a list of strings and "expands" all numbers in all the
  ;; strings.  That is, this function makes all numbers equal length by
  ;; prepending lots of zeroes before each number.  This is to ease later
  ;; sorting to find out what sequence the articles are supposed to be
  ;; decoded in.  Returns the list of expanded strings.
  (let ((out-list string-list)
	string)
    (with-current-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name)
      (buffer-disable-undo)
      (while string-list
	(erase-buffer)
	(insert (caar string-list))
	;; Translate multiple spaces to one space.
	(goto-char (point-min))
	(while (re-search-forward "[ \t]+" nil t)
	  (replace-match " "))
	;; Translate all characters to "a".
	(goto-char (point-min))
	(when translate
	  (while (re-search-forward "[A-Za-z]" nil t)
	    (replace-match "a" t t)))
	;; Expand numbers.
	(goto-char (point-min))
	(while (re-search-forward "[0-9]+" nil t)
	  (ignore-errors
	    (replace-match
	     (format "%06d"
		     (string-to-number (buffer-substring
				     (match-beginning 0) (match-end 0)))))))
	(setq string (buffer-substring (point-min) (point-max)))
	(setcar (car string-list) string)
	(setq string-list (cdr string-list))))
    out-list))