-;; We currently (sometimes) use "[" and "]" in the filename format.
-;; This means that Emacs wants to expand wildcards if
-;; `find-file-wildcards' is non-nil, and then barfs because no
-;; expansion could be found. We detect this situation and do
-;; something really awful: we have `file-expand-wildcards' return the
-;; original filename if it can't expand anything. Let's just hope
-;; that this doesn't break anything else.
-;; CCC: This check is now also really awful; we should search all
-;; of the filename format, not just the prefix.
-(when (string-match "\\[" tramp-prefix-format)
- (defadvice file-expand-wildcards
- (around tramp-advice-file-expand-wildcards activate)
- (let ((name (ad-get-arg 0)))
- (if (tramp-tramp-file-p name)
- ;; If it's a Tramp file, dissect it and look if wildcards
- ;; need to be expanded at all.
- (if (string-match
- "[[*?]"
- (tramp-file-name-localname (tramp-dissect-file-name name)))
- (setq ad-return-value (or ad-do-it (list name)))
- (setq ad-return-value (list name)))
- ;; If it is not a Tramp file, just run the original function.
- (setq ad-return-value (or ad-do-it (list name))))))
- (add-hook 'tramp-unload-hook
- (lambda () (ad-unadvise 'file-expand-wildcards))))
-