Function: elisp-enable-lexical-binding

elisp-enable-lexical-binding is an interactive and byte-compiled function defined in elisp-mode.el.gz.

Signature

(elisp-enable-lexical-binding &optional INTERACTIVE)

Documentation

Make the current buffer use lexical-binding.

INTERACTIVE non-nil means ask the user for confirmation; this happens in interactive invocations.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
(defun elisp-enable-lexical-binding (&optional interactive)
  "Make the current buffer use `lexical-binding'.
INTERACTIVE non-nil means ask the user for confirmation; this
happens in interactive invocations."
  (interactive "p")
  (if (and (local-variable-p 'lexical-binding) lexical-binding)
      (when interactive
        (message "lexical-binding already enabled!")
        (ding))
    (when (or (not interactive)
              (y-or-n-p (format "Enable lexical-binding in this %s? "
                                (if buffer-file-name "file" "buffer"))))
      (setq-local lexical-binding t)
      (add-file-local-variable-prop-line 'lexical-binding t interactive))))