all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#61707: Remove function-alias-p NOERROR argument
@ 2023-02-22 13:44 Mattias Engdegård
  2023-02-22 14:13 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Mattias Engdegård @ 2023-02-22 13:44 UTC (permalink / raw)
  To: 61707; +Cc: Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

`function-alias-p` is new in Emacs 29, and takes an optional NOERROR argument which has become entirely useless in Emacs 30 where it is only present for compatibility.

Given that the NOERROR argument is not very useful in Emacs 29 either, what about removing it in that version as well? After all, rather silly to introduce something that's known to go away the next release.

Proposed patch attached.


[-- Attachment #2: 0001-Remove-function-alias-p-noerror-argument.patch --]
[-- Type: application/octet-stream, Size: 4787 bytes --]

From 5ae6be9543f2ea72db303a611bd9a97c6a0df974 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Tue, 21 Feb 2023 15:18:53 +0100
Subject: [PATCH] Remove function-alias-p noerror argument

The `noerror` argument isn't actually needed, and since it's already
been made obsolete in Emacs 30 there is no point in adding it in the
first place.

* doc/lispref/functions.texi (Defining Functions): Update manual.
* lisp/help-fns.el (help-fns--analyze-function): Remove only use.
* lisp/subr.el (function-alias-p): Remove argument.
* test/lisp/help-fns-tests.el (help-fns--analyze-function-recursive):
* test/lisp/subr-tests.el (test-alias-p): Adapt tests.
---
 doc/lispref/functions.texi  | 6 ++----
 lisp/help-fns.el            | 3 ++-
 lisp/subr.el                | 8 +++-----
 test/lisp/help-fns-tests.el | 2 +-
 test/lisp/subr-tests.el     | 4 +---
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index f5572e447d3..3351cadf431 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -739,7 +739,7 @@ Defining Functions
 records.  @xref{Function Cells}.
 @end defun
 
-@defun function-alias-p object &optional noerror
+@defun function-alias-p object
 Checks whether @var{object} is a function alias.  If it is, it returns
 a list of symbols representing the function alias chain, else
 @code{nil}.  For instance, if @code{a} is an alias for @code{b}, and
@@ -750,9 +750,7 @@ Defining Functions
     @result{} (b c)
 @end example
 
-If there's a loop in the definitions, an error will be signaled.  If
-@var{noerror} is non-@code{nil}, the non-looping parts of the chain is
-returned instead.
+If there's a loop in the definitions, an error will be signaled.
 @end defun
 
   You cannot create a new primitive function with @code{defun} or
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a81051cee03..0d6ae7501ec 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -996,7 +996,8 @@ help-fns--analyze-function
                                               (symbol-name function)))))))
 	 (real-def (cond
                     ((and aliased (not (subrp def)))
-                     (car (function-alias-p real-function t)))
+                     (car (ignore-error cyclic-function-indirection
+                            (function-alias-p real-function))))
 		    ((subrp def) (intern (subr-name def)))
                     (t def))))
 
diff --git a/lisp/subr.el b/lisp/subr.el
index a0a22072a18..fb9ee2e7192 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6962,12 +6962,12 @@ with-delayed-message
                                  (lambda ()
                                    ,@body)))
 
