General Introduction
Emigo is an open source AI programming assistant for Emacs, developed by MatthewZMD on GitHub. Emigo is an open source AI programming assistant for Emacs, developed by MatthewZMD on GitHub, which helps programmers analyze, generate, and modify code in Emacs by integrating a large-scale language model (LLM).Emigo's core feature is an "Agentic AI", which not only generates text, but also interacts with the project through tools such as reading files, writing code, or executing commands. It can not only generate text, but also interact with the project through tools such as reading files, writing code, or executing commands. It is supported by Aider and Cline Emigo is the successor to Aidermacs, inspired by tools such as Aidermacs. Currently, Emigo is in Beta testing and features are still being refined for developers to try out and give feedback.
Function List
- Agent-based tool use: AI selects and executes tools based on task requirements, such as reading or writing files or running commands.
- Seamless integration with Emacs: The interface and shortcuts are consistent with the Emacs native experience.
- Support for multiple AI models: Connects to models such as OpenRouter, Deepseek, etc. via LiteLLM, which is freely available to the user.
- context management (computing): Automatically records conversation history and project files to ensure a coherent conversation.
- File Context Add: Quickly add files to the AI analysis via the "@" symbol.
- Code patch generation and display: The code changes returned by AI are highlighted for easy viewing.
Using Help
Emigo is an AI assistant for Emacs users. Here are detailed instructions on how to install and use it to make sure you get started quickly.
Installation process
- Inspection of environmental requirements
- Requires Emacs version 28 or higher. It can be downloaded and installed at https://www.gnu.org/software/emacs/.
- Requires Python 3.x, which can be skipped for those who have it installed, and obtained from https://www.python.org/ for those who do not.
- Download Emigo
Clone Emigo to the Emacs configuration directory by running the following command in a terminal:
git clone https://github.com/MatthewZMD/emigo.git ~/.emacs.d/emigo
- Installing Python dependencies
Go to the Emigo directory and run it:
cd ~/.emacs.d/emigo
pip install -r requirements.txt
This installs the necessary Python libraries, such as LiteLLM.
- Configuring Emacs
Open the Emacs configuration file (usually~/.emacs.d/init.el
), add the following code:
(use-package emigo
:straight (:host github :repo "MatthewZMD/emigo")
:config
(emigo-enable) ;; 自动启动后台进程
:custom
(emigo-model "openrouter/deepseek/deepseek-chat-v3-0324") ;; 设置默认模型
(emigo-base-url "https://openrouter.ai/api/v1") ;; 设置 API 地址
(emigo-api-key (emigo-read-file-content "~/.config/openrouter/key.txt"))) ;; 加载 API 密钥
- Configuration::
emigo-model
: Select the AI model to recommend OpenRouter of Deepseek.emigo-base-url
: Fill in the API service address.emigo-api-key
: Get the key from OpenRouter (https://openrouter.ai) and save it to the specified path.
- Verify Installation
After saving the configuration, restart Emacs. enterM-x emigo
If a new buffer appears, the installation was successful.
How to use
Emigo operations are mainly performed in Emacs, combining shortcuts and interactive windows.
Launch Emigo
- In the project directory, type
M-x emigo
The dedicated buffer is opened after the carriage return. - If you're in a Git repository, Emigo uses the repository root as the session path. To use the current directory, type
C-u M-x emigo
The
input prompt
- Enter your requirements in the buffer, for example:
请优化 @src/main.py 中的排序函数
- Emigo will automatically find
src/main.py
and send it to the AI for processing.
Adding files to the context
- Refer to the file with the "@" symbol, e.g.
@src/utils.py
If it is not, Emigo will add it to the context. - To view the context file: press
C-c C-l
(running)emigo-list-context-files
). - To delete a file: press
C-c C-f
(running)emigo-remove-file-from-context
).
Interacting with AI
- After entering a task, the AI analyzes it and returns the results. For example:
请帮我调试 @src/main.c 中的内存泄漏
- The patches returned by the AI will be highlighted, as in:
- free(ptr);
+ if (ptr) free(ptr);
Tool Use Process
- Emigo's agent-based functionality is realized through tools. the AI will select tools based on tasks such as:
read_file
: Read the contents of the file.write_to_file
: Write to file.execute_command
: Run command.- AI may prompt:
我需要运行 gcc -o test main.c,同意吗?
- check or refer to
y
Confirm that the results are fed into the dialog after the tool is executed.
Session Management
- Check the context: use
C-c C-l
View a list of current files. - Restart the session: close the buffer and run it again
M-x emigo
The
Development Status Alerts
- Emigo is currently in Beta and may have API changes, unstable functionality, or incomplete documentation. It is recommended that you use it for testing purposes only, and submit issues via GitHub.
application scenario
- code debugging
When you find a crash in a C project, type "check @main.c for errors" and the AI will analyze it and suggest a fix. - Document reconstruction
Type "Refactor functions in @src/utils.py" and Emigo will generate the optimized code and display the patch. - command execution
Type "compile @src/main.c" in the project and the AI will select theexecute_command
Tool Operationgcc
The
QA
- What models does Emigo support?
Multiple models are supported through LiteLLM, such as OpenRouter's Deepseek, Anthropic's Claude etc., simply specify the model name and API in the configuration. - Why is the prompt unresponsive?
There may be an invalid API key or a network issue. Check the key file path and network connection to ensure that theemigo-base-url
Accessible. - How do I update Emigo?
exist~/.emacs.d/emigo
Catalog Rungit pull
, and then restart Emacs.