Re: bug#56514: 29.0.50; Improve ERC's URI scheme integration for irc:// links

"J.P." <[email protected]>
Newsgroups gmane.emacs.erc.general
Message-ID <[email protected]>
There's been some mention on the tracker recently regarding `func-arity'
and misguided expectations. If it's important to stamp out misuses in
the Emacs tree, then I suppose the one in `url-irc' qualifies. The
attached patch should fix it, I think.

Technically, this bug was introduced in Emacs 29.1, but it's probably
not worth disturbing the release branch over.
0001-Don-t-use-func-arity-to-trigger-API-warning-in-url-i.patch (text/x-patch, 1.7 KB)
From 014a25e9fe8fb3c104d69d8e8cb787bff5e6a8b3 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email protected]>
Date: Sun, 5 Nov 2023 16:03:15 -0800
Subject: [PATCH] Don't use func-arity to trigger API warning in url-irc

* lisp/url/url-irc.el (url-irc): Use more robust `condition-case'
pattern instead, which will still fail when met with various edge
cases.  The old way was only useful for non-variadic lambda lists
consisting entirely of named positional parameters.  (Bug#56514)
---
 lisp/url/url-irc.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/url/url-irc.el b/lisp/url/url-irc.el
index 1463335d40f..e11b4a6a58e 100644
--- a/lisp/url/url-irc.el
+++ b/lisp/url/url-irc.el
@@ -83,18 +83,20 @@ url-irc
 	 (pass (url-password url))
 	 (user (url-user url))
          (chan (url-filename url))
-         (type (url-type url))
-         (compatp (eql 5 (cdr (func-arity url-irc-function)))))
+         (type (url-type url)))
     (if (url-target url)
 	(setq chan (concat chan "#" (url-target url))))
     (if (string-match "^/" chan)
 	(setq chan (substring chan 1 nil)))
     (if (= (length chan) 0)
 	(setq chan nil))
-    (when compatp
-      (lwarn 'url :error "Obsolete value for `url-irc-function'"))
-    (apply url-irc-function
-           host port chan user pass (unless compatp (list type)))
+    (condition-case nil
+        (funcall url-irc-function host port chan user pass type)
+      (wrong-number-of-arguments
+       (display-warning 'url
+                        (concat "Incompatible value for `url-irc-function'."
+                                " Likely not expecting a 6th (SCHEME) arg."))
+       (funcall url-irc-function host port chan user pass)))
     nil))
 
 ;;;; ircs://
-- 
2.41.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.