]> git.eshelyaron.com Git - emacs.git/commitdiff
Retract lexical cookie source load warning
authorMattias EngdegÄrd <mattiase@acm.org>
Sat, 4 May 2024 14:18:09 +0000 (16:18 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:53:12 +0000 (18:53 +0200)
On balance it seems likely that the warning would annoy more people than
it would help, so let them deal with any actual problems when the
default is changed instead.  See discussion at:
https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg00250.html

* src/lread.c (string_suffix_p, warn_missing_cookie, Fload)
(Feval_buffer):
* lisp/international/mule.el (load-with-code-conversion):
* lisp/startup.el (command-line--load-script):
* etc/NEWS:
Revert all changes, except for the generalised
`lisp_file_lexical_cookie` which may prove useful in the future.

(cherry picked from commit d51de0c5d90117bc1dc4bc5bc700253d71cd4579)

etc/NEWS
lisp/international/mule.el
lisp/startup.el
src/lread.c

index 69dbc6321076d3dc7b128f179dda17bdb1dcc152..ec79aa873e916eaa68b2f959e06d1fe4203ac7df 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2585,15 +2585,6 @@ The warning name is 'docstrings-control-chars'.
 *** The warning about wide docstrings can now be disabled separately.
 Its warning name is 'docstrings-wide'.
 
----
-** Warn about missing 'lexical-binding' directive when loading .el files.
-Emacs now emits a run-time warning if an Elisp source file being loaded
-lacks the '-*- lexical-binding: ... -*-' cookie on the first line.
-See the lexical-binding compiler warning described above for how to make
-the warning go away by adding a declaration to the file.  You can also
-suppress the warning by adding an entry for the warning type
-'lexical-warning' to 'warning-suppress-types'.
-
 ---
 ** New user option 'native-comp-async-warnings-errors-kind'.
 It allows control of what kinds of warnings and errors from asynchronous
index 8875c4f06afc55c61a26475e6286a5f69671de9a..a17221e6d2165655889f06e4ba0a88221c675ec4 100644 (file)
@@ -367,7 +367,7 @@ Return t if file exists."
                 (eval-buffer buffer nil
                             ;; This is compatible with what `load' does.
                              (if dump-mode file fullname)
-                            nil t t))))
+                            nil t))))
        (let (kill-buffer-hook kill-buffer-query-functions)
          (kill-buffer buffer)))
       (do-after-load-evaluation fullname)
index f2532f5254e3f0e4027aa9080c09cf790b786e4a..357a4154e4c870ab5cae4b99dd19ba6b09ffa71d 100644 (file)
@@ -2935,7 +2935,7 @@ nil default-directory" name)
        ;; buffer is empty.
        (when (looking-at "#!")
          (delete-line))
-       (eval-buffer buffer nil file nil t t)))))
+       (eval-buffer buffer nil file nil t)))))
 
 (defun command-line--eval-script (file)
   (load-with-code-conversion
index ba890cb673d3da0dd8e8293071e08b538eceb3da..7806c3972eec6fa5e91ca8fa917088e7229efb80 100644 (file)
@@ -1342,37 +1342,6 @@ close_file_unwind_android_fd (void *ptr)
 
 #endif
 
-static bool
-string_suffix_p (const char *string, ptrdiff_t string_len,
-                const char *suffix, ptrdiff_t suffix_len)
-{
-  return string_len >= suffix_len && memcmp (string + string_len - suffix_len,
-                                            suffix, suffix_len) == 0;
-}
-
-static void
-warn_missing_cookie (Lisp_Object file)
-{
-  /* Only warn for files whose name end in .el, to suppress loading of
-     data-as-code.  ".emacs" is an exception, since it does tend to contain
-     actual hand-written code.  */
-  if (!STRINGP (file))
-    return;
-  const char *name = SSDATA (file);
-  ptrdiff_t nb = SBYTES (file);
-  if (!(string_suffix_p (name, nb, ".el", 3)
-       || (string_suffix_p (name, nb, ".emacs", 6)
-           && (nb == 6 || SREF (file, nb - 7) == '/'))))
-    return;
-
-  Lisp_Object msg = CALLN (Fformat,
-                          build_string ("File %s lacks `lexical-binding'"
-                                        " directive on its first line"),
-                          file);
-  Vdelayed_warnings_list = Fcons (list2 (Qlexical_binding, msg),
-                                 Vdelayed_warnings_list);
-}
-
 DEFUN ("load", Fload, Sload, 1, 5, 0,
        doc: /* Execute a file of Lisp code named FILE.
 First try FILE with `.elc' appended, then try with `.el', then try
@@ -1822,10 +1791,7 @@ Return t if the file exists and loads successfully.  */)
     }
   else
     {
-      lexical_cookie_t lc = lisp_file_lexical_cookie (Qget_file_char);
-      if (lc == Cookie_None && !compiled)
-       warn_missing_cookie (file);
-      if (lc == Cookie_Lex)
+      if (lisp_file_lexical_cookie (Qget_file_char) == Cookie_Lex)
         Fset (Qlexical_binding, Qt);
 
       if (! version || version >= 22)
@@ -2658,7 +2624,7 @@ readevalloop (Lisp_Object readcharfun,
   unbind_to (count, Qnil);
 }
 
-DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0,6, "",
+DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "",
        doc: /* Execute the accessible portion of current buffer as Lisp code.
 You can use \\[narrow-to-region] to limit the part of buffer to be evaluated.
 When called from a Lisp program (i.e., not interactively), this
@@ -2675,8 +2641,6 @@ UNIBYTE, if non-nil, specifies `load-convert-to-unibyte' for this
 DO-ALLOW-PRINT, if non-nil, specifies that output functions in the
  evaluated code should work normally even if PRINTFLAG is nil, in
  which case the output is displayed in the echo area.
-LOADING, if non-nil, indicates that this call is part of loading a
-Lisp source file.
 
 This function ignores the current value of the `lexical-binding'
 variable.  Instead it will heed any
@@ -2686,7 +2650,7 @@ will be evaluated without lexical binding.
 
 This function preserves the position of point.  */)
   (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename,
-   Lisp_Object unibyte, Lisp_Object do_allow_print, Lisp_Object loading)
+   Lisp_Object unibyte, Lisp_Object do_allow_print)
 {
   specpdl_ref count = SPECPDL_INDEX ();
   Lisp_Object tem, buf;
@@ -2710,10 +2674,8 @@ This function preserves the position of point.  */)
   specbind (Qstandard_output, tem);
   record_unwind_protect_excursion ();
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
-  lexical_cookie_t lc = lisp_file_lexical_cookie (buf);
-  if (!NILP (loading) && lc == Cookie_None)
-    warn_missing_cookie (filename);
-  specbind (Qlexical_binding, lc == Cookie_Lex ? Qt : Qnil);
+  specbind (Qlexical_binding,
+           lisp_file_lexical_cookie (buf) == Cookie_Lex ? Qt : Qnil);
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
   readevalloop (buf, 0, filename,
                !NILP (printflag), unibyte, Qnil, Qnil, Qnil);