From 7133f262bbd818509825a3317c91e91e62bd56fb Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 3 Mar 2015 14:23:49 -0500 Subject: [PATCH] * lisp/progmodes/gud.el: Use lexical-binding. Fixes: debbugs:19966 * lisp/emacs-lisp/gv.el (gv-ref): Warn about likely problematic cases. --- lisp/ChangeLog | 10 ++++++++-- lisp/emacs-lisp/gv.el | 17 ++++++++++++++--- lisp/progmodes/gud.el | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 63071734cf8..0cfe8eed02a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-03 Stefan Monnier + + * progmodes/gud.el: Use lexical-binding (bug#19966). + + * emacs-lisp/gv.el (gv-ref): Warn about likely problematic cases. + 2015-03-03 Daniel Colascione * emacs-lisp/generator.el: Make globals conform to elisp @@ -6,8 +12,8 @@ `cps-disable-atomic-optimization'. (cps--gensym): New macro; replaces `cl-gensym' throughout. (cps-generate-evaluator): Move the `iter-yield' local macro - definition here - (iter-defun, iter-lambda): from here. + definition here... + (iter-defun, iter-lambda): ...from here. 2015-03-03 Artur Malabarba diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 5d6e6e1b372..fae3bcb86f6 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -493,9 +493,20 @@ This is like the `&' operator of the C language. Note: this only works reliably with lexical binding mode, except for very simple PLACEs such as (function-symbol 'foo) which will also work in dynamic binding mode." - (gv-letplace (getter setter) place - `(cons (lambda () ,getter) - (lambda (gv--val) ,(funcall setter 'gv--val))))) + (let ((code + (gv-letplace (getter setter) place + `(cons (lambda () ,getter) + (lambda (gv--val) ,(funcall setter 'gv--val)))))) + (if (or lexical-binding + ;; If `code' still starts with `cons' then presumably gv-letplace + ;; did not add any new let-bindings, so the `lambda's don't capture + ;; any new variables. As a consequence, the code probably works in + ;; dynamic binding mode as well. + (eq (car-safe code) 'cons)) + code + (macroexp--warn-and-return + "Use of gv-ref probably requires lexical-binding" + code)))) (defsubst gv-deref (ref) "Dereference REF, returning the referenced value. diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 42c5b20a7b8..29a6dc63a68 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -1,4 +1,4 @@ -;;; gud.el --- Grand Unified Debugger mode for running GDB and other debuggers +;;; gud.el --- Grand Unified Debugger mode for running GDB and other debuggers -*- lexical-binding:t -*- ;; Copyright (C) 1992-1996, 1998, 2000-2015 Free Software Foundation, ;; Inc. -- 2.39.2