Previous: Localname deconstruction, Up: Files directories and localnames

8.2 Integration with external Lisp packages

8.2.1 Filename completion.

While reading filenames in the minibuffer, tramp must decide whether it completes possible incomplete filenames, or not. Imagine there is the following situation: You have typed C-x C-f /ssh: <TAB>. tramp cannot know, whether ssh is a method or a host name. It checks therefore the last input character you have typed. If this is <TAB>, <SPACE> or ?, tramp assumes that you are still in filename completion, and it does not connect to the possible remote host ssh.

External packages, which use other characters for completing filenames in the minibuffer, must signal this to tramp. For this case, the variable tramp-completion-mode can be bound temporarily to a non-nil value.

     (let ((tramp-completion-mode t))

8.2.2 File attributes cache.

When tramp runs remote processes, files on the remote host could change their attributes. Consequently, tramp must flush its complete cache keeping attributes for all files of the remote host it has seen so far.

This is a performance degradation, because the lost file attributes must be recomputed when needed again. In cases the caller of process-file knows that there are no file attribute changes, it shall let-bind the variable process-file-side-effects to nil. tramp wouldn't flush the file attributes cache then.

     (let (process-file-side-effects)

For asynchronous processes, tramp flushes the file attributes cache via a process sentinel. If the caller of start-file-process knows that there are no file attribute changes, it shall set the process sentinel to nil. In case the caller defines an own process sentinel, tramp's process sentinel is overwritten. The caller can still flush the file attributes cache in its process sentinel with this code:

     (unless (memq (process-status proc) '(run open))
       (dired-uncache remote-directory))

remote-directory shall be the root directory, where file attribute changes can happen during the process lifetime. tramp traverses all subdirectories, starting at this directory. Often, it is sufficient to use default-directory of the process buffer as root directory.