Subject: Re: bug#23781: 25.0.95; read-string with HIST lexically bound

From: Noam Postavsky <[email-masked]>
Date: Sat, 25 Jun 2016 23:34:43 -0400

On Sat, Jun 25, 2016 at 7:42 PM, Michael Heerdegen
<[email-masked]> wrote:
> Stephen Berman <[email-masked]> writes:
>
>> >  Also, the code in the body of a ‘defun’ or
>> >  ‘defmacro’ cannot refer to surrounding lexical variables.
>
>
> This seems a bit unclear to me.  It sounds like something like this
> would not work:
>
> ;; -*- lexical-binding: t -*-
> (let ((x 1))
>   (defun f () x))
>
> (f) ==> 1

That's indeed what it meant, but this restriction was lifted sometime
after 24.1, see
http://help-gnu-emacs.gnu.narkive.com/uspqRdsq/surrounding-lexical-variable-reference-in-the-body-of-defun
and http://stackoverflow.com/questions/12026137/emacs-the-code-in-the-body-of-a-defun-or-defmacro-cannot-refer-to-surrounding-l.
Updated patch to remove that sentence.
From 3f08a8a535e8fb5dced8bf1474659244ed358125 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Sat, 25 Jun 2016 16:23:04 -0400
Subject: [PATCH v2] Add to elisp-completion-at-point's docstring

* lisp/progmodes/elisp-mode.el (elisp-completion-at-point): Document
position dependent behavior.  Remove mention of obsolete restriction
regarding lexical binding for defun and defmacro, this no longer applies
since 61b108cc 2012-05-29 "* lisp/emacs-lisp/byte-run.el (defmacro,
defun): Move from C..." (Bug #19854).
---
 doc/lispref/variables.texi   | 3 +--
 lisp/progmodes/elisp-mode.el | 6 +++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index b4d6857..a2d6481 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1038,8 +1038,7 @@ Lexical Binding
 functions which take a symbol argument (like @code{symbol-value},
 @code{boundp}, and @code{set}) can only retrieve or modify a
 variable's dynamic binding (i.e., the contents of its symbol's value
-cell).  Also, the code in the body of a @code{defun} or
-@code{defmacro} cannot refer to surrounding lexical variables.
+cell).
 
 @node Using Lexical Binding
 @subsection Using Lexical Binding
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 7ad8871..850ebb4 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -455,7 +455,11 @@ elisp--company-location
      ((facep sym) (find-definition-noselect sym 'defface)))))
 
 (defun elisp-completion-at-point ()
-  "Function used for `completion-at-point-functions' in `emacs-lisp-mode'."
+  "Function used for `completion-at-point-functions' in `emacs-lisp-mode'.
+The returned completions depend on whether point is in a function
+or variable position; in positions where both are
+possible (e.g. quoted symbols), functions are annotated with
+\"<f>\" via the `:annotation-function' property."
   (with-syntax-table emacs-lisp-mode-syntax-table
     (let* ((pos (point))
 	   (beg (condition-case nil
-- 
2.8.0