[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nadvice d19e9ae649: * nadvice.el (advice-add): Fix bug
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nadvice d19e9ae649: * nadvice.el (advice-add): Fix bug with empty arglists and :around |
Date: |
Wed, 11 Jan 2023 10:45:42 -0500 (EST) |
branch: externals/nadvice
commit d19e9ae649374a0f2fab1baa045ed192e0851750
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* nadvice.el (advice-add): Fix bug with empty arglists and :around
---
nadvice.el | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/nadvice.el b/nadvice.el
index 58523f69a2..512843e3b5 100644
--- a/nadvice.el
+++ b/nadvice.el
@@ -1,9 +1,9 @@
-;;; nadvice.el --- Forward compatibility for Emacs-24.4's nadvice
+;;; nadvice.el --- Forward compatibility for Emacs-24.4's nadvice -*-
lexical-binding: t; -*-
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2023 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
-;; Version: 0.3
+;; Version: 0.4
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,11 @@
;; It was tested on Emacs-22 and I can't see any obvious reason why it
;; wouldn't work on older Emacsen.
+;;; News:
+
+;; Since 0.3:
+;; - Fix a bug when advising functions that do not take arguments.
+
;;; Code:
(declare-function ad-remove-advice "advice")
@@ -73,9 +78,15 @@
ad-do-it)
(ad-get-args 0))))
(t (error "This version of nadvice.el does not handle %S"
- where)))))
+ where))))
+ ;; FIXME: Ideally the arglist here should just be nil,
+ ;; so that we reuse the original function's arglist, but
+ ;; if that original arglist is also nil, then we bump into a bug
+ ;; where (ad-set-args 0 nadvice--rest-arg) signals
+ ;; (error "ad-set-arguments: No argument at position 0 of `nil'")
+ (arglist (if (eq where :around) '(&rest _))))
(ad-add-advice symbol
- `(,function nil t (advice lambda () ,body))
+ `(,function nil t (advice lambda ,arglist ,body))
'around
nil)
(ad-activate symbol)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/nadvice d19e9ae649: * nadvice.el (advice-add): Fix bug with empty arglists and :around,
Stefan Monnier <=