Home URL: | https://github.com/pierre-rouleau/pel |
---|---|
Project: | PEL -- Pragmatic Emacs Library |
Created: | Thursday, May 23 2024. |
Author: | Pierre Rouleau <[email protected]> |
Modified: | 2024-05-29 08:23:53 EDT, updated by Pierre Rouleau. |
Copyright: | © 2024, Pierre Rouleau |
Instead of using the long explicit commands listed in the sections below, you can use the following short commands. These support both macOS and Linux.
. | e[OPTIONS..] [FILE..] |
Start Emacs in text mode.
|
. | ge :
|
Start Emacs in graphics mode.
|
. | ec :
|
Start an Emacs client for an Emacs daemon.
|
For instructions on how to close/terminate the Emacs daemon and its clients, see the Closing Suspending PEL PDF
PEL also provides a quick installation script.
Test environments:
The commands were tested in the following environments:
- macOS Sonoma 14.5, Apple Silicon
- macOS Mojave 10.14.6, i386 architecture
- Linux Ubuntu 16.04, i386 architecture
- Linux Ubuntu 22.04, arm64 architecture
Goal: Provide ability to launch a graphical (GUI) or text-based (TTY) Emacs client from a macOS terminal.
Challenge: Several people, including myself, had problems launching the
graphical based Emacs client from the terminal, regardless of the
emacsclient
command line used. All instances of Emacs client programs
ended up being terminal based only.
Solution: The key is to use an Emacs binary that supports Emacs in graphics mode to launch the Emacs daemon. Once this done, it becomes possible to launch graphical Emacs clients and text-based Emacs clients:
- To launch a graphical based Emacs client use a graphics-capable
emacsclient
binary. - To launch a text based Emacs client, you can use two methods:
- Use a graphics-capable Emacs and issue the command
emacsclient -nw
- Use a text-based Emacs and issue one of the following 2 commands:
emacsclient -c
oremacsclient -nw
- Use a graphics-capable Emacs and issue the command
On macOS, the graphics-capable Emacs is one of the Emacs binary files inside
the /Applications/Emacs.app
universal DMG directory tree from Emacs for
Mac OS X installed manually or from the Homebrew brew install --cask
emacs
command.
Other Considerations
Under macOS (as of macOS Sonoma in 2024), if you want to launch an independent terminal-based Emacs process from the terminal shell, it is best to use an Emacs binary that was built without graphical capabilities because it starts faster than an Emacs that was built with graphical capabilities.
Because of that you may want to install two instances of Emacs on macOS:
- one with graphical capabilities and
- one that does not have them built-in.
Fortunately it's possible to do both without having to build Emacs locally: Homebrew supports installing both as long as you follow some steps to trick it.
First install the graphics capable version of macOS. This can be done in two different ways:
Download and install the Emacs the Emacs for Mac OS X, or
Use the Homebrew package manager and issue the following command from your terminal:
brew install --cask emacs
Both install the same macOS universal DMG from Emacs for Mac OS X.
At this point, Homebrew won't let you install another version of emacs. You need to trick it.
- First copy the Emacs DMG (
/Applications/Emacs.app
) somewhere else. - Next, uninstall Homebrew's installed (cask) Emacs with:
brew uninstall --cask emacs
. - Then install the terminal-only version of Emacs with Homebrew by issuing the
following command:
brew install emacs
- Finally, put your
Emacs.app
copy back into/Applications
so you will now also have/Applications/Emacs.app
At this point, if you type which emacs
you should see that it is installed
inside a Homebrew controlled directory. For macOS running on Apple Silicon
processors, that's /opt/homebrew/bin/emacs
.
The graphical version of Emacs is located inside the following directory:
>0@14:53:40 L3 roup@macStudio1:/Applications/Emacs.app/Contents/MacOS
zsh% ls -lFGO
total 156416
-rwxr-xr-x@ 1 roup admin - 4085936 24 Mar 10:18 Emacs*
-rwxr-xr-x@ 1 roup admin - 8236224 24 Mar 10:18 Emacs-arm64-11*
-rw-r--r--@ 1 roup admin - 16995328 24 Mar 10:18 Emacs-arm64-11.pdmp
-rwxr-xr-x@ 1 roup admin - 8469888 24 Mar 10:18 Emacs-x86_64-10_11*
-rw-r--r--@ 1 roup admin - 16922656 24 Mar 10:18 Emacs-x86_64-10_11.pdmp
-rwxr-xr-x@ 1 roup admin - 8349024 24 Mar 10:18 Emacs-x86_64-10_14*
-rw-r--r--@ 1 roup admin - 16995160 24 Mar 10:18 Emacs-x86_64-10_14.pdmp
lrwxr-xr-x 1 roup admin - 16 22 May 08:31 bin@ -> bin-x86_64-10_11
drwxr-xr-x@ 6 roup admin - 192 24 Mar 10:18 bin-arm64-11/
drwxr-xr-x@ 6 roup admin - 192 24 Mar 10:18 bin-x86_64-10_11/
drwxr-xr-x@ 6 roup admin - 192 24 Mar 10:18 bin-x86_64-10_14/
-rwxr-xr-x@ 1 roup admin - 281 24 Mar 10:18 emacs-nw*
-rwxr-xr-x@ 1 roup admin - 11272 24 Mar 10:18 launch.rs*
drwxr-xr-x@ 50 roup admin - 1600 24 Mar 10:18 lib-arm64-11/
drwxr-xr-x@ 8 roup admin - 256 24 Mar 10:18 lib-x86_64-10_11/
drwxr-xr-x@ 51 roup admin - 1632 24 Mar 10:18 lib-x86_64-10_14/
lrwxr-xr-x 1 roup admin - 20 22 May 08:31 libexec@ -> libexec-x86_64-10_11
drwxr-xr-x@ 5 roup admin - 160 24 Mar 10:18 libexec-arm64-11/
drwxr-xr-x@ 5 roup admin - 160 24 Mar 10:18 libexec-x86_64-10_11/
drwxr-xr-x@ 5 roup admin - 160 24 Mar 10:18 libexec-x86_64-10_14/
>0@14:53:51 L3 roup@macStudio1:/Applications/Emacs.app/Contents/MacOS
zsh%
And the Apple Silicon ARM64 binaries are see here:
>0@14:55:57 L3 roup@macStudio1:/Applications/Emacs.app/Contents/MacOS/bin-arm64-11
zsh% ls -lFGO
total 1168
-rwxr-xr-x@ 1 roup admin - 204752 24 Mar 10:18 ctags*
-rwxr-xr-x@ 1 roup admin - 91744 24 Mar 10:18 ebrowse*
-rwxr-xr-x@ 1 roup admin - 92912 24 Mar 10:18 emacsclient*
-rwxr-xr-x@ 1 roup admin - 204480 24 Mar 10:18 etags*
>0@14:56:03 L3 roup@macStudio1:/Applications/Emacs.app/Contents/MacOS/bin-arm64-11
zsh%
The next sections list the explicit commands to launch Emacs in a specific way. These assume Emacs was installed in macOS as described in the previous section.
Explicit command line:
emacs
Explicit command line:
open -n -a /Applications/Emacs.app/Contents/MacOS/Emacs
This uses the macOS open command with the following command line options:
-n
: open a new instance on each invocation-a application
: identify the path of the application
Assuming no Emacs daemon is running, you can use Spotlight to open Emacs from the keyboard:
- Type
⌘-SPACE
then Emacs andRET
Explicit command line for an Emacs daemon with the default socket name:
/Applications/Emacs.app/Contents/MacOS/Emacs --daemon
If you want to create multiple Emacs daemon, each one must identify a socket by name. The command is:
/Applications/Emacs.app/Contents/MacOS/Emacs --daemon --socket-name=FILENAME
where, according the emacsclient man page:
*Use socket named FILENAME for communication. Relative filenames are relative to "$XDG_RUNTIME_DIR/emacs/" or "$TMPDIR/".
See also the EMACS_SOCKET_NAME environment variable, over which this option takes precedence.*
Explicit command for macOS running on Apple Silicon:
/Applications/Emacs.app/Contents/MacOS/bin-arm64-11/emacsclient -c -n
Explicit command using the mac OS X Emacs, for macOS on Apple Silicon:
/Applications/Emacs.app/Contents/MacOS/bin-arm64-11/emacsclient -nw
Explicit command using the text-based Emacs installed with Homebrew brew
install emacs
command:
emacsclient -nw