emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat eb0c027 26/99: Advise indirect-function to not r


From: ELPA Syncer
Subject: [elpa] externals/compat eb0c027 26/99: Advise indirect-function to not raise void-function
Date: Sun, 17 Oct 2021 05:57:51 -0400 (EDT)

branch: externals/compat
commit eb0c027a33d1eaaa1bad112e7840d3f44dfe7f82
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Advise indirect-function to not raise void-function
---
 compat-25.1.el  |  8 ++++++++
 compat-tests.el | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/compat-25.1.el b/compat-25.1.el
index 100e578..67534b7 100644
--- a/compat-25.1.el
+++ b/compat-25.1.el
@@ -66,6 +66,14 @@ This implementation is equivalent to `format'."
             ?\\ ?/))
       (aref name (1- (length name)))))
 
+;;;; Defined in data.c
+
+(compat-advise indirect-function (object)
+  "Prevent `void-function' from being signalled."
+  (condition-case nil
+      (funcall oldfun object)
+    (void-function nil)))
+
 ;;;; Defined in subr.el
 
 (compat-defun string-greaterp (string1 string2)
diff --git a/compat-tests.el b/compat-tests.el
index b179cfa..ce5fe8b 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1245,5 +1245,22 @@ the compatibility function."
     (compat--should t "dir/subdir/")
     (compat--should nil "dir/subdir")))
 
+(ert-deftest compat-indirect-function ()
+  "Check if `indirect-function' was advised properly."
+  (compat-test indirect-function
+    ;; A symbol with a function alias should return the function it is
+    ;; aliasing:
+    (compat--should* (indirect-function #'process-send-string)
+                     'send-string)
+    (compat--should* (indirect-function #'string-equal)
+                     'string=)
+    ;; A function should return it self when not aliased:
+    (compat--should* (indirect-function #'string-equal) 'string-equal)
+    ;; A fresh symbol should return nil when no function is associated
+    ;; with it:
+    (compat--should* nil (make-symbol "foobar"))
+    ;; Anything else is return as is:
+    (compat--should* "foobar" "foobar")))
+
 (provide 'compat-tests)
 ;;; compat-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]