summaryrefslogtreecommitdiffstats
path: root/content/posts/using-emacsclient-on-macos
diff options
context:
space:
mode:
authorDante Catalfamo2020-06-18 18:58:56 -0400
committerDante Catalfamo2020-06-18 18:58:56 -0400
commit826c24e0fe1e47baf1d64d315ccff46c7e7a93df (patch)
tree7487f2e420374edab262b82662ea0ee8c2702175 /content/posts/using-emacsclient-on-macos
parent6ea917ca4e0fcea6c016f215708788abc8147a7b (diff)
downloadblog-826c24e0fe1e47baf1d64d315ccff46c7e7a93df.tar.gz
blog-826c24e0fe1e47baf1d64d315ccff46c7e7a93df.tar.bz2
blog-826c24e0fe1e47baf1d64d315ccff46c7e7a93df.zip
Most post to posts
Diffstat (limited to 'content/posts/using-emacsclient-on-macos')
-rw-r--r--content/posts/using-emacsclient-on-macos/index.org60
-rw-r--r--content/posts/using-emacsclient-on-macos/macos emacsclient.pngbin0 -> 108919 bytes
2 files changed, 60 insertions, 0 deletions
diff --git a/content/posts/using-emacsclient-on-macos/index.org b/content/posts/using-emacsclient-on-macos/index.org
new file mode 100644
index 0000000..d1b90fc
--- /dev/null
+++ b/content/posts/using-emacsclient-on-macos/index.org
@@ -0,0 +1,60 @@
+#+TITLE: Using Emacsclient on MacOS
+#+DATE: 2020-06-18T17:10:15-04:00
+#+DRAFT: false
+#+DESCRIPTION:
+#+TAGS[]: macos emacs
+#+KEYWORDS[]:
+#+SLUG:
+#+SUMMARY:
+
+#+ATTR_HTML: :alt MacOS Emacsclient
+#+ATTR_HTML: :title MacOS Emacsclient
+[[file:macos%20emacsclient.png]]
+
+Emacs is an amazing editor, but it can be a little slow to start
+sometimes. That's why =emacsclient= lets you run Emacs as a daemon and
+connect to it as a client, negating the startup time and letting you
+jump directly into editing.
+
+The two primary ways of getting Emacs onto your Mac are by either
+downloading it from [[https://emacsformacosx.com/][Emacs For MacOS X]] or by installing it through
+[[https://brew.sh/][homebrew]] using =brew cask install emacs=. I prefer the homebrew method
+as it automatically adds =emacs= and =emacsclient= to your =$PATH=.
+
+Using it from the command line is a breeze. I have this alias in my
+=.bashrc=
+
+#+BEGIN_SRC shell
+alias em="emacsclient -t -a ''"
+#+END_SRC
+
+This way I can type =em <filename>= to edit a file. =-t= tells
+emacsclient to start in terminal mode, and =-a= tell it to start the
+Emacs daemon process if it isn't already running.
+
+Getting the GUI version to run without first opening the command line
+is a little trickier. Homebrew provides an app for =emacs=, but no way
+to start =emacsclient=. The way I've worked around that is by using
+[[https://github.com/deseven/icanhazshortcut][iCanHazShortcut]], which lets you bind arbitrary shell commands to
+keyboard shortcuts.
+
+To add a new shortcut, open the app and click the =Shortcuts= tab at
+the top. Then click the plus in the bottom right corner, click inside
+the =Shortcut= field, press the desired shortcut keys, give it an
+action name, and a command.
+
+To launch =emacsclient=, I have a shortcut bound to
+@@html:<kbd>⌃</kbd> + <kbd>⇧</kbd> + <kbd>⌘</kbd> + <kbd>E</kbd>@@
+which runs
+#+BEGIN_SRC shell
+emacsclient -c -n -a ''
+#+END_SRC
+
+The =-c= flag tells =emacsclient= to open a GUI window instead of in
+terminal mode. The =-n= flag tells the command to return once the
+window is opened, instead of waiting for the client to close. Finally,
+like before the =-a ''= flag tells =emacsclient= to start the Emacs
+daemon if it isn't already running.
+
+Now all I have to do is press @@html:<kbd>⌃</kbd> + <kbd>⇧</kbd> + <kbd>⌘</kbd> + <kbd>E</kbd>@@
+and a new Emacs window pops up with no startup delay!
diff --git a/content/posts/using-emacsclient-on-macos/macos emacsclient.png b/content/posts/using-emacsclient-on-macos/macos emacsclient.png
new file mode 100644
index 0000000..371fc2f
--- /dev/null
+++ b/content/posts/using-emacsclient-on-macos/macos emacsclient.png
Binary files differ