diff options
author | F. Jason Park <jp@neverwas.me> | 2022-07-11 05:14:57 -0700 |
---|---|---|
committer | F. Jason Park <jp@neverwas.me> | 2022-11-16 21:34:36 -0800 |
commit | ed5022b4eec676bd6c0509615a1f939b796b942b (patch) | |
tree | 0ad5489bdd8e7ea7b27cd110d559cbe347b1a682 /lisp/erc/erc-compat.el | |
parent | 535cc4c81a91d0661418ce59be951dda9e233a2e (diff) | |
download | emacs-ed5022b4eec676bd6c0509615a1f939b796b942b.tar.gz emacs-ed5022b4eec676bd6c0509615a1f939b796b942b.tar.bz2 emacs-ed5022b4eec676bd6c0509615a1f939b796b942b.zip |
Improve new connections in erc-handle-irc-url
* doc/misc/erc.texi: Add new Integrations section to the info manual
under Advanced Usage.
* etc/ERC-NEWS: Add new section mentioning improved UX when clicking
on irc:// links.
* lisp/erc/erc.el (erc-handle-irc-url): Add optional "scheme"
parameter. Fix `erc-open' invocation so that the server buffer is
named correctly by deferring to a new customizable opener. Arrange
for JOINing a channel in a manner similar to ERC's autojoin module.
(erc-url-connect-function): Add new option for creating a new ERC
connection based on info parsed from a URL.
(erc--url-default-connect-function): New function to serve as an
interactive-only fallback when a user hasn't specified a URL connect
function.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url--irc): Add new
compatibility function for `browse-url-irc' and include it in
`browse-url-default-handlers' on Emacs versions below 29.
* test/lisp/erc/erc-tests.el (erc-tests--make-server-buf,
erc-tests--make-client-buf): Add helpers for creating dummy ERC
buffers.
(erc-handle-irc-url): Add test.
* test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-handle-irc-url):
Add new test.
* test/lisp/erc/resources/join/legacy/foonet.eld: Relax
timeout. (Bug#56514.)
Diffstat (limited to 'lisp/erc/erc-compat.el')
-rw-r--r-- | lisp/erc/erc-compat.el | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 5b54a0587a1..d23703394be 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -32,8 +32,7 @@ ;;; Code: (require 'compat nil 'noerror) -(eval-when-compile (require 'cl-lib)) - +(eval-when-compile (require 'cl-lib) (require 'url-parse)) ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode @@ -285,6 +284,35 @@ If START or END is negative, it counts from the end." `(cl--generic-with-memoization ,table ,@forms)) (t `(progn ,@forms)))) +(defvar url-irc-function) + +(defun erc-compat--29-browse-url-irc (string &rest _) + (require 'url-irc) + (let* ((url (url-generic-parse-url string)) + (url-irc-function + (if (function-equal url-irc-function 'url-irc-erc) + (lambda (host port chan user pass) + (erc-handle-irc-url host port chan user pass (url-type url))) + url-irc-function))) + (url-irc url))) + +(cond ((fboundp 'browse-url-irc)) ; 29 + ((boundp 'browse-url-default-handlers) ; 28 + (cl-pushnew '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) + browse-url-default-handlers)) + ((boundp 'browse-url-browser-function) ; 27 + (require 'browse-url) + (let ((existing browse-url-browser-function)) + (setq browse-url-browser-function + (if (functionp existing) + (lambda (u &rest r) + (apply (if (string-match-p "\\`irc6?s?://" u) + #'erc-compat--29-browse-url-irc + existing) + u r)) + (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) + existing)))))) + (provide 'erc-compat) ;;; erc-compat.el ends here |