"A.J.Mechelynck" <[EMAIL PROTECTED]> wrote: > The ps solution is difficult to use, because there may be several instances > of Vim running in parallel (whose prognames might or might not be different) > and I want to make sure to access the "current" instance: so I would have to > know the process ID of the current Vim and I don't know how to do that. > Using system('ls -l /proc/self') wouldn't work, because that would return > the PID of the ls process called by a subshell called by Vim.
libcallnr("/usr/lib/libc.so", "getpid", "") should do the trick on most *nix flavours. >From here, it should be possible to play with /proc related utilities. > Maybe I'found something... or have I? > > (first try omitted, it didn't work) > (second try is better) > (third try:) > > " (try to) detect whether we have clipboard and X > if has('clipboard') > let x = @+ > let @+ = '--' . x > redir @" > silent reg > redir END > let @+ = x > unlet x > let clipboard_present = (@" =~ '^"+ ') > else > let clipboard_present = 0 > endif > let X_available = has('x11') && clipboard_present > > The above would fail in a Vim compiled with X support but without clipboard > support. I think that that risk is negligible. Do you (or does anyone) see > other cases where the above algorithm would fail? It relies on the fact that > when the clipboard is not available (for whatever reason: not compiled-in, > -X, or terminal with no X access) the ":reg" command never lists the "+ > register, not even if we just yanked a nonempty value into it. Just in case it may help, this code returns 0 in every situation (gvim, vim, vim -X) in my config (Solaris custom build) However it seems tied to the fact the "^" prevents '"+' from being matched -- while (@" =~ "\n".'"+ ') is non null. With this new regex, I always end up with 1. -------- >% ---------- VIM - Vi IMproved 7.0 (2006 May 7, compiled Nov 23 2006 16:11:47) Included patches: 1-168 Compiled by luc Normal version with X11-Motif GUI. Features included (+) or not (-): -arabic +autocmd +balloon_eval +browse +builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv -cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path +folding -footer +fork() -gettext -hangul_input -iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse +mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm +mouse_xterm -multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra +perl +postscript +printer -profile -python +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 +xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save [...] Compilation: cc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MOTIF -I/usr/dt/include -g -I/usr/perl5/5.00503/sun4-solaris/CORE Linking: cc -L/usr/dt/lib -R /usr/dt/lib -o vim -lXmu -lXext -lXm -lSM -lICE -lXt -lX11 -ltermlib -R /usr/perl5/5.00503/sun4-solaris/CORE /usr/perl5/5.00503/sun4-sol aris/auto/DynaLoader/DynaLoader.a -L/usr/perl5/5.00503/sun4-solaris/CORE -lperl -lsocket -lnsl -ldl -lm -------- >% ---------- HTH, -- Luc Hermitte