# Setting Up Emacs on macOS 27 with Both Window Resizing and Japanese Inline Input

When installing Emacs on macOS 27, different distribution packages come with the following trade-offs:

| Installation Method | Window Resizing | Japanese Conversion Clause Distinction (Underlines) | Notes |
| :--- | :---: | :---: | :--- |
| `emacs-mac` (Emacs 29) | No | Yes | Conflicts with macOS 27 live window resizing, preventing mouse-drag resizing |
| Official Cask `emacs` (Emacs 31) | Yes | No | Lacks the IME inline patch, so conversion clause boundaries are not visually distinguished |
| **`emacs-plus@31` + Inline Patch** | **Yes** | **Yes** | **Achieves both by applying the Japanese inline patch to the NS-based build** |

This guide covers how to build **Emacs 31** from `d12frosted/emacs-plus` with the Japanese inline patch (`takaxp/ns-inline-patch`) applied.

---

## Prerequisites

* macOS 27
* Homebrew installed

---

## Installation Steps

### 1. Remove Conflicting Emacs Installations (If Installed)

Uninstall any previously installed versions of Emacs to avoid command link conflicts.

```bash
# If installed via Cask
brew uninstall --cask emacs

# If emacs-mac is installed
brew uninstall emacs-mac
```

### 2. Add the Tap and Trust the Formula (`brew trust`)

Add `d12frosted/emacs-plus`. Recent versions of Homebrew require explicit permission (`brew trust`) before loading formulas from third-party taps, so run the trust commands as well.

```bash
brew tap d12frosted/emacs-plus
brew trust d12frosted/emacs-plus
brew trust --formula d12frosted/emacs-plus/emacs-plus@31
```

### 3. Create the Configuration File (`build.yml`) for the Japanese Inline Patch

`emacs-plus` automatically applies patches during build time when their URLs and SHA256 hashes are specified in `~/.config/emacs-plus/build.yml`.

Run the following commands to fetch the latest patch from the repository and generate the configuration file:

```bash
mkdir -p ~/.config/emacs-plus

PATCH_NAME=$(curl -fsSL https://api.github.com/repos/takaxp/ns-inline-patch/contents/ | grep -o '"name": "emacs-[0-9.]*-inline\.patch"' | cut -d'"' -f4 | sort | tail -n 1)
PATCH_URL="https://raw.githubusercontent.com/takaxp/ns-inline-patch/master/${PATCH_NAME}"
SHA=$(curl -fsSL "$PATCH_URL" | shasum -a 256 | awk '{print $1}')

cat <<EOF> ~/.config/emacs-plus/build.yml
patches:
  - ns-inline-patch:
      url: "$PATCH_URL"
      sha256: "$SHA"
EOF
```

Verify the generated file (confirm that both `url` and a 64-character `sha256` hash are present):

```bash
cat ~/.config/emacs-plus/build.yml
```

### 4. Build and Install `emacs-plus@31`

This compiles Emacs from source with the patch applied (this takes a few minutes depending on your machine).

```bash
brew install d12frosted/emacs-plus/emacs-plus@31
```

Once the installation finishes, launch the app directly to verify it works:

```bash
open /opt/homebrew/opt/emacs-plus@31/Emacs.app
```

### 5. Register in the Applications Folder (Spotlight Support)

`Emacs.app` built via a Formula is not placed in `/Applications` automatically. Because standard symbolic links (`ln -s`) do not appear in Spotlight search results, create a Finder alias instead:

```bash
osascript -e 'tell application "Finder" to make alias file to POSIX file "/opt/homebrew/opt/emacs-plus@31/Emacs.app" at POSIX file "/Applications"'
```

---

## Verification Checklist

* [ ] The window can be freely resized by dragging its edges with the mouse cursor
* [ ] When typing in Japanese (IME enabled), the active conversion clause is visually distinguishable from other clauses via underline thickness or background color
* [ ] Searching for `Emacs` in Spotlight (`Command + Space`) finds and launches the application