diff options
| author | Stefan Monnier | 2020-03-07 23:28:12 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2020-03-07 23:28:12 -0500 |
| commit | e4fb95fa18072cedb021a82f7aa0e79fa6ca387a (patch) | |
| tree | 81ab316dd97d896aab4122467f21ced48c6ab411 | |
| parent | 6ce20525585cc9c4c865cfdd32b43ab268bb17ec (diff) | |
| download | emacs-e4fb95fa18072cedb021a82f7aa0e79fa6ca387a.tar.gz emacs-e4fb95fa18072cedb021a82f7aa0e79fa6ca387a.zip | |
* lisp/emacs-lisp/bytecomp.el: Drop warning for loading into Emacs<23
Stash the major version of the compiling Emacs such that the loading
Emacs can later detect when loading a file compiled by a too-new Emacs.
(byte-compile-fix-header): Remove.
(byte-compile-from-buffer): Don't call it any more.
(byte-compile-insert-header): Stash the emacs-major-version in it.
Don't leave space for `byte-compile-fix-header`.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 68 |
1 files changed, 15 insertions, 53 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 63348456a15..4f01918bdb9 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -2140,50 +2140,9 @@ With argument ARG, insert value in current buffer after the form." | |||
| 2140 | ;; Make warnings about unresolved functions | 2140 | ;; Make warnings about unresolved functions |
| 2141 | ;; give the end of the file as their position. | 2141 | ;; give the end of the file as their position. |
| 2142 | (setq byte-compile-last-position (point-max)) | 2142 | (setq byte-compile-last-position (point-max)) |
| 2143 | (byte-compile-warn-about-unresolved-functions)) | 2143 | (byte-compile-warn-about-unresolved-functions))) |
| 2144 | ;; Fix up the header at the front of the output | ||
| 2145 | ;; if the buffer contains multibyte characters. | ||
| 2146 | (and byte-compile-current-file | ||
| 2147 | (with-current-buffer byte-compile--outbuffer | ||
| 2148 | (byte-compile-fix-header byte-compile-current-file)))) | ||
| 2149 | byte-compile--outbuffer))) | 2144 | byte-compile--outbuffer))) |
| 2150 | 2145 | ||
| 2151 | (defun byte-compile-fix-header (_filename) | ||
| 2152 | "If the current buffer has any multibyte characters, insert a version test." | ||
| 2153 | (when (< (point-max) (position-bytes (point-max))) | ||
| 2154 | (goto-char (point-min)) | ||
| 2155 | ;; Find the comment that describes the version condition. | ||
| 2156 | (when (search-forward "\n;;; This file does not contain utf-8" nil t) | ||
| 2157 | (narrow-to-region (line-beginning-position) (point-max)) | ||
| 2158 | ;; Find the first line of ballast semicolons. | ||
| 2159 | (search-forward ";;;;;;;;;;") | ||
| 2160 | (beginning-of-line) | ||
| 2161 | (narrow-to-region (point-min) (point)) | ||
| 2162 | (let ((old-header-end (point)) | ||
| 2163 | (minimum-version "23") | ||
| 2164 | delta) | ||
| 2165 | (delete-region (point-min) (point-max)) | ||
| 2166 | (insert | ||
| 2167 | ";;; This file contains utf-8 non-ASCII characters,\n" | ||
| 2168 | ";;; and so cannot be loaded into Emacs 22 or earlier.\n" | ||
| 2169 | ;; Have to check if emacs-version is bound so that this works | ||
| 2170 | ;; in files loaded early in loadup.el. | ||
| 2171 | "(and (boundp 'emacs-version)\n" | ||
| 2172 | ;; If there is a name at the end of emacs-version, | ||
| 2173 | ;; don't try to check the version number. | ||
| 2174 | " (< (aref emacs-version (1- (length emacs-version))) ?A)\n" | ||
| 2175 | (format " (string-lessp emacs-version \"%s\")\n" minimum-version) | ||
| 2176 | ;; Because the header must fit in a fixed width, we cannot | ||
| 2177 | ;; insert arbitrary-length file names (Bug#11585). | ||
| 2178 | " (error \"`%s' was compiled for " | ||
| 2179 | (format "Emacs %s or later\" #$))\n\n" minimum-version)) | ||
| 2180 | ;; Now compensate for any change in size, to make sure all | ||
| 2181 | ;; positions in the file remain valid. | ||
| 2182 | (setq delta (- (point-max) old-header-end)) | ||
| 2183 | (goto-char (point-max)) | ||
| 2184 | (widen) | ||
| 2185 | (delete-char delta))))) | ||
| 2186 | |||
| 2187 | (defun byte-compile-insert-header (_filename outbuffer) | 2146 | (defun byte-compile-insert-header (_filename outbuffer) |
| 2188 | "Insert a header at the start of OUTBUFFER. | 2147 | "Insert a header at the start of OUTBUFFER. |
| 2189 | Call from the source buffer." | 2148 | Call from the source buffer." |
| @@ -2201,7 +2160,19 @@ Call from the source buffer." | |||
| 2201 | ;; 0 string ;ELC GNU Emacs Lisp compiled file, | 2160 | ;; 0 string ;ELC GNU Emacs Lisp compiled file, |
| 2202 | ;; >4 byte x version %d | 2161 | ;; >4 byte x version %d |
| 2203 | (insert | 2162 | (insert |
| 2204 | ";ELC" 23 "\000\000\000\n" | 2163 | ";ELC" |
| 2164 | (let ((version | ||
| 2165 | (if (zerop emacs-minor-version) | ||
| 2166 | ;; Let's allow silently loading into Emacs-27 | ||
| 2167 | ;; files compiled with Emacs-28.0.NN since the two can | ||
| 2168 | ;; be almost identical (e.g. right after cutting the | ||
| 2169 | ;; release branch) and people running the development | ||
| 2170 | ;; branch can be presumed to know that it's risky anyway. | ||
| 2171 | (1- emacs-major-version) emacs-major-version))) | ||
| 2172 | ;; Make sure the version is a plain byte that doesn't end the comment! | ||
| 2173 | (cl-assert (and (> version 13) (< version 128))) | ||
| 2174 | version) | ||
| 2175 | "\000\000\000\n" | ||
| 2205 | ";;; Compiled\n" | 2176 | ";;; Compiled\n" |
| 2206 | ";;; in Emacs version " emacs-version "\n" | 2177 | ";;; in Emacs version " emacs-version "\n" |
| 2207 | ";;; with" | 2178 | ";;; with" |
| @@ -2213,16 +2184,7 @@ Call from the source buffer." | |||
| 2213 | ".\n" | 2184 | ".\n" |
| 2214 | (if dynamic ";;; Function definitions are lazy-loaded.\n" | 2185 | (if dynamic ";;; Function definitions are lazy-loaded.\n" |
| 2215 | "") | 2186 | "") |
| 2216 | "\n" | 2187 | "\n\n")))) |
| 2217 | ;; Note that byte-compile-fix-header may change this. | ||
| 2218 | ";;; This file does not contain utf-8 non-ASCII characters,\n" | ||
| 2219 | ";;; and so can be loaded in Emacs versions earlier than 23.\n\n" | ||
| 2220 | ;; Insert semicolons as ballast, so that byte-compile-fix-header | ||
| 2221 | ;; can delete them so as to keep the buffer positions | ||
| 2222 | ;; constant for the actual compiled code. | ||
| 2223 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" | ||
| 2224 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" | ||
| 2225 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")))) | ||
| 2226 | 2188 | ||
| 2227 | (defun byte-compile-output-file-form (form) | 2189 | (defun byte-compile-output-file-form (form) |
| 2228 | ;; Write the given form to the output buffer, being careful of docstrings | 2190 | ;; Write the given form to the output buffer, being careful of docstrings |