]> Repositorios git - classgraph.git/commitdiff
Add two Emacs editor-link schemes
authorJavier Sagredo <[email protected]>
Wed, 6 May 2026 22:08:40 +0000 (00:08 +0200)
committerJavier Sagredo <[email protected]>
Wed, 6 May 2026 22:08:40 +0000 (00:08 +0200)
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) <[email protected]>
README.md
data/viewer.html
data/viewer.js

index ae4d0e9f21f4f9d0853d4cb9ac70f8cf27157796..863c42fc67e0d9fd3bc4df64a7054196c4c4c768 100644 (file)
--- 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),
index c84f9513c71da59065a08028372b12c427070c3a..e83979df1e9f555e26bba14c6c8d984737f77968 100644 (file)
@@ -85,6 +85,8 @@
           <option value="cursor">Cursor</option>
           <option value="idea">IntelliJ / IDEA family</option>
           <option value="txmt">TextMate (txmt://)</option>
+          <option value="emacs">Emacs (emacs://)</option>
+          <option value="emacs-org">Emacs (org-protocol)</option>
           <option value="file">file:// (no line jump)</option>
         </select>
       </div>
index 01e13a1aa7c5abfc5132097855cc8f0352977a1d..757e9b0fa4211259e80dbeaf015996217ab6bf79 100644 (file)
         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: