diff options
| author | Mattias EngdegÄrd | 2024-05-04 16:18:09 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-05-05 16:14:00 +0200 |
| commit | d51de0c5d90117bc1dc4bc5bc700253d71cd4579 (patch) | |
| tree | c37cfb5aea8dab9b090be613e20f39d883f79825 /src | |
| parent | 71491fe6f4a944457cb56f6323983ef431e0c422 (diff) | |
| download | emacs-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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 48 |
1 files changed, 5 insertions, 43 deletions
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 | ||
| 1345 | static bool | ||
| 1346 | string_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 | |||
| 1353 | static void | ||
| 1354 | warn_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 | |||
| 1376 | DEFUN ("load", Fload, Sload, 1, 5, 0, | 1345 | DEFUN ("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. |
| 1378 | First try FILE with `.elc' appended, then try with `.el', then try | 1347 | 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. */) | |||
| 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 | ||
| 2661 | DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0,6, "", | 2627 | DEFUN ("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. |
| 2663 | You can use \\[narrow-to-region] to limit the part of buffer to be evaluated. | 2629 | You can use \\[narrow-to-region] to limit the part of buffer to be evaluated. |
| 2664 | When called from a Lisp program (i.e., not interactively), this | 2630 | 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 | |||
| 2675 | DO-ALLOW-PRINT, if non-nil, specifies that output functions in the | 2641 | DO-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. |
| 2678 | LOADING, if non-nil, indicates that this call is part of loading a | ||
| 2679 | Lisp source file. | ||
| 2680 | 2644 | ||
| 2681 | This function ignores the current value of the `lexical-binding' | 2645 | This function ignores the current value of the `lexical-binding' |
| 2682 | variable. Instead it will heed any | 2646 | variable. Instead it will heed any |
| @@ -2686,7 +2650,7 @@ will be evaluated without lexical binding. | |||
| 2686 | 2650 | ||
| 2687 | This function preserves the position of point. */) | 2651 | This 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); |