[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ange-ftp + cperl-mode + replace-string bug
From: |
Stefan Monnier |
Subject: |
Re: ange-ftp + cperl-mode + replace-string bug |
Date: |
12 Jan 2002 15:26:38 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.50 |
>>>>> "Vladimir" == Vladimir Volovich <vvv@vsu.ru> writes:
> "VV" == Vladimir Volovich writes:
VV> This bug is present when i use BOTH ange-ftp and cperl-mode: if i
VV> open a local file via C-x C-f, or if i do not start cperl-mode,
VV> there is no such bug.
> nope -- it appears that the bug is independent of cperl-mode, and
> appears because of ange-ftp hooks which are called when i do a
> replace-string.
That's indeed my suspicion. There's a save-match-data missing somewhere
...
...
...
I've just spent a fair amount of time looking for such missing
save-match-data and it seems like it's a real mess.
Could you retry your experiment after applying the patch below ?
Stefan
PS: It's not the first time a problem shows up because of a file-handler
not properly saving the match data. It often leads to rather nasty
and subtle bugs. Is there any reason why we don't do `save-match-data'
directly inside `ange-ftp-hook-function' once and for all instead
of having those save-match-data sprinkled everywhere (and worse yet:
it's really non-obvious when such a save-match-data is missing) ?
Is there such a thing as a file operation for which it is correct
to modify the match-data ?
--- ange-ftp.el.~1.14.4.1.~ Mon Nov 19 15:25:41 2001
+++ ange-ftp.el Sat Jan 12 15:20:12 2002
@@ -2092,6 +2092,7 @@
;; grab a suitable process.
(setq proc (ange-ftp-start-process host user name))
+ (save-match-data
;; login to FTP server.
(if (and (ange-ftp-use-smart-gateway-p host)
ange-ftp-gateway-host)
@@ -2111,7 +2112,7 @@
proc "passive" "Trying passive mode..." nil))))
(if (string-match "\\?\\|refused" answer)
(message "Trying passive mode...ok")
- (message "Trying passive mode...failed"))))
+ (message "Trying passive mode...failed")))))
;; Run any user-specified hooks. Note that proc, host and user are
;; dynamically bound at this point.
@@ -2211,6 +2212,7 @@
host-type (ange-ftp-host-type host user))
;; This will trigger an FTP login, if one doesn't exist
(eq cmd0 'dir))
+ (save-match-data
(setq cmd1 (funcall
(or (cdr (assq host-type ange-ftp-fix-dir-name-func-alist))
'identity)
@@ -2229,7 +2231,7 @@
;; directory in question and ls ".".
(when (string-match " " cmd1)
(ange-ftp-cd host user (nth 1 cmd))
- (setq cmd1 "."))
+ (setq cmd1 ".")))
;; If the remote ls can take switches, put them in
(or (memq host-type ange-ftp-dumb-host-types)
@@ -3840,7 +3842,8 @@
completions)))
(if (or (and (eq system-type 'windows-nt)
- (string-match "^[a-zA-Z]:[/\\]$" ange-ftp-this-dir))
+ (save-match-data
+ (string-match "^[a-zA-Z]:[/\\]$" ange-ftp-this-dir)))
(string-equal "/" ange-ftp-this-dir))
(nconc (all-completions file (ange-ftp-generate-root-prefixes))
(ange-ftp-real-file-name-all-completions file
@@ -3872,7 +3875,8 @@
(function ange-ftp-file-entry-active-p)))))))
(if (or (and (eq system-type 'windows-nt)
- (string-match "^[a-zA-Z]:[/\\]$" ange-ftp-this-dir))
+ (save-match-data
+ (string-match "^[a-zA-Z]:[/\\]$" ange-ftp-this-dir)))
(string-equal "/" ange-ftp-this-dir))
(try-completion
file
@@ -4317,15 +4321,17 @@
;; So the format conversion should be all that is needed.
(defun ange-ftp-insert-directory (file switches &optional wildcard full)
+ (save-match-data
(let ((short (ange-ftp-abbreviate-filename file))
(parsed (ange-ftp-ftp-name (expand-file-name file))))
(if parsed
(insert
(if wildcard
(let ((default-directory (file-name-directory file)))
- (ange-ftp-ls (file-name-nondirectory file) switches nil nil t))
+ (ange-ftp-ls (file-name-nondirectory file)
+ switches nil nil t))
(ange-ftp-ls file switches full)))
- (ange-ftp-real-insert-directory file switches wildcard full))))
+ (ange-ftp-real-insert-directory file switches wildcard full)))))
(defun ange-ftp-dired-uncache (dir)
(if (ange-ftp-ftp-name (expand-file-name dir))
@@ -4355,6 +4361,10 @@
(ange-ftp-real-shell-command command output-buffer error-buffer)
(if (> (length name) 0) ; else it's $HOME
(setq command (concat "cd " name "; " command)))
+ ;; Remove port from the hostname.
+ (save-match-data
+ (when (string-match "\\(.*\\)#\\(.*\\)" host)
+ (setq host (match-string 1 host))))
(setq command
(format "%s %s \"%s\"" ; remsh -l USER does not work well
; on a hp-ux machine I tried