https://github.com/mimo84/emacsclient-wrapper
https://github.com/mimo84/emacsclient-wrapper
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mimo84/emacsclient-wrapper
- Owner: mimo84
- Created: 2024-06-14T21:42:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-09T19:55:22.000Z (over 1 year ago)
- Last Synced: 2025-07-08T03:10:12.817Z (12 months ago)
- Language: Shell
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.org
Awesome Lists containing this project
README
* Emacs Client Wrapper Script
** Demo Video
You can watch the demo for this video here: https://youtu.be/pQr6pnnZ6sA
** What is it
This is a utility script that wraps Emacs client in order to automatically run a server configured to use a chemacs2 profile or a =init-directory=.
It is going to pass to =emacsclient= all the extra options that are not read out by the script.
For the options you can pass to =emacsclient= refer to: https://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html
** How is different than just running =emacsclient -a=?
It differs because when running emacsclient with =-a= option I did not find a way to specify a profile or an =init-directory=, which didn't involve changing the startup script.
Also the script has some utility functions such as =-l= that is going to list all the socket files currently available in the system.
** Dependencies
This script expects =emacs= and =emacsclient= to be in the system and available.
Also uses =lsof= to be installed in the system.
*** =profile= option
In order to use the =--profile= option in the script, [[https://github.com/plexus/chemacs2][chemacs2]] is expected to be installed and configured in the system.
*** =init-directory= option
The [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Initial-Options.html#index-_002d_002dinit_002ddirectory][init-directory]] option relies on Emacs being v29.
** Examples
*** Basic usage
#+begin_src sh
ec
#+end_src
*** Emacs server already running
It will open a new instance of =emacsclient= in a frame, called with =-c= option.
*** Emacs server is not running
In this case is going to call =emacsclient= with =-a ''= option, which is going to start the server for the default profile of Emacs.
*** Specify a profile or =init-directory=
#+begin_src sh
ec --profile
# or
ec --init-directory ~/init-directory
#+end_src
**** Emacs server already running
It's going to just call Emacs client, since the socket already exists and it's not required to create a new one.
If you really want to run a second server besides you can always run the regular command:
#+begin_src sh
emacs --bg-daemon= --init-directory ~/init-directory
#+end_src
and then call the script with the =-s= option for Emacs client to reference to that particular daemon that wants to be used.
#+begin_src sh
ec -s
#+end_src
**** Emacs server is not running
It is going to start a new Emacs instance with a particular =init-directory= or profile, and then it's going to run the client associated with it.
***** List available Emacs server
#+begin_src sh
ec -l
#+end_src
It will return a list of open Emacs sockets using =lsof=.
*** Kill an Emacs server
#+begin_src sh
ec -k
#+end_src
Or a specific daemon instance:
#+begin_src sh
ec -k -s
#+end_src
** Support for all the options that can be provided to =emacsclient=
Just a few examples:
*** Open =emacsclient= on a particular file and line number
#+begin_src sh
ec +18 ~/dotfiles/.config/conf.el
#+end_src
*** Open =emacsclient= using a different daemon
#+begin_src sh
ec -s deamon-name +12 ~/my-file.org
#+end_src