From f66543a308c2e420ef3b4fc4b5033bec8d77dbfe Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Thu, 7 May 2026 00:08:40 +0200 Subject: [PATCH] Add two Emacs editor-link schemes emacs://: a freeform URL the user maps to emacsclient via xdg-mime. emacs-org://: the canonical org-protocol://open-source URL handler that ships with Emacs once (require 'org-protocol) is loaded. Co-Authored-By: Claude Opus 4.7 (1M context) --- README.md | 6 +++--- data/viewer.html | 2 ++ data/viewer.js | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ae4d0e9..863c42f 100644 --- a/README.md +++ b/README.md @@ -279,13 +279,13 @@ The side panel has an `Editor link` block at the top with two settings | Setting | What it does | |---|---| -| **Editor** | Picks a URL scheme — VS Code, VS Code Insiders, Cursor, IntelliJ family, TextMate (`txmt://`), or plain `file://`. Set it to *off* to keep `Defined at` as plain text. | +| **Editor** | Picks a URL scheme — VS Code, VS Code Insiders, Cursor, IntelliJ family, TextMate (`txmt://`), Emacs (`emacs://` or `org-protocol://`), or plain `file://`. Set it to *off* to keep `Defined at` as plain text. | | **Source root override** | Absolute prefix prepended to relative paths when no per-package root is known. Usually leave blank — `classgraph-view` infers roots from `--input` (see below). | Once an editor is chosen, every `Defined at` line in the panel becomes a clickable link that opens the file at the right line in your editor. -Schemes that take a column (`vscode`, `cursor`, `txmt`) get one; -`idea` and `file` ignore it. +Schemes that take a column (`vscode`, `cursor`, `txmt`, `emacs`) get +one; `idea`, `emacs-org`, and `file` ignore it. **Source roots are inferred automatically.** The plugin records source paths as GHC saw them (usually relative to each package's source dir), diff --git a/data/viewer.html b/data/viewer.html index c84f951..e83979d 100644 --- a/data/viewer.html +++ b/data/viewer.html @@ -85,6 +85,8 @@ + + diff --git a/data/viewer.js b/data/viewer.js index 01e13a1..757e9b0 100644 --- a/data/viewer.js +++ b/data/viewer.js @@ -1410,6 +1410,20 @@ return `idea://open?file=${encodeURIComponent(abs)}&line=${line}`; case 'txmt': return `txmt://open?url=file://${enc}&line=${line}&column=${col || 1}`; + case 'emacs': + // Same query-string shape as `idea`, intentionally — user-side + // handlers (xdg-mime / a small wrapper that calls emacsclient + // +LINE:COL FILE) are easy to write against this layout. See + // the README for an example. + return `emacs://open?file=${encodeURIComponent(abs)}` + + `&line=${line}&column=${col || 1}`; + case 'emacs-org': + // Emacs's own org-protocol://open-source URL handler. Requires + // (require 'org-protocol) plus (server-start) on the user's + // side — the canonical Emacs-internal way. + return `org-protocol://open-source?url=` + + encodeURIComponent('file://' + (enc.startsWith('/') ? enc : '/' + enc)) + + `&line=${line}`; case 'file': return `file://${enc.startsWith('/') ? '' : '/'}${enc}`; default: -- 2.54.0