src/nvim/fileio.c
// Find next autocommand pattern that matches.
Find next autocommand pattern that matches.
Find next autocommand pattern that matches .
static void
auto_next_pat(
    AutoPatCmd *apc,
    int stop_at_last                   
)
{
  AutoPat     *ap;
  AutoCmd     *cp;
  char        *s;
  XFREE_CLEAR(sourcing_name);
  for (ap = apc->curpat; ap != NULL && !got_int; ap = ap->next) {
    apc->curpat = NULL;
    if (ap->pat != NULL && ap->cmds != NULL
        && (apc->group == AUGROUP_ALL || apc->group == ap->group)) {
      if (ap->buflocal_nr == 0
          ? match_file_pat(NULL, &ap->reg_prog, apc->fname, apc->sfname,
                           apc->tail, ap->allow_dirs)
          : ap->buflocal_nr == apc->arg_bufnr) {
        const char *const name = event_nr2name(apc->event);
        s = _("%s Autocommands for \"%s\"");
        const size_t sourcing_name_len = (STRLEN(s) + strlen(name) + ap->patlen
                                          + 1);
        sourcing_name = xmalloc(sourcing_name_len);
        snprintf((char *)sourcing_name, sourcing_name_len, s, name,
                 (char *)ap->pat);
        if (p_verbose >= 8) {
          verbose_enter();
          smsg(_("Executing %s"), sourcing_name);
          verbose_leave();
        }
        apc->curpat = ap;
        apc->nextcmd = ap->cmds;
        for (cp = ap->cmds; cp->next != NULL; cp = cp->next)
          cp->last = FALSE;
        cp->last = TRUE;
      }
      line_breakcheck();
      if (apc->curpat != NULL)              
        break;
    }
    if (stop_at_last && ap->last)
      break;
  }
}
static void auto_next_pat ( AutoPatCmd * apc , int stop_at_last ) { AutoPat * ap ; AutoCmd * cp ; char * s ; XFREE_CLEAR ( sourcing_name ) ; for ( ap = apc -> curpat ; ap != NULL && ! got_int ; ap = ap -> next ) { apc -> curpat = NULL ; if ( ap -> pat != NULL && ap -> cmds != NULL && ( apc -> group == AUGROUP_ALL || apc -> group == ap -> group ) ) { if ( ap -> buflocal_nr == 0 ? match_file_pat ( NULL , & ap -> reg_prog , apc -> fname , apc -> sfname , apc -> tail , ap -> allow_dirs ) : ap -> buflocal_nr == apc -> arg_bufnr ) { const char * const name = event_nr2name ( apc -> event ) ; s = _ ( " \" \" " ) ; const size_t sourcing_name_len = ( STRLEN ( s ) + strlen ( name ) + ap -> patlen + 1 ) ; sourcing_name = xmalloc ( sourcing_name_len ) ; snprintf ( ( char * ) sourcing_name , sourcing_name_len , s , name , ( char * ) ap -> pat ) ; if ( p_verbose >= 8 ) { verbose_enter ( ) ; smsg ( _ ( " " ) , sourcing_name ) ; verbose_leave ( ) ; } apc -> curpat = ap ; apc -> nextcmd = ap -> cmds ; for ( cp = ap -> cmds ; cp -> next != NULL ; cp = cp -> next ) cp -> last = FALSE ; cp -> last = TRUE ; } line_breakcheck ( ) ; if ( apc -> curpat != NULL ) break ; } if ( stop_at_last && ap -> last ) break ; } }
Find next autocommand pattern that matches.
Find next autocommand pattern that matches .
/* stop when 'last' flag is set */ /* Only use a pattern when it has not been removed, has commands and
     * the group matches. For buffer-local autocommands only check the
     * buffer number. */ /* execution-condition */ /* mark last command */ /* found a match */