branch: externals/ement
commit 21cc649b8062cc5085faff48fc32172ffd22f68c
Author: Phil Sainty <[email protected]>
Commit: Phil Sainty <[email protected]>
Fix: (ement-room-browse-url) Avoid recursive call
Prevent the inner `browse-url-emacs' using `ement-room-browse-url'.
---
ement-room.el | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/ement-room.el b/ement-room.el
index 423551dd56..fb7a4c5276 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -1184,7 +1184,20 @@ are passed to `browse-url'."
(lambda (room session)
(ement-view-room room
session)
(ement-room-find-event
event-id)))))
- ("Load link with browser" (apply #'browse-url url args)))))))
+ ("Load link with browser"
+ (let ((handler (cons ement-room-matrix.to-url-regexp
#'ement-room-browse-url)))
+ ;; Note that `browse-url-handlers' was added in 28.1;
+ ;; prior to that `browse-url-browser-function' served double-duty.
+ ;; TODO: Remove compat code when requiring Emacs >=28.
+ ;; (See also `ement-room-mode'.)
+ (cond ((boundp 'browse-url-handlers)
+ (let ((browse-url-handlers (remove handler
browse-url-handlers)))
+ (apply #'browse-url url args)))
+ ((consp browse-url-browser-function)
+ (let ((browse-url-browser-function (remove handler
browse-url-browser-function)))
+ (apply #'browse-url url args)))
+ (t
+ (apply #'browse-url url args))))))))))
(defun ement-room-find-event (event-id)
"Go to EVENT-ID in current buffer."
@@ -2092,6 +2105,7 @@ and erases the buffer."
;; Set the URL handler. Note that `browse-url-handlers' was added in 28.1;
;; prior to that `browse-url-browser-function' served double-duty.
;; TODO: Remove compat code when requiring Emacs >=28.
+ ;; (See also `ement-room-browse-url'.)
(let ((handler (cons ement-room-matrix.to-url-regexp
#'ement-room-browse-url)))
(if (boundp 'browse-url-handlers)
(setq-local browse-url-handlers (cons handler browse-url-handlers))