aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2024-05-04 16:18:09 +0200
committerMattias EngdegÄrd2024-05-05 16:14:00 +0200
commitd51de0c5d90117bc1dc4bc5bc700253d71cd4579 (patch)
treec37cfb5aea8dab9b090be613e20f39d883f79825
parent71491fe6f4a944457cb56f6323983ef431e0c422 (diff)
downloademacs-d51de0c5d90117bc1dc4bc5bc700253d71cd4579.tar.gz
emacs-d51de0c5d90117bc1dc4bc5bc700253d71cd4579.zip
Retract lexical cookie source load warning
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.
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/international/mule.el2
-rw-r--r--lisp/startup.el2
-rw-r--r--src/lread.c48
4 files changed, 7 insertions, 54 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 0a1c217d897..e69825669ae 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2437,15 +2437,6 @@ The warning name is 'docstrings-control-chars'.
2437Its warning name is 'docstrings-wide'. 2437Its warning name is 'docstrings-wide'.
2438 2438
2439--- 2439---
2440** Warn about missing 'lexical-binding' directive when loading .el files.
2441Emacs now emits a run-time warning if an Elisp source file being loaded
2442lacks the '-*- lexical-binding: ... -*-' cookie on the first line.
2443See the lexical-binding compiler warning described above for how to make
2444the warning go away by adding a declaration to the file. You can also
2445suppress the warning by adding an entry for the warning type
2446'lexical-warning' to 'warning-suppress-types'.
2447
2448---
2449** New user option 'native-comp-async-warnings-errors-kind'. 2440** New user option 'native-comp-async-warnings-errors-kind'.
2450It allows control of what kinds of warnings and errors from asynchronous 2441It allows control of what kinds of warnings and errors from asynchronous
2451native compilation are reported to the parent Emacs process. The 2442native compilation are reported to the parent Emacs process. The
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 8875c4f06af..a17221e6d21 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -367,7 +367,7 @@ Return t if file exists."
367 (eval-buffer buffer nil 367 (eval-buffer buffer nil
368 ;; This is compatible with what `load' does. 368 ;; This is compatible with what `load' does.
369 (if dump-mode file fullname) 369 (if dump-mode file fullname)
370 nil t t)))) 370 nil t))))
371 (let (kill-buffer-hook kill-buffer-query-functions) 371 (let (kill-buffer-hook kill-buffer-query-functions)
372 (kill-buffer buffer))) 372 (kill-buffer buffer)))
373 (do-after-load-evaluation fullname) 373 (do-after-load-evaluation fullname)
diff --git a/lisp/startup.el b/lisp/startup.el
index f2532f5254e..357a4154e4c 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2935,7 +2935,7 @@ nil default-directory" name)
2935 ;; buffer is empty. 2935 ;; buffer is empty.
2936 (when (looking-at "#!") 2936 (when (looking-at "#!")
2937 (delete-line)) 2937 (delete-line))
2938 (eval-buffer buffer nil file nil t t))))) 2938 (eval-buffer buffer nil file nil t)))))
2939 2939
2940(defun command-line--eval-script (file) 2940(defun command-line--eval-script (file)
2941 (load-with-code-conversion 2941 (load-with-code-conversion
diff --git a/src/lread.c b/src/lread.c
index ba890cb673d..7806c3972ee 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1342,37 +1342,6 @@ close_file_unwind_android_fd (void *ptr)
1342 1342
1343#endif 1343#endif
1344 1344
1345static bool
1346string_suffix_p (const char *string, ptrdiff_t string_len,
1347 const char *suffix, ptrdiff_t suffix_len)
1348{
1349 return string_len >= suffix_len && memcmp (string + string_len - suffix_len,
1350 suffix, suffix_len) == 0;
1351}
1352
1353static void
1354warn_missing_cookie (Lisp_Object file)
1355{
1356 /* Only warn for files whose name end in .el, to suppress loading of
1357 data-as-code. ".emacs" is an exception, since it does tend to contain
1358 actual hand-written code. */
1359 if (!STRINGP (file))
1360 return;
1361 const char *name = SSDATA (file);
1362 ptrdiff_t nb = SBYTES (file);
1363 if (!(string_suffix_p (name, nb, ".el", 3)
1364 || (string_suffix_p (name, nb, ".emacs", 6)
1365 && (nb == 6 || SREF (file, nb - 7) == '/'))))
1366 return;
1367
1368 Lisp_Object msg = CALLN (Fformat,
1369 build_string ("File %s lacks `lexical-binding'"
1370 " directive on its first line"),
1371 file);
1372 Vdelayed_warnings_list = Fcons (list2 (Qlexical_binding, msg),
1373 Vdelayed_warnings_list);
1374}
1375
1376DEFUN ("load", Fload, Sload, 1, 5, 0, 1345DEFUN ("load", Fload, Sload, 1, 5, 0,
1377 doc: /* Execute a file of Lisp code named FILE. 1346 doc: /* Execute a file of Lisp code named FILE.
1378First try FILE with `.elc' appended, then try with `.el', then try 1347First try FILE with `.elc' appended, then try with `.el', then try
@@ -1822,10 +1791,7 @@ Return t if the file exists and loads successfully. */)
1822 } 1791 }
1823 else 1792 else
1824 { 1793 {
1825 lexical_cookie_t lc = lisp_file_lexical_cookie (Qget_file_char); 1794 if (lisp_file_lexical_cookie (Qget_file_char) == Cookie_Lex)
1826 if (lc == Cookie_None && !compiled)
1827 warn_missing_cookie (file);
1828 if (lc == Cookie_Lex)
1829 Fset (Qlexical_binding, Qt); 1795 Fset (Qlexical_binding, Qt);
1830 1796
1831 if (! version || version >= 22) 1797 if (! version || version >= 22)
@@ -2658,7 +2624,7 @@ readevalloop (Lisp_Object readcharfun,
2658 unbind_to (count, Qnil); 2624 unbind_to (count, Qnil);
2659} 2625}
2660 2626
2661DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0,6, "", 2627DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "",
2662 doc: /* Execute the accessible portion of current buffer as Lisp code. 2628 doc: /* Execute the accessible portion of current buffer as Lisp code.
2663You can use \\[narrow-to-region] to limit the part of buffer to be evaluated. 2629You can use \\[narrow-to-region] to limit the part of buffer to be evaluated.
2664When called from a Lisp program (i.e., not interactively), this 2630When 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
2675DO-ALLOW-PRINT, if non-nil, specifies that output functions in the 2641DO-ALLOW-PRINT, if non-nil, specifies that output functions in the
2676 evaluated code should work normally even if PRINTFLAG is nil, in 2642 evaluated code should work normally even if PRINTFLAG is nil, in
2677 which case the output is displayed in the echo area. 2643 which case the output is displayed in the echo area.
2678LOADING, if non-nil, indicates that this call is part of loading a
2679Lisp source file.
2680 2644
2681This function ignores the current value of the `lexical-binding' 2645This function ignores the current value of the `lexical-binding'
2682variable. Instead it will heed any 2646variable. Instead it will heed any
@@ -2686,7 +2650,7 @@ will be evaluated without lexical binding.
2686 2650
2687This function preserves the position of point. */) 2651This function preserves the position of point. */)
2688 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, 2652 (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename,
2689 Lisp_Object unibyte, Lisp_Object do_allow_print, Lisp_Object loading) 2653 Lisp_Object unibyte, Lisp_Object do_allow_print)
2690{ 2654{
2691 specpdl_ref count = SPECPDL_INDEX (); 2655 specpdl_ref count = SPECPDL_INDEX ();
2692 Lisp_Object tem, buf; 2656 Lisp_Object tem, buf;
@@ -2710,10 +2674,8 @@ This function preserves the position of point. */)
2710 specbind (Qstandard_output, tem); 2674 specbind (Qstandard_output, tem);
2711 record_unwind_protect_excursion (); 2675 record_unwind_protect_excursion ();
2712 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2676 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2713 lexical_cookie_t lc = lisp_file_lexical_cookie (buf); 2677 specbind (Qlexical_binding,
2714 if (!NILP (loading) && lc == Cookie_None) 2678 lisp_file_lexical_cookie (buf) == Cookie_Lex ? Qt : Qnil);
2715 warn_missing_cookie (filename);
2716 specbind (Qlexical_binding, lc == Cookie_Lex ? Qt : Qnil);
2717 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2679 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2718 readevalloop (buf, 0, filename, 2680 readevalloop (buf, 0, filename,
2719 !NILP (printflag), unibyte, Qnil, Qnil, Qnil); 2681 !NILP (printflag), unibyte, Qnil, Qnil, Qnil);