在 2012年11月29日星期四UTC+8上午10时42分23秒,Techlive Zheng写道:
> It seems if "QuitPre" autocommand is used, executing ":quit" twice will not 
> quit vim when the last file in the argument list has not yet been edited. I 
> looked into the source, it seems that 'quitmore' flag somehow be reset to 0 
> again.

I came up with a patch that should fix this problem, but I do not know if it is 
the elegant solution, anyway, I paste it here.

>From 6fa8e662bfc519aa5b8df4a747a34d12e66e6f45 Mon Sep 17 00:00:00 2001
From: Techlive Zheng <[email protected]>
Date: Thu, 29 Nov 2012 12:39:37 +0800
Subject: [PATCH] Fix "QuitPre" autocommand interfering twice ':q' behavior

If the last file in the argument list has not yet been edited, execute ':q'
twice should quit vim anyway, but if "QuitPre" is fired, this behavior
will not function, 'quitmore' flag is reset to 0 again.
---
 src/ex_docmd.c       | 1 +
 src/fileio.c         | 3 +--
 src/proto/fileio.pro | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 311f4f0..479a3cd 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1732,6 +1732,7 @@ do_one_cmd(cmdlinep, sourcing,
 #ifdef FEAT_EVAL
            /* avoid that a function call in 'statusline' does this */
            && !getline_equal(fgetline, cookie, get_func_line)
+           && !getline_equal(fgetline, cookie, getnextac)
 #endif
            )
        --quitmore;
diff --git a/src/fileio.c b/src/fileio.c
index a3113d7..8eecb44 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7774,7 +7774,6 @@ static char_u *find_end_event __ARGS((char_u *arg, int 
have_group));
 static int event_ignored __ARGS((event_T event));
 static int au_get_grouparg __ARGS((char_u **argp));
 static int do_autocmd_event __ARGS((event_T event, char_u *pat, int nested, 
char_u *cmd, int forceit, int group));
-static char_u *getnextac __ARGS((int c, void *cookie, int indent));
 static int apply_autocmds_group __ARGS((event_T event, char_u *fname, char_u 
*fname_io, int force, int group, buf_T *buf, exarg_T *eap));
 static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
 
@@ -9613,7 +9612,7 @@ auto_next_pat(apc, stop_at_last)
  * Called by do_cmdline() to get the next line for ":if".
  * Returns allocated string, or NULL for end of autocommands.
  */
-    static char_u *
+char_u *
 getnextac(c, cookie, indent)
     int            c UNUSED;
     void    *cookie;
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
index baf6216..e716b7d 100644
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -58,4 +58,5 @@ int match_file_list __ARGS((char_u *list, char_u *sfname, 
char_u *ffname));
 char_u *file_pat_to_reg_pat __ARGS((char_u *pat, char_u *pat_end, char 
*allow_dirs, int no_bslash));
 long read_eintr __ARGS((int fd, void *buf, size_t bufsize));
 long write_eintr __ARGS((int fd, void *buf, size_t bufsize));
+char_u *getnextac __ARGS((int c, void *cookie, int indent));
 /* vim: set ft=c : */
-- 
1.7.12.2

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui