Cameron Simpson wrote:
On 13Mar2007 23:29, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
| How can a Vim script know if we're running without an X connection?
| Of course, some cases are obvious, such as
|       if has('unix') && !has('x11')
| meaning we're on Unix with no X11 support compiled-in.
| | But what about an X-enabled Vim running in console mode, either with the -X | command-line switch, or in a terminal with no access to an X server?

Examine the $DISPLAY environment variable. If non-empty, you have a X11
display.

$DISPLAY means Vim was started from a shell running within X11. It doesn't mean Vim is aware of that X11 server. In particular, if Vim was started as "vim -X" in an xterm, $DISPLAY will be nonempty but attempts to read or write the clipboard or to use the +clientserver feature (both of which rely on X functions other than reading the keyboard or wtiting to the display) wouldn't work, even if they don't give an error (for instance, in that case reading @+ or writing to it gives no error, but the keyboard is neither read nor written).

For more clarification, please read the _whole_ of my previous post.


Best regards,
Tony.

Reply via email to