NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Fuzzy matching library

High-performance fuzzy matching library for NeoMutt

Overview

This library provides fuzzy string matching capabilities optimized for interactive use in NeoMutt. It's designed to help users quickly find items by typing approximate or abbreviated input.

Design Principles

  • No heap allocation: All operations use stack memory only
  • No global state: Fully reentrant and thread-safe
  • Pure string matching: No dependencies on mailbox, alias, or email structures
  • O(n) performance: Linear time complexity for interactive responsiveness
  • Pluggable algorithms: Easy to add new matching algorithms

Use Cases

  • Mailbox/folder selection (e.g., "mlnd" → "mailinglists/neomutt-dev")
  • Alias lookup (e.g., "rich" → "Richard Smith")
  • Command completion (e.g., "set to" → "set timeout")
  • Config variable lookup (e.g., "timeo" → "timeout")
  • Email subject/sender filtering

API Usage

struct FuzzyOptions opts = { .smart_case = true };
struct FuzzyResult result = { 0 };
int score = fuzzy_match("mlnd", "mailinglists/neomutt-dev",
FUZZY_ALGO_SUBSEQ, &opts, &result);
if (score >= 0)
printf("Match! Score: %d, Span: %d\n", result.score, result.span);
@ FUZZY_ALGO_SUBSEQ
Subsequence matching algorithm.
Definition lib.h:77
int fuzzy_match(const char *pattern, const char *candidate, enum FuzzyAlgo algo, const struct FuzzyOptions *opts, struct FuzzyResult *out)
Perform fuzzy matching.
Definition fuzzy.c:58
Options for fuzzy matching.
Definition lib.h:87
Result of a fuzzy match.
Definition lib.h:98
int score
Score (<0 = no match)
Definition lib.h:99
int span
Match span.
Definition lib.h:100
File Description
fuzzy/fuzzy.c Fuzzy matching dispatcher
fuzzy/subseq.c Subsequence fuzzy matching