From: Eric Swenson <eric@swenson.org>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Cc: Eric Swenson <eric@swenson.org>
Subject: Cannot start Emacs from Finder on macOS Ventura
Date: Mon, 9 Jan 2023 23:11:51 +0000 [thread overview]
Message-ID: <CY8PR19MB7249EDE8BA04147B98D8C323A0FE9@CY8PR19MB7249.namprd19.prod.outlook.com> (raw)
I recently decided to update my Homebrew-installed emacs, and because only version 28.2 was available, I decided to try the emacs-nightly HomeBrew cask. Installation went find, and I’m able to invoke the GUI emacs by simply executing “emacs” in a zsh shell. When I do, it comes up in the dock, and I can set the “Keep in dock” menu item from the dock icon’s Options context menu. If I exit emacs, however, I’m unable to launch it via the dock, nor by clicking on /Applications/Emacs.app in Finder. The only way I appear to be able to start it is via the command line.
It turns out that “emacs” is an alias:
➜ ~ which emacs
emacs: aliased to /Users/eswenson/.oh-my-zsh/plugins/emacs/emacsclient.sh --no-wait
This script looks like this:
#!/bin/sh
emacsfun() {
local cmd frames
# Build the Emacs Lisp command to check for suitable frames
# See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
case "$*" in
*-t*|*--tty*|*-nw*) cmd="(memq 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are tty frames
*) cmd="(delete 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are graphical terminals (x, w32, ns)
esac
# Check if there are suitable frames
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null)"
# Only create another X frame if there isn't one present
if [ -z "$frames" -o "$frames" = nil ]; then
emacsclient --alternate-editor "" --create-frame "$@"
return $?
fi
emacsclient --alternate-editor "" "$@"
}
# Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# If the second argument is - then write stdin to a tempfile and open the
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [ $# -ge 2 -a "$2" = "-" ]; then
# Create a tempfile to hold stdin
tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
|| mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
# Redirect stdin to the tempfile
cat - > "$tempfile"
# Reset $2 to the tempfile so that "$@" works as expected
set -- "$1" "$tempfile" "${@:3}"
fi
emacsfun "$@"
So “emacsclient –create-frame” is able to start emacs.
And emacsclient is:
➜ ~ which emacsclient
/usr/local/bin/emacsclient
➜ ~ ls -l /usr/local/bin/emacsclient
lrwxr-xr-x 1 eswenson admin 54 Jan 9 14:50 /usr/local/bin/emacsclient@ -> /Applications/Emacs.app/Contents/MacOS/bin/emacsclient
So why is it that neither clicking on /Application/Emacs.app in Finder, or using Spotlight, or clicking on the dock icon for Emacs will bring up Emacs?
I’m running macOS Ventura. I’m using an emacs-nightly Homebrew from this date/time: 2023-01-06_00-09-32.
-- Eric (KC6EJS)
next reply other threads:[~2023-01-09 23:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 23:11 Eric Swenson [this message]
2023-01-10 1:23 ` Emacs for early Macs? (was: Re: Cannot start Emacs from Finder on macOS Ventura) [screenshot] Emanuel Berg
2023-01-10 2:11 ` Eric Swenson
2023-01-10 3:59 ` Emanuel Berg
2023-01-10 5:12 ` Emacs for early Macs? Po Lu
2023-01-10 5:43 ` Emanuel Berg
2023-01-10 10:33 ` Emacs for early Macs? (was: Re: Cannot start Emacs from Finder on macOS Ventura) [screenshot] Jean Louis
2023-01-10 21:57 ` Emanuel Berg
2023-01-11 1:04 ` Cannot start Emacs from Finder on macOS Ventura Eric Swenson
2023-01-11 3:03 ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-01-16 0:00 ` Eric Swenson
2023-01-11 6:25 ` Daniel Fleischer
2023-01-11 6:44 ` John Covici
2023-01-15 22:54 ` Eric Swenson
2023-01-15 23:55 ` Eric Swenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CY8PR19MB7249EDE8BA04147B98D8C323A0FE9@CY8PR19MB7249.namprd19.prod.outlook.com \
--to=eric@swenson.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).