RE: Inability to map C-N when completion popup is visible

2006-06-16 Thread David Fishburn
 

 -Original Message-
 From: Hari Krishna Dara [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 15, 2006 8:23 PM
 To: vim@vim.org
 Subject: Inability to map C-N when completion popup is visible
 
 
 I am trying to map C-N and C-P to behave differently when
 pumvisible() returns true, but Vim seems to completely ignore this.
 E.g., if I create this unconditional map (a much simpler one 
 than what I
 wanted):
 
 inoremap C-N C-C
 
 pressing ^N normally stops insertmode, but when popup is 
 visible, Vim never executes the map. This may be true for 
 C-P also, but the same is not true for, say Up.
 
 inoremap Up C-C
 
 Using the above map, pressing Up arrow always stops insert 
 mode, whether popup is visible or not. Is this a bug? I 
 tested by starting with -u NONE option to avoid any other 
 interferences.

I had a lot of problems trying to get this to work as well.

In the end I was unable to map it without making a function call.

autoload/sqlcomplete.vim does the following:

if has('win32')
imap buffer c-right C-R=sqlcomplete#DrillIntoTable()CR
imap buffer c-left  C-R=sqlcomplete#DrillOutOfColumns()CR
endif

function! sqlcomplete#DrillIntoTable()
 If the omni popup window is visible
if pumvisible()
call sqlcomplete#Map('column')
 C-Y, makes the currently highlighted entry active
 and trigger the omni popup to be redisplayed
call feedkeys(\C-Y\C-X\C-O)
else
if has('win32')
 If the popup is not visible, simple perform the normal
 C-Right behaviour
exec normal! \C-Right
endif
endif
return 
endfunction

In this case, if the popup window is not visible I want to perform the
standard C-Right so the user does not loose any functionality due to the
mapping.

For the lurkers, this is for Vim7 since pumvisible() and feedkeys() are Vim7
functions.

HTH,
Dave



RE: Inability to map C-N when completion popup is visible

2006-06-16 Thread Hari Krishna Dara

On Fri, 16 Jun 2006 at 8:25am, David Fishburn wrote:



  -Original Message-
  From: Hari Krishna Dara [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 15, 2006 8:23 PM
  To: vim@vim.org
  Subject: Inability to map C-N when completion popup is visible
 
 
  I am trying to map C-N and C-P to behave differently when
  pumvisible() returns true, but Vim seems to completely ignore this.
  E.g., if I create this unconditional map (a much simpler one
  than what I
  wanted):
 
  inoremap C-N C-C
 
  pressing ^N normally stops insertmode, but when popup is
  visible, Vim never executes the map. This may be true for
  C-P also, but the same is not true for, say Up.
 
  inoremap Up C-C
 
  Using the above map, pressing Up arrow always stops insert
  mode, whether popup is visible or not. Is this a bug? I
  tested by starting with -u NONE option to avoid any other
  interferences.

 I had a lot of problems trying to get this to work as well.

 In the end I was unable to map it without making a function call.

 autoload/sqlcomplete.vim does the following:

 if has('win32')
   imap buffer c-right C-R=sqlcomplete#DrillIntoTable()CR
   imap buffer c-left  C-R=sqlcomplete#DrillOutOfColumns()CR
 endif

 function! sqlcomplete#DrillIntoTable()
  If the omni popup window is visible
 if pumvisible()
 call sqlcomplete#Map('column')
  C-Y, makes the currently highlighted entry active
  and trigger the omni popup to be redisplayed
 call feedkeys(\C-Y\C-X\C-O)
 else
 if has('win32')
  If the popup is not visible, simple perform the normal
  C-Right behaviour
 exec normal! \C-Right
 endif
 endif
 return 
 endfunction

 In this case, if the popup window is not visible I want to perform the
 standard C-Right so the user does not loose any functionality due to the
 mapping.

 For the lurkers, this is for Vim7 since pumvisible() and feedkeys() are Vim7
 functions.

 HTH,
 Dave

I give up. The procedure you came up with works for other keys but not
for C-N (and possibly C-P as well). The function doesn't even get
called when completion popup is visible. Even for other keys where the
function gets called, I made several attempts to do what I want and none
worked properly. What I want is to remap Down to C-N (which is no
problem) but to also move the cursor to the end of the line before doing
C-N. I had two mixed results. In the first result, I am able to move
the cursor to the end, but C-N will then be treated as a trigger for
fresh insert mode completion (and I am not using a 'completefunc' to set
matches, so my completions get overwritten by what Vim generates by
default). In the second result, C-N works, but the cursor is not moved
to the end of the line. I tried to use all kinds of tricks mixing
the use of feedkeys(), inputsave/restore() and others. Something is very
fishy about C-N, when it is anywhere in the map (LHS or RHS),
everything else gets ignored.

-- 
Thanks,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


RE: Inability to map C-N when completion popup is visible

2006-06-16 Thread Hari Krishna Dara

On Fri, 16 Jun 2006 at 11:25am, Max Dyckhoff wrote:

  I give up. The procedure you came up with works for other keys but not
  for C-N (and possibly C-P as well). The function doesn't even get
  called when completion popup is visible. Even for other keys where the
  function gets called, I made several attempts to do what I want and
 none
  worked properly. What I want is to remap Down to C-N (which is no
  problem) but to also move the cursor to the end of the line before
 doing
  C-N. I had two mixed results. In the first result, I am able to move
  the cursor to the end, but C-N will then be treated as a trigger for
  fresh insert mode completion (and I am not using a 'completefunc' to
 set
  matches, so my completions get overwritten by what Vim generates by
  default). In the second result, C-N works, but the cursor is not
 moved
  to the end of the line. I tried to use all kinds of tricks mixing
  the use of feedkeys(), inputsave/restore() and others. Something is
 very
  fishy about C-N, when it is anywhere in the map (LHS or RHS),
  everything else gets ignored.

 There is a high probability that I am being dense, but it actually seems
 to work for me now. Here is what I'm doing.

 :imap C-N C-R=Wibble()CR

 function! Wibble()
   if pumvisible()
   return visible
   else
   return unvisible
   endif
 endf

 I type the beginning of a tag (actor_) and press C-P to open up the
 popup menu. Vim enters the first match (actor_get), and I then press
 C-N, and it changes the string to actor_getvisible.

 In normal insert mode pressing C-N just enters unvisible.

 Either I am misunderstanding the problem, or maybe I'm just special? Let
 me know if you need any more details of my setup.

 Max



Strange... this works for me as well when I am not in my plugin window,
but when the cursor is in the plugin window, it gets completely ignored
(the breakpoint doesn't even get called, no buffer mapping for C-N to
hide this, I checked). This beats me, but I think this is because of the
way I am setting completion items. Instead of using the traditional
'completefunc' or 'omnifunc' approach (which involves invoking a
keysequence), I am using the CursorMovedI event to set completions as
soon as user types something (this is because, the whole purpose of the
plugin is to show matches, so there is no point asking the user to press
C-XC-U or any other key). Looks like I need to look deeper into the
problem. Thanks to all.

-- 
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com