# Agent Guidelines: Aerc Configuration Repository

This repository contains the configuration and customization for `aerc`, a terminal-based email client. It is optimized for a workflow involving `notmuch` for indexing, `mbsync` for synchronization, `abook` for address management, `khal` for calendar, and `taskwarrior` for tasks.

## 1. Build, Lint, and Test Commands

### Sync and Maintenance
- **Global Sync**: Run `mailsync` (bound to `u` in `aerc`) to perform:
  1. `mbsync -a` (Mail sync)
  2. `vdirsyncer sync` (Calendar sync)
  3. `caldawarrior sync` (Task sync)
  4. `notmuch new` for all account databases (Indexing)
  5. `notmuch-abook-sync` (Address book population)

### Linting
- **Permissions**: `accounts.conf` must be `0600`.
- **Dependencies**: `w3m`, `bat`, `yazi`, `notmuch`, `abook`, `pass`, `isync`, `khal`, `vdirsyncer`, `task`, `taskwarrior-tui`, `caldawarrior`.

### Testing
- **Filters**: `cat email.html | w3m -T text/html -dump`
- **Calendar**: `khal list`
- **Tasks**: `task list`

## 2. Code Style Guidelines

### Aerc Configuration
- **Notmuch URI**: Use absolute triple-slash format: `source = notmuch:///home/liph/Mail/account_name`.
- **Credentials**: Use `pass` via `outgoing-cred-cmd = pass show mail/account_email`.
- **Sidebar**: Use separate `notmuch` databases per account directory for isolation.

### Keybindings
- **Leader**: `,` (comma).
- **Tab switching**: `Alt+n` (next) and `Alt+p` (prev).
- **Contacts**: `,ab` opens `abook`.
- **Calendar**: `,ca` opens unified `khal`.
- **Tasks**: `,ta` opens `taskwarrior-tui`.

### Terminal Tabs (Khal/Taskwarrior)
- **Escape**: Press `Ctrl+x` to release terminal focus and use `aerc` commands.
- **Tab Passthrough**: `Tab` and `Backtab` are passed to terminal apps for internal navigation.

### Neovim integration (`after/ftplugin/mail.lua`)
- **Completion**: Triggered by `Tab` on header lines using `abook --mutt-query`.
- **Fzf**: Triggered by `Ctrl+f` for interactive contact selection.
