I use Emacs as server instance.
When I start EMacs Client, he will check if the file
.emacs.d/server/server exists. If not so, then he will initiating a Emacs server instance, and my Emacs configuration files will be loaded.
Then I start a new Emacs Client. He checks that the
server-file already exists. The Emacs configuration will not be loaded again, but it will create a new frame instead, connected with the Emacs server instance. It loads really fast.
If I close the Emacs instance properly, the file
server will be deleted. But sometimes my Emacs crashes (it happens a lot, because I configure my Emacs like a crazy, believe me).
Then I start Emacs client again, after killing it in Windows. He sees the Emacs
server file already exists, but he cannot find the Emacs instance server, to create a frame from it.
So I decided to automatically delete the server-file, every time that Emacs file is being loaded (it's being loaded only when Emacs starts as server instance).
So I created the following:
(add-hook before-init-hook '(shell-command "c:/Dropbox/Sys/autohotkey/delete-server-file-emacs.ahk")) (require 'server) (unless (server-running-p) (server-start))
This is an AHK-script, that deletes the server file every time when the Emacs configuration is being read.
When I start the Emacs instance, while the server file still in the folder, he still tries to read the server-file first, before execute the autohotkey script.
I stil got the message that there no connection from emacsclient could be made, because the target machine actively refused it. So that means he is reading the server file, that means that there is a Emacs instance as server to connect with it.
Any suggestion, in order to solve this?