# Contributing to eml-tmLanguage
Thank you for considering contributing to `eml-tmLanguage` (`email.tmBundle`)!
---
## Development Setup
To symlink the package for local development in **Sublime Text 3** (and **TextMate 2** on macOS):
```bash
./scripts/link_sublime.sh
```
Or link manually:
- **Sublime Text 3 (macOS)**:
```bash
ln -s "$PWD" "$HOME/Library/Application Support/Sublime Text 3/Packages/Email"
```
- **Sublime Text 3 (Linux)**:
```bash
ln -s "$PWD" "$HOME/.config/sublime-text-3/Packages/Email"
```
- **TextMate 2 (macOS)**:
```bash
mkdir -p "$HOME/Library/Application Support/TextMate/Bundles"
ln -s "$PWD/email.tmBundle" "$HOME/Library/Application Support/TextMate/Bundles/email.tmBundle"
```
---
## Editing & Compiling the Grammar
- **YAML source**: `email.tmBundle/Syntaxes/email.YAML-tmLanguage`
- **Compiled XML plist**: `email.tmBundle/Syntaxes/email.tmLanguage` (consumed directly by Sublime Text 3 and TextMate 2)
Whenever you update `email.YAML-tmLanguage`, recompile `email.tmLanguage` so both files stay synchronized:
```bash
python3 scripts/build_grammar.py
```
Verify sync without modifying files (enforced in CI):
```bash
python3 scripts/build_grammar.py --check
```
---
## Testing & Verifying Changes
### 1. Automated Unit Tests & Python 3.3 Checks
```bash
python3 -m py_compile email_plugin.py scripts/build_grammar.py
python3 -m unittest discover -s tests -p "test_*.py" -v
```
### 2. Automated Syntax Tests (Sublime Text 3)
- Open any `tests/syntax_test_*.eml` file in Sublime Text 3 and press Cmd + B (macOS) or Ctrl + B (Windows/Linux).
- GitHub Actions runs the entire suite automatically against **Sublime Text 3 (Build 3211)**.
### 3. Visual Verification & Scope Inspection
Open sample emails in [tests/fixtures/](tests/fixtures/) in **Sublime Text 3** and **TextMate 2**. To inspect the scope under your cursor:
- **Sublime Text 3 (macOS)**: Cmd + Option + P
- **Sublime Text 3 (Windows / Linux)**: Ctrl + Alt + Shift + P
- **TextMate 2 (macOS)**: Ctrl + Shift + P
---
## Guidelines & Best Practices
- **Scope Naming**: Follow the [Sublime Text Scope Naming Guidelines](https://www.sublimetext.com/docs/scope_naming.html) and [TextMate Language Grammar Naming Conventions](https://macromates.com/manual/en/language_grammars#naming_conventions).
- **Sublime Text 3 & TextMate 2 Compatibility**: Keep syntax rules compatible with standard `.tmLanguage` Oniguruma format (never introduce `.sublime-syntax` / Sublime Text 4-only keys such as `push`, `pop`, `set`, `with_prototype`, `extends`, or `version: 2`, and never use `foldScopes`).
- **Python 3.3 Plugin Compatibility**: `email_plugin.py` runs on Sublime Text 3's Python 3.3 host — avoid f-strings, `re.fullmatch`, `b64decode(..., validate=True)`, or zero-argument `datetime.astimezone()`.
- **Regular Expressions**: Avoid unbounded quantifier nesting (`(a+)+`) or ambiguous overlapping branches to prevent catastrophic backtracking (ReDoS).
---
## Code of Conduct & Security
- This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
- Please do not open public issues for security vulnerabilities — see [SECURITY.md](SECURITY.md) for confidential disclosure.
---
## Submitting Pull Requests
1. Create a feature branch from `master`.
2. Keep PRs focused on a single change or fix.
3. Attach **before / after screenshots** illustrating any visual changes in highlighting.
4. Fill out the checklist in the [Pull Request Template](.github/PULL_REQUEST_TEMPLATE.md).
5. External contributors do not need to edit `CHANGELOG.md`; maintainers curate releases following merge (see [RELEASE.md](RELEASE.md)).
---
## References
- [Sublime Text Scope Naming Guidelines](https://www.sublimetext.com/docs/scope_naming.html)
- [TextMate Language Grammars Manual](https://macromates.com/manual/en/language_grammars)
- [RFC 5322: Internet Message Format](https://tools.ietf.org/html/rfc5322)
- [RFC 2045: MIME Part One](https://tools.ietf.org/html/rfc2045)
- [RFC 2047: MIME Message Header Extensions for Non-ASCII Text](https://tools.ietf.org/html/rfc2047)