From 67b757840ecad162288dead1ab419c4057ddaf17 Mon Sep 17 00:00:00 2001 From: Conor Nash Date: Fri, 15 May 2026 11:41:28 +0100 Subject: [PATCH] Add C-c C-o to browse markdown link URL at point md-ts-mode hides link URLs via invisible text properties, so browse-url-at-point and thing-at-point cannot find them. pi-coding-agent-browse-url-at-point extracts the URL from the raw buffer text on the current line and passes it to browse-url. Bound to C-c C-o in chat-mode, matching the org-mode convention. --- pi-coding-agent-ui.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pi-coding-agent-ui.el b/pi-coding-agent-ui.el index 02c147a..2f53a11 100644 --- a/pi-coding-agent-ui.el +++ b/pi-coding-agent-ui.el @@ -439,6 +439,19 @@ Returns \"text\" for unrecognized extensions to ensure consistent fencing." (or (cdr (assoc ext pi-coding-agent--extension-language-alist)) "text")))) +(defun pi-coding-agent-browse-url-at-point () + "Browse the markdown link URL at or near point." + (interactive) + (let* ((pos (point)) + (line (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + ;; Find the link text nearest to point on this line + (url (when (string-match "(\\(https?://[^)]+\\))" line) + (match-string 1 line)))) + (if url + (browse-url url) + (user-error "No URL found on this line")))) + ;;;; Major Modes (defvar pi-coding-agent-chat-mode-map @@ -452,6 +465,7 @@ Returns \"text\" for unrecognized extensions to ensure consistent fencing." (define-key map (kbd "") #'pi-coding-agent-toggle-tool-section) (define-key map (kbd "RET") #'pi-coding-agent-visit-file) (define-key map (kbd "") #'pi-coding-agent-visit-file) + (define-key map (kbd "C-c C-o") #'pi-coding-agent-browse-url-at-point) map) "Keymap for `pi-coding-agent-chat-mode'.")