emacs-async

Identify and mitigate cursor-position bugs in asynchronous Emacs Lisp code using markers and explicit context.

1|Updated Dec 14, 2025
One-click install
npx skills add https://github.com/jingtaozf/emacs-claude-agent --skill emacs-async
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: emacs-async
Source: https://github.com/jingtaozf/emacs-claude-agent/tree/main/.claude/skills/emacs-async
Command: npx skills add https://github.com/jingtaozf/emacs-claude-agent --skill emacs-async

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses cursor-position bugs in asynchronous Emacs Lisp code by teaching reliable patterns that preserve buffer context across callbacks, timers, and process filters.

Core Features & Use Cases

  • Marker-based position tracking to survive edits during async operations.
  • Explicitly pass context into callbacks to avoid relying on the current cursor state.
  • Use lexical binding to capture variables for safe asynchronous execution.
  • Validate and reposition point before using cursor-dependent functions like org-entry-get and org-get-tags.

Quick Start

Position the cursor, then start an asynchronous Emacs Lisp operation using captured markers and explicit context.

Frequently Asked Questions about emacs-async

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I preserve cursor position in Emacs Lisp asynchronous callbacks?

To preserve cursor position in Emacs Lisp asynchronous callbacks, use markers to track positions and explicitly pass context into the callback instead of relying on the current cursor state. This ensures positions survive buffer edits during async operations.

Why does my Elisp process filter move the cursor unexpectedly?

Elisp process filters move the cursor unexpectedly because buffer modifications during asynchronous execution invalidate raw position integers. Using marker-based position tracking and explicit context passing mitigates these cursor-position bugs across async callbacks.

What is the best way to handle buffer context in Elisp timers?

The best way to handle buffer context in Elisp timers is to use lexical binding to capture variables and validate the buffer before repositioning point. This maintains correct context for safe asynchronous execution across timer-triggered functions.

How do I validate point before calling cursor-dependent functions like org-entry-get?

To validate point before calling cursor-dependent functions like org-entry-get, validate and reposition the point using markers before executing the operation. This ensures the cursor is in the correct buffer context during asynchronous code execution.

Can I use lexical binding to capture variables for async Elisp execution?

Yes, you can use lexical binding to capture variables for async Elisp execution. This approach safely captures the needed context, preventing reliance on mutable global cursor states during asynchronous callbacks, timers, and process filters.

When do I need marker-based position tracking in Emacs Lisp?

You need marker-based position tracking in Emacs Lisp when performing asynchronous operations that modify the buffer. Markers automatically update their positions to survive edits during async callbacks, timers, and process filters, preventing cursor-position bugs.