Subject: bug#12528: closed (Re: bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 28 Sep 2012 07:43:02 +0000

Your bug report

#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list

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].

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

Subject: Re: bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
From: Glenn Morris <[email-masked]>
To: [email-masked]
Date: Fri, 28 Sep 2012 03:41:52 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 24.3

Installed something to trunk that hopefully fixes this.

Subject: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
From: Changa Imara <[email-masked]>
To: [email-masked]
Date: Thu, 27 Sep 2012 13:44:22 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

I'm attempting to run the following script:
===start script===
#!/usr/local/bin/emacs --script
;;; -*- lexical-binding: t -*-

(defun foo ()
  (setq x 100))

(defun bar ()
  (let ((x 0))
    (foo)
    x))

(message "%d" (bar))  ; would expect x to still be 0 here
===end script===

With lexical binding enabled the script should return 0. Otherwise it
will return 100. However, when set to be executable and run from the
shell with a command like
"./lexical-binding-test.el", emacs fails to use lexial-binding.

According to the manual: "In shell scripts, the first line is used to
identify the script interpreter, so you cannot put any local variables
there. To accommodate this, Emacs looks for local variable
specifications in the second line if the first line specifies an
interpreter. " This does not seem to be the case.

I also tried setting lexical-bindings using a file local variable list.
This doesn't seem to work either.

In GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2012-08-27 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1138
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.5''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  hi-lock-mode: t
  recentf-mode: t
  eldoc-mode: t
  elisp-slime-nav-mode: t
  paredit-mode: t
  hl-line-mode: t
  idle-highlight-mode: t
  ido-ubiquitous-mode: t
  show-paren-mode: t
  global-linum-mode: t
  linum-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Features:
(shadow sort flyspell ispell mail-extr emacsbug message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail tramp-cache tramp tramp-compat format-spec tramp-loaddefs debug
shell pcomplete comint regexp-opt ansi-color pp lisp-mnt misearch
multi-isearch mule-util parse-time mail-utils network-stream starttls
url-cache url-http tls mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
url-gw url-auth url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-util url-parse auth-source eieio byte-opt
bytecomp byte-compile cconv macroexp assoc gnus-util password-cache
url-vars mm-util mail-prsvr mailcap finder-inf hi-lock newcomment
files-x recentf tree-widget wid-edit eldoc elisp-slime-nav etags ring
paredit hl-line saveplace idle-highlight-mode thingatpt yasnippet
help-mode view cl htmlize-autoloads starter-kit-lisp-autoloads
elisp-slime-nav-autoloads starter-kit-autoloads edmacro kmacro smex
starter-kit-misc ido-ubiquitous ido paren starter-kit-defuns uniquify
advice help-fns advice-preload magit-autoloads info easymenu
ido-ubiquitous-autoloads smex-autoloads find-file-in-project-autoloads
idle-highlight-mode-autoloads paredit-autoloads yasnippet-autoloads
package tabulated-list linum time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)