[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: ftp での download



From: Mitsugu SAKAMOTO <mitsugu@argv.org>
Subject: [emacs-w3m:03436] Re: ftp での download
Date: Tue, 28 May 2002 00:54:54 +0900 (JST)

安宅です。

> > どうも env コマンドが見付けられなくて
> > エラーになっているようです。

> (defvar wget-env-command "c:/cygwin/bin/env"
-snip- 
> して byte-compile しなおしたのですが、なんかだめです。ただし、今度は殻の
> *wget* buffer はできていました。
> 
backtrace を見ると、env コマンドは正常に呼ばれたようです。
設定は間違っていなかったという事ですね。

backtrace は
  Signaling: (void-function replace-regexp-in-string)
と言っています。
この関数は Emacs-20.7 ではまだ無いようです。
NEWS を見てみたら Emacs-21.1 での新設関数とのこと。

次の関数を評価して、もう一度やってみてくれませんか。
(私の使ってる Emacs-21.3.50 にくっついてたやつです)


(defun replace-regexp-in-string (regexp rep string &optional
					fixedcase literal subexp start)
  "Replace all matches for REGEXP with REP in STRING.

Return a new string containing the replacements.

Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
arguments with the same names of function `replace-match'.  If START
is non-nil, start replacements at that index in STRING.

REP is either a string used as the NEWTEXT arg of `replace-match' or a
function.  If it is a function it is applied to each match to generate
the replacement passed to `replace-match'; the match-data at this
point are such that match 0 is the function's argument.

To replace only the first match (if any), make REGEXP match up to \\'
and replace a sub-expression, e.g.
  (replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo foo\" nil nil 1)
    => \" bar foo\"
"

  ;; To avoid excessive consing from multiple matches in long strings,
  ;; don't just call `replace-match' continually.  Walk down the
  ;; string looking for matches of REGEXP and building up a (reversed)
  ;; list MATCHES.  This comprises segments of STRING which weren't
  ;; matched interspersed with replacements for segments that were.
  ;; [For a `large' number of replacements it's more efficient to
  ;; operate in a temporary buffer; we can't tell from the function's
  ;; args whether to choose the buffer-based implementation, though it
  ;; might be reasonable to do so for long enough STRING.]
  (let ((l (length string))
	(start (or start 0))
	matches str mb me)
    (save-match-data
      (while (and (< start l) (string-match regexp string start))
	(setq mb (match-beginning 0)
	      me (match-end 0))
	;; If we matched the empty string, make sure we advance by one char
	(when (= me mb) (setq me (min l (1+ mb))))
	;; Generate a replacement for the matched substring.
	;; Operate only on the substring to minimize string consing.
	;; Set up match data for the substring for replacement;
	;; presumably this is likely to be faster than munging the
	;; match data directly in Lisp.
	(string-match regexp (setq str (substring string mb me)))
	(setq matches
	      (cons (replace-match (if (stringp rep)
				       rep
				     (funcall rep (match-string 0 str)))
				   fixedcase literal str subexp)
		    (cons (substring string start mb) ; unmatched prefix
			  matches)))
	(setq start me))
      ;; Reconstruct a string from the pieces.
      (setq matches (cons (substring string start l) matches)) ; leftover
      (apply #'concat (nreverse matches)))))

もしかしたら、この他にも Emacs-20.7 には未知の関数を
使っているかもしれないなぁ。

# ああ、手元に Emacs-20 系が無い。
# 何で大学の Emacs は 19.34 (Mule-2.3) なんだ。

                                    ----Input with T-Code!
           http://isweb22.infoseek.co.jp/computer/pop-club
     Masayuki Ataka / 安宅 正之 (ataka@milk.freemail.ne.jp)