Given the magical startup speed of Emacs, every time you open a file like Vim starts an Emacs, it is intolerable, in Linux, you can use Emacs -- deamon to start Emacs as a daemon, but this parameter does not support windows (although it is awkward to use Emacs on Windows ), it is estimated that the features are not available on the Windows platform. I have not studied the specific features.
However, the Windows platform can only start a single Emacs instance, so that you can use this existing instance to open the file each time, to avoid waiting for the embarrassing startup speed of Emacs. The principle is to start an Emacs instance as the server, listen to a port, and then use the client to connect to the port when you need to open the file, and pass the file path and other information to the server, then, as the server's Emacs, after receiving the path information, find the file and open it.
To start Emacs as a server, add the following command to the Emacs configuration file:
(server-start)
In this example, after you use runemacs.exe to start Emacs, you can view the settings and values of the home directory in the home directory. emacs. A server file is generated under the d \ Server Directory, which records information such as the IP address and port number of the Emacs instance. After exiting Emacs, the file will be deleted.
Prepare two EXE files. The former is based on the command line, and the latter has a graphical interface. The command to connect to the server to open the file is as follows:
emacsclientw.exe --no-wait --alternate-editor="runemacs.exe" "~/.emacs"
The -- no-Wait parameter tells the client not to wait for Emacs wait, so that Emacs can be run and edited without Emacs running. The third parameter is the file to be opened, this is the configuration file in the home directory. emacs. After running this command, emacsclientw.exe finds the Server File In the <Home> \. emacs. d \ Server Directory, retrieves the IP address and port number, and connects "~ /. The emacs file is uploaded and then opened as the server's Emacs. Because the -- no-Wait parameter exists, the client will not directly exit when it returns the result as the server's Emacs; of course, if <Home> \. emacs. if the d \ serverdirectory does not find the serverfile, The clientwill call runemacs.exe to open the file.
========================================================== I am proud demarcation Line ================================================
Now, it is impossible for us to input such a large string of things through the command line every time a file is opened. Besides, the path changes every time, right-click "Edit with Emacs" and choose "Edit with Emacs" from the shortcut menu. Therefore, set the following key value in the registry:
HKEY_CLASSES_ROOT\*\shell\Edit with Emacs\command
Set the default value:
"path\to\emacsclientw.exe" --no-wait --alternate-editor="path\to\runemacs.exe" "%1"
In the preceding command, replace the paths of emacsclientw.exeand runemacs.exe with the actual paths, while % 1 indicates the file to be opened. It is best to enclose all parts with paths in quotation marks to prevent space harassment. For example:
The shortcut menu is as follows:
References: http://www.emacswiki.org/emacs/EmacsClient