[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 01ed1c6737 1/7: Drop broken func-arity
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 01ed1c6737 1/7: Drop broken func-arity |
Date: |
Wed, 4 Jan 2023 13:57:27 -0500 (EST) |
branch: externals/compat
commit 01ed1c6737b3ab84becc60455a6413a28dfe17e5
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Drop broken func-arity
---
NEWS.org | 3 ++-
compat-26.el | 72 ---------------------------------------------------------
compat-29.el | 5 ++--
compat-tests.el | 11 ---------
compat.texi | 30 ------------------------
5 files changed, 5 insertions(+), 116 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 168caa123e..2483ea99c8 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -14,7 +14,8 @@
- Deprecate all ~compat-*~ prefixed functions. Instead use the aforementioned
~compat-call~ or ~compat-function~ macros.
- Deprecate ~compat-help.el~ and ~compat-font-lock.el~
-- Drop support for Emacs 24.3
+- BREAKING: Drop broken function ~func-arity~
+- BREAKING: Drop support for Emacs 24.3
* Release of "Compat" Version 28.1.2.2
diff --git a/compat-26.el b/compat-26.el
index bd058457a1..1bfe33996c 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -26,78 +26,6 @@
(eval-when-compile (load "compat-macs.el" nil t t))
(compat-declare-version "26.1")
-;;;; Defined in eval.c
-
-(compat-defun func-arity (func) ;; <UNTESTED>
- "Return minimum and maximum number of args allowed for FUNC.
-FUNC must be a function of some kind.
-The returned value is a cons cell (MIN . MAX). MIN is the minimum number
-of args. MAX is the maximum number, or the symbol `many', for a
-function with `&rest' args, or `unevalled' for a special form."
- (cond
- ((or (null func) (and (symbolp func) (not (fboundp func))))
- (signal 'void-function func))
- ((and (symbolp func) (not (null func)))
- (func-arity (symbol-function func)))
- ((eq (car-safe func) 'macro)
- (func-arity (cdr func)))
- ((subrp func)
- (subr-arity func))
- ((memq (car-safe func) '(closure lambda))
- ;; See lambda_arity from eval.c
- (when (eq (car func) 'closure)
- (setq func (cdr func)))
- (let ((syms-left (if (consp func)
- (car func)
- (signal 'invalid-function func)))
- (min-args 0) (max-args 0) optional)
- (catch 'many
- (dolist (next syms-left)
- (cond
- ((not (symbolp next))
- (signal 'invalid-function func))
- ((eq next '&rest)
- (throw 'many (cons min-args 'many)))
- ((eq next '&optional)
- (setq optional t))
- (t (unless optional
- (setq min-args (1+ min-args)))
- (setq max-args (1+ max-args)))))
- (cons min-args max-args))))
- ((and (byte-code-function-p func) (numberp (aref func 0)))
- ;; See get_byte_code_arity from bytecode.c
- (let ((at (aref func 0)))
- (cons (logand at 127)
- (if (= (logand at 128) 0)
- (ash at -8)
- 'many))))
- ((and (byte-code-function-p func) (numberp (aref func 0)))
- ;; See get_byte_code_arity from bytecode.c
- (let ((at (aref func 0)))
- (cons (logand at 127)
- (if (= (logand at 128) 0)
- (ash at -8)
- 'many))))
- ((and (byte-code-function-p func) (listp (aref func 0)))
- ;; Based on `byte-compile-make-args-desc', this is required for
- ;; old versions of Emacs that don't use a integer for the argument
- ;; list description, per e2abe5a13dffb08d6371b6a611bc39c3a9ac2bc6.
- (let ((arglist (aref func 0)) (mandatory 0) nonrest)
- (while (and arglist (not (memq (car arglist) '(&optional &rest))))
- (setq mandatory (1+ mandatory))
- (setq arglist (cdr arglist)))
- (setq nonrest mandatory)
- (when (eq (car arglist) '&optional)
- (setq arglist (cdr arglist))
- (while (and arglist (not (eq (car arglist) '&rest)))
- (setq nonrest (1+ nonrest))
- (setq arglist (cdr arglist))))
- (cons mandatory (if arglist 'many nonrest))))
- ((autoloadp func)
- (autoload-do-load func)
- (func-arity func))
- ((signal 'invalid-function func))))
-
;;;; Defined in fns.c
(compat-defun assoc (key alist &optional testfn) ;; <OK>
diff --git a/compat-29.el b/compat-29.el
index f83ca5b6c4..25ac016f98 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -286,9 +286,10 @@ CONDITION is either:
((stringp condition)
(string-match-p condition (buffer-name buffer)))
((functionp condition)
- (if (eq 1 (cdr (func-arity condition)))
+ (condition-case nil
(funcall condition buffer)
- (funcall condition buffer arg)))
+ (wrong-number-of-arguments
+ (funcall condition buffer arg))))
((eq (car-safe condition) 'major-mode)
(eq
(buffer-local-value 'major-mode buffer)
diff --git a/compat-tests.el b/compat-tests.el
index a78a8c0ad9..43b59836b0 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1693,17 +1693,6 @@
))
(should-not (string-match-p regexp-unmatchable str))))
-(ert-deftest func-arity ()
- (should-equal '(0 . 0) (func-arity (lambda ())))
- (should-equal '(1 . 1) (func-arity (lambda (x) x)))
- (should-equal '(1 . 2) (func-arity (lambda (x &optional _) x)))
- (should-equal '(0 . many) (func-arity (lambda (&rest _))))
- (should-equal '(1 . 1) (func-arity 'identity))
- (should-equal '(0 . many) (func-arity 'ignore))
- (should-equal '(2 . many) (func-arity 'defun))
- (should-equal '(2 . 3) (func-arity 'defalias))
- (should-equal '(1 . unevalled) (func-arity 'defvar)))
-
;; TODO fix broken test
;;(ert-deftest directory-files-recursively
;; (should-equal
diff --git a/compat.texi b/compat.texi
index 827b7e25b8..549f750b6a 100644
--- a/compat.texi
+++ b/compat.texi
@@ -762,36 +762,6 @@ The functions @code{bufferpos-to-filepos} and
The following functions and macros implemented in 26.1, and are provided
by Compat:
-@c copied from lispref/functions.texi
-@defun func-arity function
-This function provides information about the argument list of the
-specified @var{function}. The returned value is a cons cell of the form
-@w{@code{(@var{min} . @var{max})}}, where @var{min} is the minimum
-number of arguments, and @var{max} is either the maximum number of
-arguments, or the symbol @code{many} for functions with @code{&rest}
-arguments, or the symbol @code{unevalled} if @var{function} is a special
-form.
-
-Note that this function might return inaccurate results in some
-situations, such as the following:
-
-@itemize @minus
-@item
-Functions defined using @code{apply-partially} (@pxref{Calling
-Functions,apply-partially,,elisp}).
-
-@item
-Functions that are advised using @code{advice-add} (@pxref{Advising
-Named Functions,,,elisp}).
-
-@item
-Functions that determine the argument list dynamically, as part of their
-code.
-@end itemize
-
-@xref{What Is a Function,,,elisp}.
-@end defun
-
@c copied from lispref/functions.texi
@defun mapcan function sequence
This function applies @var{function} to each element of @var{sequence},
- [elpa] externals/compat updated (8144719780 -> f0362f354c), ELPA Syncer, 2023/01/04
- [elpa] externals/compat 8ab4272a5d 5/7: Add thread-first and thread-last tests, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 9257871cb0 3/7: Test take and ntake, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 01ed1c6737 1/7: Drop broken func-arity,
ELPA Syncer <=
- [elpa] externals/compat f0362f354c 7/7: Warn about untested functions, ELPA Syncer, 2023/01/04
- [elpa] externals/compat fc2ad0899d 6/7: Test buffer-local-boundp, ELPA Syncer, 2023/01/04
- [elpa] externals/compat b126fd50df 2/7: Mark a few functions as tested, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 1d25236892 4/7: Use with-eval-after-load (24.4), ELPA Syncer, 2023/01/04