• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neomutt / neomutt / 22560814615

02 Mar 2026 03:07AM UTC coverage: 42.368% (-0.1%) from 42.484%
22560814615

push

github

flatcap
sort MenuDefs

0 of 7 new or added lines in 1 file covered. (0.0%)

2173 existing lines in 26 files now uncovered.

12014 of 28356 relevant lines covered (42.37%)

2760.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pattern/complete.c
1
/**
2
 * @file
3
 * Pattern Auto-Completion
4
 *
5
 * @authors
6
 * Copyright (C) 2023 Richard Russon <rich@flatcap.org>
7
 *
8
 * @copyright
9
 * This program is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License as published by the Free Software
11
 * Foundation, either version 2 of the License, or (at your option) any later
12
 * version.
13
 *
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU General Public License along with
20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22

23
/**
24
 * @page pattern_complete Pattern Auto-Completion
25
 *
26
 * Pattern Auto-Completion
27
 */
28

29
#include "config.h"
30
#include <stdbool.h>
31
#include <stddef.h>
32
#include "mutt/lib.h"
33
#include "core/lib.h"
34
#include "gui/lib.h"
35
#include "lib.h"
36
#include "complete/lib.h"
37
#include "editor/lib.h"
38

39
/**
40
 * is_pattern_prefix - Check if a character is a pattern prefix
41
 * @param c Character to check
42
 * @retval true  Character is a pattern prefix (~, %, or =)
43
 * @retval false Character is not a pattern prefix
44
 */
45
static bool is_pattern_prefix(wchar_t c)
46
{
UNCOV
47
  return (c == '~') || (c == '%') || (c == '=');
×
48
}
49

50
/**
51
 * complete_pattern - Complete a NeoMutt Pattern - Implements CompleteOps::complete() - @ingroup compapi_complete
52
 */
UNCOV
53
static enum FunctionRetval complete_pattern(struct EnterWindowData *wdata, int op)
×
54
{
UNCOV
55
  if (!wdata || ((op != OP_EDITOR_COMPLETE) && (op != OP_EDITOR_COMPLETE_QUERY)))
×
56
    return FR_NO_ACTION;
57

UNCOV
58
  size_t i = wdata->state->curpos;
×
59

60
  // Check if cursor is right after a pattern prefix (~, %, or =)
UNCOV
61
  if (i && is_pattern_prefix(wdata->state->wbuf[i - 1]))
×
62
  {
63
    if (dlg_pattern(wdata->buffer))
×
64
      replace_part(wdata->state, i - 1, wdata->buffer->data);
×
65
    buf_fix_dptr(wdata->buffer);
×
UNCOV
66
    return FR_CONTINUE;
×
67
  }
68

69
  // Search backwards for a pattern prefix
UNCOV
70
  for (; (i > 0) && !is_pattern_prefix(wdata->state->wbuf[i - 1]); i--)
×
71
    ; // do nothing
72

73
  if ((i > 0) && (i < wdata->state->curpos) &&
×
UNCOV
74
      (wdata->state->wbuf[i - 1] == '~') && (wdata->state->wbuf[i] == 'y'))
×
75
  {
76
    // Label completion for ~y pattern
77
    i++;
×
78
    buf_mb_wcstombs(wdata->buffer, wdata->state->wbuf + i, wdata->state->curpos - i);
×
79
    int rc = mutt_label_complete(wdata->cd, wdata->buffer, wdata->tabs);
×
80
    replace_part(wdata->state, i, wdata->buffer->data);
×
81
    buf_fix_dptr(wdata->buffer);
×
UNCOV
82
    if (rc != 1)
×
83
    {
84
      return FR_CONTINUE;
85
    }
86
  }
87
  else
88
  {
89
    return FR_NO_ACTION;
90
  }
91

92
  return FR_SUCCESS;
93
}
94

95
/**
96
 * CompletePatternOps - Auto-Completion of Patterns
97
 */
98
const struct CompleteOps CompletePatternOps = {
99
  .complete = complete_pattern,
100
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc