emacs-devel
[Top][All Lists]
Advanced

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

Re: ange-ftp + cperl-mode + replace-string bug


From: Vladimir Volovich
Subject: Re: ange-ftp + cperl-mode + replace-string bug
Date: Sun, 13 Jan 2002 15:06:11 +0300
User-agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.1 (sparc-sun-solaris2.8)

"RS" == Richard Stallman writes:

 VV> ange-ftp runs some hooks which perform regexp matching on the
 VV> opened file name, and it looks like these matches do confuse the
 VV> matcher in replace-string.

 RS> (Do you mean replace-match?  I think so.)

 RS> It looks like you have tracked this down more than half way.  If
 RS> you can find the calls to replace-match which get confused, I
 RS> could probably fix the problem.

[see below why i thing that the fix should be applied to ange-ftp
instead of to replace.el]

 RS> If you add (debug) to these hooks so you can get a backtrace,
 RS> that backtrace could help you find the replace-match calls.

i think that all calls to replace-match inside perform-replace (from
replace.el) are affected: e.g. here are some backtraces:

1) when replace-match is called from perform-replace,
   ange-ftp-hook-function is automatically called:

Debugger entered--entering a function:
* ange-ftp-hook-function(expand-file-name 
"/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil)
* replace-match("2002-01" nil t)
* perform-replace("2001-12" "2002-01" nil nil nil nil nil)
* byte-code("..." [from-string to-string start end delimited perform-replace 
nil] 8)
* replace-string("2001-12" "2002-01" nil nil nil)
  call-interactively(replace-string)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

2) that function itself performs some matching:

Debugger entered--entering a function:
* match-data()
* ange-ftp-expand-file-name("/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil)
* apply(ange-ftp-expand-file-name 
("/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil))
* ange-ftp-hook-function(expand-file-name 
"/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil)
* replace-match("2002-01" nil t)
* perform-replace("2001-12" "2002-01" nil nil nil nil nil)
* byte-code("..." [from-string to-string start end delimited perform-replace 
nil] 8)
* replace-string("2001-12" "2002-01" nil nil nil)
  call-interactively(replace-string)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

Debugger entered--entering a function:
* string-match("[^:]+//" "/address@hidden:/www/prs/cgi-bin/prs/bug.cgi")
* ange-ftp-canonize-filename("/address@hidden:/www/prs/cgi-bin/prs/bug.cgi")
* ange-ftp-expand-file-name("/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil)
* apply(ange-ftp-expand-file-name 
("/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil))
* ange-ftp-hook-function(expand-file-name 
"/address@hidden:/www/prs/cgi-bin/prs/bug.cgi" nil)
* replace-match("2002-01" nil t)
* perform-replace("2001-12" "2002-01" nil nil nil nil nil)
* byte-code("..." [from-string to-string start end delimited perform-replace 
nil] 8)
* replace-string("2001-12" "2002-01" nil nil nil)
  call-interactively(replace-string)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

so:

* replace-string calls perform-replace

* perform-replace calls search-forward and match-data, and then
  replace-match

* when replace-match is going to do the first real change in the
  buffer, the ange-ftp-hook-function is called which itself calls
  match-data and string-match, and this effectively breaks the
  match-data call from perform-replace

I think that the fix should be applied to ange-ftp, to not break the
(possibly already existing) matched string.

if the fix is applied to replace.el, then there could be other similar
bugs floating around (also, manually-called replace-match will be
broken too).

Best,
v.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]