Subject: bug#8457: closed (Re: bug#8457: 24.0.50; defadvice with BODY referencing args by name: void-var error)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 13 Apr 2011 17:58:01 +0000

Your bug report

#8457: 24.0.50; defadvice with BODY referencing args by name: void-var error

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
8457: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8457
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#8457: 24.0.50; defadvice with BODY referencing args by name: void-var error
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Date: Wed, 13 Apr 2011 14:57:23 -0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Yup.  I think the patch below may fix this problem.

Installed,

        Stefan

Subject: 24.0.50; defadvice with BODY referencing args by name: void-var error
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Sat, 9 Apr 2011 09:45:13 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

(elisp) `Argument Access in Advice' says that you should be able to
access the args using the original names:
 
"The simplest way to access the arguments of an advised function in the
body of a piece of advice is to use the same names that the function
definition uses.  To do this, you need to know the names of the argument
variables of the original function."
 
This should work, and it works prior to the move to lexbind(?), at least.  I
have this defadvice:
 
(defadvice narrow-to-region (before push-wide-n-restrictions activate)
  "Push the region limits to `wide-n-restrictions'.
You can use `C-x n x' to widen to a previous buffer restriction."
  (when (or (interactive-p) wide-n-push-anyway-p)
    (wide-n-push start end)))
 
START and END are the original arg names.  Yes, the doc also says that
this method of referring to args is not the most robust.  Still, it has
worked in general but no longer does.  This is the error:
 
Debugger entered--Lisp error: (void-variable start)
  (wide-n-push start end)
  (progn (wide-n-push start end))
  (if (or (interactive-p) wide-n-push-anyway-p) (progn (wide-n-push start end)))
  (when (or (interactive-p) wide-n-push-anyway-p) (wide-n-push start end))
  (let (ad-return-value) (when (or (interactive-p) wide-n-push-anyway-p)
(wide-n-push start end)) (setq ad-return-value (apply (quote
ad-Orig-narrow-to-region) arg1 arg2 rest)) ad-return-value)
  narrow-to-region(8268 9972)
  call-interactively(narrow-to-region nil nil)
 
Just a guess: this has to do with the move to lexbind.

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-04-04 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/imagesupport/include'