Received: from luna.worldonline.nl (luna.worldonline.nl [195.241.48.131]) by larissa.worldonline.nl (8.8.5/8.8.5) with ESMTP id AAA27161 for ; Tue, 6 Jul 1999 00:45:07 +0200 (MET DST) Received: from ulwar.pair.com (ulwar.pair.com [209.68.1.173]) by luna.worldonline.nl (8.8.5/8.8.5) with ESMTP id AAA02253 for ; Tue, 6 Jul 1999 00:37:26 +0200 (MET DST) Received: from foobar.math.fu-berlin.de (foobar.math.fu-berlin.de [160.45.45.151]) by ulwar.pair.com (8.9.1/8.6.12) with SMTP id SAA19696 for ; Mon, 5 Jul 1999 18:37:18 -0400 (EDT) X-Envelope-To: Received: (qmail 11546 invoked by uid 200); 5 Jul 1999 22:37:37 -0000 Mailing-List: contact vim-dev-help@vim.org; run by ezmlm Precedence: bulk Delivered-To: mailing list vim-dev@vim.org Received: (qmail 11515 invoked from network); 5 Jul 1999 22:37:36 -0000 Message-Id: <199907052245.AAA07812@moolenaar.net> To: Johannes Zellner Cc: vim development Subject: patch 5.4n.5 (was: CursorHold & normal) In-Reply-To: From: Bram Moolenaar Date: Tue, 06 Jul 1999 00:45:42 +0200 Sender: Bram@moolenaar.net Content-type: text Status: U Johannes Zellner wrote: > autocmd! CursorHold * normal j > > and vim will hang, at least untill you type an error. Just a note. > As I had my fingers in CursorHold I might take a look into this evening. Interesting problem. The CursorHold event is triggered while waiting for a character, somewhere down from vgetc(). It then executes the ":normal" command, which puts "j" in the input buffer and calls normal_cmd() to execute it. normal_cmd() then calls vgetc() to get the command character, but since vgetc() can't work recursively, this is redirected to get_keystroke(). Thus the "j" in the input buffer is never consumed... This is too tricky to fix now. This would probably require returning a Cursor-hold key code from the input function and handling it at a higher level. I don't want to do that now. Let's just forbid the use of ":normal" here. The real solution can be done later (hopefully in a generic way, event handling has become a bit messy...). Patch 5.4n.5 Problem: When using ":normal" from a CursorHold autocommand Vim hangs. The autocommand is executed down from vgetc(). Calling vgetc() recursively to execute the command doesn't work then. Solution: Forbid the use of ":normal" when vgetc_busy is set. Give an error message when this happens. Files: src/ex_docmd.c, runtime/doc/autocmd.txt *** ../vim-5.4n/src/ex_docmd.c Sun Jul 4 20:35:46 1999 --- src/ex_docmd.c Mon Jul 5 22:11:18 1999 *************** *** 6961,6966 **** --- 6961,6973 ---- EMSG("Recursive use of :normal too deep"); return; } + /* Using ":normal" from a CursorHold autocommand event doesn't work, + * because vgetc() can't be used recursively. */ + if (vgetc_busy) + { + EMSG("Cannot use :normal from event handler"); + return; + } ++depth; msg_scroll = FALSE; /* no msg scrolling in Normal mode */ restart_edit = 0; /* don't go to Insert mode */ *** ../vim-5.4n/runtime/doc/autocmd.txt Sun Jul 4 20:36:25 1999 --- runtime/doc/autocmd.txt Mon Jul 5 22:14:42 1999 *************** *** 1,4 **** ! *autocmd.txt* For Vim version 5.4n. Last change: 1999 Jul 03 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *autocmd.txt* For Vim version 5.4n. Last change: 1999 Jul 05 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 257,266 **** until the user has pressed a key (i.e. doesn't fire every 'updatetime' ms if you leave Vim to make some coffee. :) See |CursorHold-example| ! for previewing tags. Note: In the future ! there will probably be another option to set ! the time. {only on Amiga, Unix, Win32, MSDOS ! and all GUI versions} *BufEnter* BufEnter After entering a buffer. Useful for setting options for a file type. Also executed when --- 257,269 ---- until the user has pressed a key (i.e. doesn't fire every 'updatetime' ms if you leave Vim to make some coffee. :) See |CursorHold-example| ! for previewing tags. ! Note: Interactive commands and ":normal" ! cannot be used for this event. ! Note: In the future there will probably be ! another option to set the time. ! {only on Amiga, Unix, Win32, MSDOS and all GUI ! versions} *BufEnter* BufEnter After entering a buffer. Useful for setting options for a file type. Also executed when -- Lose weight, NEVER Diet again with The "Invisible Weight Loss Patch" (spam e-mail) --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / / .