unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 30078@debbugs.gnu.org
Subject: bug#30078: 27.0.50; Use lexical-binding for M-:
Date: Fri, 12 Jan 2018 13:47:07 -0500	[thread overview]
Message-ID: <jwvbmhznddy.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <871sivf0tl.fsf@web.de> (Michael Heerdegen's message of "Fri, 12 Jan 2018 18:23:34 +0100")

> Don't you also want to change this occurrence in `command-line'?
>
> #+begin_src emacs-lisp
>   ;; If *scratch* exists and init file didn't change its mode, initialize it.
>   (if (get-buffer "*scratch*")
>       (with-current-buffer "*scratch*"
> 	(if (eq major-mode 'fundamental-mode)
> 	    (funcall initial-major-mode))))
> #+end_src

Ah, so that's where it is, thanks.

> So far, lexical-binding in *scratch* is nil with emacs -Q with your
> patch.

That's what I was seeing as well, indeed :-(

> Maybe also check that evaluating the expression `lexical-binding'
> returns a result that is consistent with the evaluation behavior.

I already know that the check will fail.  Is it important?

In general the value of the variable lexical-binding during evaluation
of the code is not directly related to whether the code is evaluated
using lexical rules or not.  Within macros, Emacs tries to make sure
that lexical-binding reflects whether the code returned by the macro
will use lexical scoping or not (so that the macro can adjust the code
it generates accordingly), but other than that, the two are
largely independent (which is why (setq lexical-binding t) is not the
right way to enable lexical scoping in a file).

> In particular, evaluating lexical-binding in M-x ielm RET still gives
> nil - that's confusing.

Right (well, it doesn't always give you nil: it depends on the value of
lexical-binding in the buffer currently selected to evaluate the IELM
expressions).
But this discrepancy also shows up in various other contexts.  Eg.:

    ;; -*- lexical-binding:t -*-
    (defun my-test ()
      (interactive)
      (message "%S" lexical-binding))

will give you a lexically scoped command which will tell you the value
of lexical-binding at the time&place you run the command, which will
sometimes be t and sometimes not.

I'm not sure we should try to encourage the user to think a piece of
code can check the value of `lexical-binding` to know if it's being
evaluated using lexical scoping rules.


        Stefan





  reply	other threads:[~2018-01-12 18:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 16:36 bug#30078: 27.0.50; Use lexical-binding for M-: Stefan Monnier
2018-01-11 20:58 ` Michael Heerdegen
2018-01-12 14:58   ` Stefan Monnier
2018-01-12 16:12     ` Stefan Monnier
2018-01-12 16:53       ` Glenn Morris
2018-01-12 17:23       ` Michael Heerdegen
2018-01-12 18:47         ` Stefan Monnier [this message]
2018-01-12 19:35           ` Michael Heerdegen
2018-01-13 17:58             ` Stefan Monnier
2018-01-12 18:34       ` Eli Zaretskii
2018-01-12 18:49         ` Stefan Monnier
2018-01-12 18:55           ` Eli Zaretskii
2018-01-12 19:06             ` Stefan Monnier
2018-01-12 20:03               ` Eli Zaretskii
2018-01-12 20:33                 ` Noam Postavsky
2018-01-12 20:55                 ` Michael Heerdegen
2018-01-12 21:04                   ` Eli Zaretskii
2018-01-12 21:11                     ` Michael Heerdegen
2018-01-13 17:50                       ` Luis Gerhorst
2018-01-13 19:48                         ` Eli Zaretskii
2018-01-13 20:19                           ` Luis Gerhorst
2018-01-14  5:58                           ` Robert Cochran
2018-01-13 18:19                     ` Stefan Monnier
2018-01-13 19:34                       ` Eli Zaretskii
2018-01-13 21:58                         ` Stefan Monnier
2018-01-13 23:18                       ` Richard Stallman
2018-01-14  2:07                       ` Drew Adams
2018-01-15  2:34                         ` Richard Stallman
2018-01-13 18:05                 ` Stefan Monnier
2018-01-13 19:37                   ` Eli Zaretskii
2018-03-19 19:32       ` Stefan Monnier
2018-03-19 19:34         ` Stefan Monnier
2018-03-19 20:10         ` Eli Zaretskii
2018-03-19 20:50           ` Stefan Monnier
2018-03-20  6:59             ` Eli Zaretskii
2018-03-20 19:20               ` Stefan Monnier
2018-04-02 19:40                 ` Richard Stallman
2018-04-03  0:12                   ` Stefan Monnier
2018-04-03 16:50                     ` Richard Stallman
     [not found] <mailman.7210.1515688689.27995.bug-gnu-emacs@gnu.org>
2018-01-12 16:28 ` nazienham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbmhznddy.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=30078@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).