emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit d98e935ed7 1/2: magit-{browse, visit}-thing: Ha


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit d98e935ed7 1/2: magit-{browse, visit}-thing: Handle raw URL links
Date: Thu, 2 May 2024 10:00:14 -0400 (EDT)

branch: elpa/git-commit
commit d98e935ed7134b44e5ee9d2a3b4bf42938fdface
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-{browse,visit}-thing: Handle raw URL links
    
    Every once in a while, someone suggests that it should be possible to
    follow URL links (often those displayed by user hooks and thus in the
    process buffer), which I used to decline, on the grounds that it would
    be way too costly to do that, for too little gain, and that the
    workaround (using `browse-url') was simple and obvious enough.
    
    By adding support for urls to `magit-browse-thing' (because that is
    where it belongs, according to Magit's browse|visit distinction) and
    `magit-visit-thing' (because that (i.e., "RET") is what users are
    likely to try using), we get the desired behavior -- without having
    to spend time looking for urls ahead while washing process output.
    
    So now "RET" visits links, unless `magit-visit-thing' is remapped to
    something else, that is.  The mouse still cannot be used.
    
    Closes #5134.
---
 lisp/magit-mode.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index bab9dae204..91db4d63af 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -421,7 +421,9 @@ which actually visits the thing at point."
   (interactive)
   (if (eq transient-current-command 'magit-dispatch)
       (call-interactively (key-binding (this-command-keys)))
-    (user-error "There is no thing at point that could be visited")))
+    (if-let ((url (browse-url-url-at-point)))
+        (browse-url url)
+      (user-error "There is no thing at point that could be visited"))))
 (put 'magit-visit-thing 'completion-predicate #'ignore)
 
 (defun magit-edit-thing ()
@@ -436,11 +438,13 @@ buffer."
 (put 'magit-edit-thing 'completion-predicate #'ignore)
 
 (defun magit-browse-thing ()
-  "This is a placeholder command, which signals an error if called.
+  "This is a placeholder command, which may signals an error if called.
 Where applicable, other keymaps remap this command to another,
 which actually visits thing at point using `browse-url'."
   (interactive)
-  (user-error "There is no thing at point that could be browsed"))
+  (if-let ((url (browse-url-url-at-point)))
+      (browse-url url)
+    (user-error "There is no thing at point that could be browsed")))
 (put 'magit-browse-thing 'completion-predicate #'ignore)
 
 (defun magit-copy-thing ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]