[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 3082209 4/4: Move require advice to compat-25.1
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 3082209 4/4: Move require advice to compat-25.1 |
Date: |
Sun, 24 Oct 2021 13:57:12 -0400 (EDT) |
branch: externals/compat
commit 3082209c30a4ebb08b8229c81eaedaf9b8c142a5
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Move require advice to compat-25.1
As currently the only feature that depends on the require advice is
subr-x, and that specifically on version 24.x, we can avoid advising
require in all other cases.
Thank you to Stefan Monnier for pointing this out.
---
compat-25.1.el | 13 +++++++++++++
compat-macs.el | 10 ++++------
compat.el | 22 ----------------------
3 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/compat-25.1.el b/compat-25.1.el
index 5a4183e..b381fd8 100644
--- a/compat-25.1.el
+++ b/compat-25.1.el
@@ -112,6 +112,19 @@ Equality with KEY is tested by TESTFN, defaulting to `eq'."
;;;; Defined in subr-x.el
+(compat-advise require (feature &rest args)
+ "Allow for Emacs 24.x to require the inexistent FEATURE subr-x."
+ ;; As the compatibility advise around `require` is more a hack than
+ ;; of of actual value, the highlighting is suppressed.
+ :no-highlight t
+ :max-version "24.5"
+ (if (eq 'feature 'subr-x)
+ (let ((entry (assq feature after-load-alist)))
+ (let ((load-file-name nil))
+ (dolist (form (cdr entry))
+ (funcall (eval form t)))))
+ (apply oldfun feature args)))
+
(compat-defmacro if-let* (varlist then &rest else)
"Bind variables according to VARLIST and evaluate THEN or ELSE.
This is like `if-let' but doesn't handle a VARLIST of the form
diff --git a/compat-macs.el b/compat-macs.el
index f8d0c65..a479bff 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -102,12 +102,10 @@ TYPE is used to set the symbol property `compat-type' for
NAME."
(put ',realname 'compat-version ,version)
,(funcall def-fn realname version)
,(if feature
- `(progn
- (put ',feature 'setup-deferred-p t)
- ;; Warning: This might be able throw an error if the code
- ;; is not byte compiled, as explained in:
- ;; https://nullprogram.com/blog/2018/02/22/.
- (eval-after-load ',feature (lambda () ,body)))
+ ;; Warning: This might be able throw an error if the code
+ ;; is not byte compiled, as explained in:
+ ;; https://nullprogram.com/blog/2018/02/22/.
+ `(eval-after-load ',feature (lambda () ,body))
body))))
(defun compat-common-fdefine (type name arglist docstring rest)
diff --git a/compat.el b/compat.el
index 79a2c92..b2f56ee 100644
--- a/compat.el
+++ b/compat.el
@@ -141,28 +141,6 @@ advice."
(not (eq (cdr (compat-func-arity func t)) n))
(void-function t))))
-;; Suppress errors triggered by requiring non-existent libraries in
-;; older versions of Emacs (e.g. subr-x).
-(compat-advise require (feature &optional filename noerror)
- "Avoid throwing an error if library has compatibility code."
- ;; As the compatibility advise around `require` is more a hack than
- ;; of of actual value, the highlighting is suppressed.
- :no-highlight t
- (condition-case err
- (funcall oldfun feature filename)
- (file-missing
- (let ((entry (assq feature after-load-alist)))
- (when (and entry
- (get feature 'setup-deferred-p)
- (null noerror))
- (signal (car err) (cdr err)))
- (let ((load-file-name nil))
- (dolist (form (cdr entry))
- (funcall (eval form t))))))
- (error
- (unless noerror
- (signal (car err) (cdr err))))))
-
;; Load the actual compatibility definitions:
(require 'compat-24.4)
(require 'compat-25.1)