Emacs: disable Ido completion in Tramp mode
Asked Answered
G

1

12

I often use ido for auto-completion and tramp to access remote server via ssh. My .emacs includes the following lines:

(require 'tramp)
(setq tramp-default-method "ssh")
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)

I want to disable Ido completion, when i'm browsing contents of remote server. Note that variable ido-enable-tramp-completion has nothing to do with my problem. Consider line /[email protected]#1234:/var/www/file.txt. I need Ido not to deduct the part after the colon (remote file path), i don't care about the part before the colon. I use ssh, and Ido makes Emacs lag for a few seconds every time i run ido-find-file, and when ssh timeout is over, Tramp tries to reconnect, asks me for a password and so on. This behavior is undesirable.

Emacs version - 24.0.94.1

Edit (20.03.12): After contact with Ido author I tried to change the ido-file-name-all-completions-1 to the following:

(defun ido-file-name-all-completions-1 (dir)
  (cond
   ((ido-nonreadable-directory-p dir) '())
   ;; do not check (ido-directory-too-big-p dir) here.
   ;; Caller must have done that if necessary.

   ((and ido-enable-tramp-completion
     (or (fboundp 'tramp-completion-mode-p)
         (require 'tramp nil t))
     (string-match "\\`/[^/]+[:@]\\'" dir))
    ;; TRAMP RELATED CODE DELETED
    nil)
   (t
    (file-name-all-completions "" dir))))

No success. I then changed regex to

"\\`/[^/]+[:@]"

and it worked - Ido was disabled, when minibuffer contained that match. However as Ido couldn't see files on a remote server, it started calling ido-make-merged-file-list to search for files in other directories every time i enter something. This made working with Ido on remote servers even more pain.

I also tried setting up variables ido-slow-ftp-hosts and ido-slow-ftp-host-regexps to /[email protected]#1234, didn't help.

Gomar answered 12/3, 2012 at 10:18 Comment(1)
This question seems related to this other question.Hothouse
G
12

If you enter C-x C-f again you temporally disable ido-find and fall back to the default find-file.

For more information C-h f ido-find-file RET

To do this every time ido found a colon, I guess you have to write your own function for that.

Gait answered 13/3, 2012 at 9:56 Comment(5)
If i do ido-find-file twice, then this error is thrown in *Backtrace* buffer - Debugger entered--Lisp error: (error "Command attempted to use minibuffer while in minibuffer")Debugger entered--Lisp error: (error "Command attempted to use minibuffer while in minibuffer"). And where should i write this function?Gomar
You can't run ido-find-file twice. The C-x C-f command will not lunch the ido-find-file, it just fall back to find-file. Do not type M-x ido-find-file RET again. Type C-x C-f.Gait
I see. Where should i write a function for ido seeing a colon?Gomar
For this case I don't think there is a hook. I suggest that you rewrote your own find-file method and copy most of the behavior of ido-find-file except when you see colon.Gait
two years after and I find this post helpful!Maricruzmaridel

© 2022 - 2024 — McMap. All rights reserved.