Previous: , Up: 変数   [Contents][Index]


51.2.6 接続ごとのローカル変数

ほとんどの変数はローカルマシンの状況を反映します。リモートのデフォルトディレクトリーをもつバッファー操作時には、それらの変数が異なる値を使用しなければならないときが時折あります。shellを呼び出す際の挙動について考えてみましょう。ローカルのマシンでは/bin/bashを使用してtermcapを用いるかもしれませんが、リモートのマシンでは/bin/kshとterminfoかもしれないのです。

これは接続ローカル変数(connection-local variables)で実現することができます。ディレクトリーローカル変数とファイルローカル変数は接続ローカル変数をオーバーライドします。安全ではない接続ローカル値は、安全でないファイルローカル値と同じ方法で扱われます(安全なファイル変数を参照してください)。

接続ローカル変数はconnection-local-set-profile-variables関数を使用して変数/値ペアのグループとしてプロファイル(profile)内に宣言されます。関数connection-local-set-profilesはリモートマシンを識別する与えられた条件にたいしてプロファイルをアクティブにします。

(connection-local-set-profile-variables 'remote-terminfo
   '((system-uses-terminfo . t)
     (comint-terminfo-terminal . "dumb-emacs-ansi")))

(connection-local-set-profile-variables 'remote-ksh
   '((shell-file-name . "/bin/ksh")
     (shell-command-switch . "-c")))

(connection-local-set-profile-variables 'remote-bash
   '((shell-file-name . "/bin/bash")
     (shell-command-switch . "-c")))

(connection-local-set-profiles
   '(:application tramp :machine "remotemachine")
   'remote-terminfo 'remote-ksh)

このコードではremote-terminforemote-kshそしてremote-bashという3つの異なるプロファイルを宣言しています。プロファイルremote-terminforemote-kshは、ホスト名がregexpの"remotemachine"にマッチするリモートのデフォルトディレクトリーをもつすべてのバッファーに適用されます。このような条件はプロパティ:protocol (Trampの手法)や:user (リモートユーザー名)も区別できます。nilという条件はリモートデフォルトディレクトリーをもつすべてのバッファーにマッチします。

Be careful when declaring different profiles with the same variable, and setting these profiles to criteria which could match in parallel. It is unspecified which variable value is used then.

This page has generated for branch:master, commit:762705fb24fd90db318f2e51c1e762452d26f7e2 to check Japanese translation.