Eli Zaretskii <[EMAIL PROTECTED]> writes:
> I think it will be very bad if Emacs 22.1 will not support
> autocompletion on Windows, because autocompletion is such a
> fundamental Emacs feature.
>
> What do you need to understand to fix this? It should be fairly easy
> to get this right, as Emacs should already have the necessary
> infrastructure in place (we deal with such problems in quite a few
> places already, I think).
The appended patch shows how autocompletion could work for remote file
names. It removes the drive letter from file names to be completed,
because this prevents activation of Tramp file name handlers for
file-name-all-completions in read-file-name-internal.
But the disadvantage is, that file name completion fails if you are on
another drive than the one Emacs is installed. Assume that Emacs is
located at "C:/Program Files/Emacs". Your default directory be
"U:/". When you type "C-x f /p <TAB>", you get offered "/plink:" and
"/Program Files/". The second offer is wrong.
Best regards, Michael.
*** /home/albinus/src/emacs/lisp/net/tramp.el.~1.100.~ Mon Jul 17 22:40:00 2006
--- /home/albinus/src/emacs/lisp/net/tramp.el Tue Aug 22 07:41:49 2006
***************
*** 1928,1934 ****
;; Handlers for partial tramp file names. For Emacs just
;; `file-name-all-completions' is needed.
;;;###autoload
! (defconst tramp-completion-file-name-handler-alist
'((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
(file-name-completion . tramp-completion-handle-file-name-completion))
"Alist of completion handler functions.
--- 1928,1934 ----
;; Handlers for partial tramp file names. For Emacs just
;; `file-name-all-completions' is needed.
;;;###autoload
! (defvar tramp-completion-file-name-handler-alist
'((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
(file-name-completion . tramp-completion-handle-file-name-completion))
"Alist of completion handler functions.
***************
*** 1936,1941 ****
--- 1936,1945 ----
mentioned here will be handled by `tramp-file-name-handler-alist' or the
normal Emacs functions.")
+ (when (memq system-type '(windows-nt))
+ (add-to-list 'tramp-completion-file-name-handler-alist
+ '(expand-file-name . tramp-completion-handle-expand-file-name)))
+
;; Handlers for foreign methods, like FTP or SMB, shall be plugged here.
(defvar tramp-foreign-file-name-handler-alist
;; (identity . tramp-sh-file-name-handler) should always be the last
***************
*** 4477,4482 ****
--- 4481,4493 ----
last-input-event) ?\ ))))))
t)))
+ (defun tramp-completion-handle-expand-file-name (name &optional dir)
+ "Like `expand-file-name' for tramp files."
+ (let ((fullname (concat (or dir default-directory) name)))
+ (funcall
+ (if (tramp-completion-mode fullname) 'tramp-drop-volume-letter 'identity)
+ (tramp-completion-run-real-handler 'expand-file-name (list name dir)))))
+
;; Method, host name and user name completion.
;; `tramp-completion-dissect-file-name' returns a list of
;; tramp-file-name structures. For all of them we return possible completions.