File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,18 @@ Since 1.2."
190190 (when , fn
191191 (remove-hook 'kill-emacs-hook , fn ))))))
192192
193+ ; ; May later make public, like `eldev-advised' . For now only on usecase.
194+ (defmacro eldev--ensure-function (function if-missing &rest body )
195+ (declare (indent 2 ) (debug (symbolp sexp body)))
196+ (let ((present (make-symbol " $present" )))
197+ `(let ((, present (fboundp ', function )))
198+ (unless , present
199+ (fset ', function , if-missing ))
200+ (unwind-protect
201+ ,(macroexp-progn body)
202+ (unless , present
203+ (fmakunbound ', function ))))))
204+
193205
194206(defsubst eldev-listify (x )
195207 " Make a list out of X.
Original file line number Diff line number Diff line change @@ -2801,7 +2801,11 @@ Since 0.2."
28012801 (when (and flag (not (file-symlink-p filename)))
28022802 (setf flag nil))
28032803 (funcall original filename mode flag))))
2804- (package-install-from-archive dependency)))
2804+ ;; GNU ELPA (e.g. in March 2025) itself provides packages that are not installable on older
2805+ ;; Emacs versions because those lack `lisp-data-mode' and the mode is referred to in
2806+ ;; e.g. `dash-pkg.el'. Work around by temporarily providing a dummy function with that name.
2807+ (eldev--ensure-function lisp-data-mode (lambda ())
2808+ (package-install-from-archive dependency))))
28052809 (when (eq dependency-name 'eldev)
28062810 ;; Reload the current package again, so that we
28072811 ;; don't mix old and new function invocations.
Original file line number Diff line number Diff line change 5353 ; ; And only now gone completely.
5454 (should (equal (eldev--test-internals-inc 5 ) 6 )))
5555
56+ (ert-deftest eldev--ensure-function ()
57+ (let ((have-lisp-data-mode (fboundp 'lisp-data-mode )))
58+ (eldev--ensure-function lisp-data-mode (lambda ())
59+ (should (fboundp 'lisp-data-mode )))
60+ (should (eq (fboundp 'lisp-data-mode ) have-lisp-data-mode))))
61+
5662
5763(defmacro eldev--test-target-dependencies (&rest body )
5864 (declare (indent 0 ))
You can’t perform that action at this time.
0 commit comments