-(defun function-alias-p (func &optional noerror)
+(defun function-alias-p (func)
   "Return nil if FUNC is not a function alias.
 If FUNC is a function alias, return the function alias chain.
 
 If the function alias chain contains loops, an error will be
-signaled.  If NOERROR, the non-loop parts of the chain is returned."
+signaled."
   (declare (side-effect-free t))
   (let ((chain nil)
         (orig-func func))
@@ -6978,9 +6978,7 @@ function-alias-p
                    (symbolp func))
          (when (or (memq func chain)
                    (eq func orig-func))
-           (if noerror
-               (throw 'loop chain)
-             (signal 'cyclic-function-indirection (list orig-func))))
+           (signal 'cyclic-function-indirection (list orig-func)))
          (push func chain))
        chain))))
 
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index 4d715cde1d5..85ddab47479 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -185,6 +185,6 @@ help-fns--analyze-function-recursive
   ;; Make a loop and see that it doesn't infloop.
   (defalias 'help-fns--b 'help-fns--a)
   (should (equal (help-fns--analyze-function 'help-fns--a)
-                 '(help-fns--a help-fns--b t help-fns--b))))
+                 '(help-fns--a help-fns--b t nil))))
 
 ;;; help-fns-tests.el ends here
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 1abd3be4ea1..37f4277f962 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1059,9 +1059,7 @@ test-alias-p
 
   (defalias 'subr-tests--d 'subr-tests--e)
   (defalias 'subr-tests--e 'subr-tests--d)
-  (should-error (function-alias-p 'subr-tests--d))
-  (should (equal (function-alias-p 'subr-tests--d t)
-                 '(subr-tests--e))))
+  (should-error (function-alias-p 'subr-tests--d)))
 
 (ert-deftest test-readablep ()
   (should (readablep "foo"))
-- 
2.32.0 (Apple Git-132)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#61707: Remove function-alias-p NOERROR argument
  2023-02-22 13:44 bug#61707: Remove function-alias-p NOERROR argument Mattias Engdegård
@ 2023-02-22 14:13 ` Eli Zaretskii
  2023-02-22 15:26   ` Lars Ingebrigtsen
  2023-02-22 16:43   ` Mattias Engdegård
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2023-02-22 14:13 UTC (permalink / raw)
  To: Mattias Engdegård, Lars Ingebrigtsen; +Cc: 61707

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Wed, 22 Feb 2023 14:44:21 +0100
> Cc: Eli Zaretskii <eliz@gnu.org>
> 
> `function-alias-p` is new in Emacs 29, and takes an optional NOERROR argument which has become entirely useless in Emacs 30 where it is only present for compatibility.
> 
> Given that the NOERROR argument is not very useful in Emacs 29 either, what about removing it in that version as well? After all, rather silly to introduce something that's known to go away the next release.
> 
> Proposed patch attached.

Lars added this function, so it would be prudent to ask him.

My opinion is that it's too late for such changes: this function is
with us for more than a year, so I guess we will have to live with
optional argument even if it's useless in Emacs 30 and later.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#61707: Remove function-alias-p NOERROR argument
  2023-02-22 14:13 ` Eli Zaretskii
@ 2023-02-22 15:26   ` Lars Ingebrigtsen
  2023-02-22 16:43   ` Mattias Engdegård
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2023-02-22 15:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: mattias.engdegard, 61707

Eli Zaretskii <eliz@gnu.org> writes:

> Lars added this function, so it would be prudent to ask him.
>
> My opinion is that it's too late for such changes: this function is
> with us for more than a year, so I guess we will have to live with
> optional argument even if it's useless in Emacs 30 and later.

I agree with Eli.

(The optional argument has been made obsolete in Emacs 30, so it can be
removed in Emacs 33-ish.)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#61707: Remove function-alias-p NOERROR argument
  2023-02-22 14:13 ` Eli Zaretskii
  2023-02-22 15:26   ` Lars Ingebrigtsen
@ 2023-02-22 16:43   ` Mattias Engdegård
  1 sibling, 0 replies; 4+ messages in thread
From: Mattias Engdegård @ 2023-02-22 16:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 61707-done

22 feb. 2023 kl. 15.13 skrev Eli Zaretskii <eliz@gnu.org>:

> My opinion is that it's too late for such changes

Reasonable people may disagree, but I won't insist. Closing bug.






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-22 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 13:44 bug#61707: Remove function-alias-p NOERROR argument Mattias Engdegård
2023-02-22 14:13 ` Eli Zaretskii
2023-02-22 15:26   ` Lars Ingebrigtsen
2023-02-22 16:43   ` Mattias Engdegård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.