branch: externals/compat commit eb0c027a33d1eaaa1bad112e7840d3f44dfe7f82 Author: Philip Kaludercic <phil...@posteo.net> Commit: Philip Kaludercic <phil...@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