diff options
| author | Stefan Monnier | 2007-08-23 19:58:31 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-08-23 19:58:31 +0000 |
| commit | 9ec5dfe64b819bec13c8eb5691d2a57bc6c9d7ec (patch) | |
| tree | 89e2bb9be956d6d25d5f4637a4bad312decb6a9a | |
| parent | 40fafc21621fd7f5e7164bee1813a9819cab8236 (diff) | |
| download | emacs-9ec5dfe64b819bec13c8eb5691d2a57bc6c9d7ec.tar.gz emacs-9ec5dfe64b819bec13c8eb5691d2a57bc6c9d7ec.zip | |
(byte-compile-output-docform, byte-compile-output-as-comment):
Use with-current-buffer rather than a weird set-buffer&prog1 combination.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 220 |
2 files changed, 112 insertions, 112 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dadc3e0f78c..4105cdf3b37 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2007-08-23 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2007-08-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-output-docform) | ||
| 4 | (byte-compile-output-as-comment): Use with-current-buffer rather than | ||
| 5 | a weird set-buffer&prog1 combination. | ||
| 6 | |||
| 3 | * emacs-lisp/byte-opt.el (byte-optimize-if): Move `progn' out of the test | 7 | * emacs-lisp/byte-opt.el (byte-optimize-if): Move `progn' out of the test |
| 4 | so as to optimise cases where the `progn's result is constant. | 8 | so as to optimise cases where the `progn's result is constant. |
| 5 | 9 | ||
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 45c8422e64f..39ff0d8668e 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -2037,85 +2037,83 @@ list that represents a doc string reference. | |||
| 2037 | ;; We need to examine byte-compile-dynamic-docstrings | 2037 | ;; We need to examine byte-compile-dynamic-docstrings |
| 2038 | ;; in the input buffer (now current), not in the output buffer. | 2038 | ;; in the input buffer (now current), not in the output buffer. |
| 2039 | (let ((dynamic-docstrings byte-compile-dynamic-docstrings)) | 2039 | (let ((dynamic-docstrings byte-compile-dynamic-docstrings)) |
| 2040 | (set-buffer | 2040 | (with-current-buffer outbuffer |
| 2041 | (prog1 (current-buffer) | 2041 | (let (position) |
| 2042 | (set-buffer outbuffer) | 2042 | |
| 2043 | (let (position) | 2043 | ;; Insert the doc string, and make it a comment with #@LENGTH. |
| 2044 | 2044 | (and (>= (nth 1 info) 0) | |
| 2045 | ;; Insert the doc string, and make it a comment with #@LENGTH. | 2045 | dynamic-docstrings |
| 2046 | (and (>= (nth 1 info) 0) | 2046 | (not byte-compile-compatibility) |
| 2047 | dynamic-docstrings | 2047 | (progn |
| 2048 | (not byte-compile-compatibility) | 2048 | ;; Make the doc string start at beginning of line |
| 2049 | (progn | 2049 | ;; for make-docfile's sake. |
| 2050 | ;; Make the doc string start at beginning of line | 2050 | (insert "\n") |
| 2051 | ;; for make-docfile's sake. | 2051 | (setq position |
| 2052 | (insert "\n") | 2052 | (byte-compile-output-as-comment |
| 2053 | (setq position | 2053 | (nth (nth 1 info) form) nil)) |
| 2054 | (byte-compile-output-as-comment | 2054 | (setq position (- (position-bytes position) (point-min) -1)) |
| 2055 | (nth (nth 1 info) form) nil)) | 2055 | ;; If the doc string starts with * (a user variable), |
| 2056 | (setq position (- (position-bytes position) (point-min) -1)) | 2056 | ;; negate POSITION. |
| 2057 | ;; If the doc string starts with * (a user variable), | 2057 | (if (and (stringp (nth (nth 1 info) form)) |
| 2058 | ;; negate POSITION. | 2058 | (> (length (nth (nth 1 info) form)) 0) |
| 2059 | (if (and (stringp (nth (nth 1 info) form)) | 2059 | (eq (aref (nth (nth 1 info) form) 0) ?*)) |
| 2060 | (> (length (nth (nth 1 info) form)) 0) | 2060 | (setq position (- position))))) |
| 2061 | (eq (aref (nth (nth 1 info) form) 0) ?*)) | 2061 | |
| 2062 | (setq position (- position))))) | 2062 | (if preface |
| 2063 | 2063 | (progn | |
| 2064 | (if preface | 2064 | (insert preface) |
| 2065 | (progn | 2065 | (prin1 name outbuffer))) |
| 2066 | (insert preface) | 2066 | (insert (car info)) |
| 2067 | (prin1 name outbuffer))) | 2067 | (let ((print-escape-newlines t) |
| 2068 | (insert (car info)) | 2068 | (print-quoted t) |
| 2069 | (let ((print-escape-newlines t) | 2069 | ;; For compatibility with code before print-circle, |
| 2070 | (print-quoted t) | 2070 | ;; use a cons cell to say that we want |
| 2071 | ;; For compatibility with code before print-circle, | 2071 | ;; print-gensym-alist not to be cleared |
| 2072 | ;; use a cons cell to say that we want | 2072 | ;; between calls to print functions. |
| 2073 | ;; print-gensym-alist not to be cleared | 2073 | (print-gensym '(t)) |
| 2074 | ;; between calls to print functions. | 2074 | (print-circle ; handle circular data structures |
| 2075 | (print-gensym '(t)) | 2075 | (not byte-compile-disable-print-circle)) |
| 2076 | (print-circle ; handle circular data structures | 2076 | print-gensym-alist ; was used before print-circle existed. |
| 2077 | (not byte-compile-disable-print-circle)) | 2077 | (print-continuous-numbering t) |
| 2078 | print-gensym-alist ; was used before print-circle existed. | 2078 | print-number-table |
| 2079 | (print-continuous-numbering t) | 2079 | (index 0)) |
| 2080 | print-number-table | 2080 | (prin1 (car form) outbuffer) |
| 2081 | (index 0)) | 2081 | (while (setq form (cdr form)) |
| 2082 | (prin1 (car form) outbuffer) | 2082 | (setq index (1+ index)) |
| 2083 | (while (setq form (cdr form)) | 2083 | (insert " ") |
| 2084 | (setq index (1+ index)) | 2084 | (cond ((and (numberp specindex) (= index specindex) |
| 2085 | (insert " ") | 2085 | ;; Don't handle the definition dynamically |
| 2086 | (cond ((and (numberp specindex) (= index specindex) | 2086 | ;; if it refers (or might refer) |
| 2087 | ;; Don't handle the definition dynamically | 2087 | ;; to objects already output |
| 2088 | ;; if it refers (or might refer) | 2088 | ;; (for instance, gensyms in the arg list). |
| 2089 | ;; to objects already output | 2089 | (let (non-nil) |
| 2090 | ;; (for instance, gensyms in the arg list). | 2090 | (dotimes (i (length print-number-table)) |
| 2091 | (let (non-nil) | 2091 | (if (aref print-number-table i) |
| 2092 | (dotimes (i (length print-number-table)) | 2092 | (setq non-nil t))) |
| 2093 | (if (aref print-number-table i) | 2093 | (not non-nil))) |
| 2094 | (setq non-nil t))) | 2094 | ;; Output the byte code and constants specially |
| 2095 | (not non-nil))) | 2095 | ;; for lazy dynamic loading. |
| 2096 | ;; Output the byte code and constants specially | 2096 | (let ((position |
| 2097 | ;; for lazy dynamic loading. | 2097 | (byte-compile-output-as-comment |
| 2098 | (let ((position | 2098 | (cons (car form) (nth 1 form)) |
| 2099 | (byte-compile-output-as-comment | 2099 | t))) |
| 2100 | (cons (car form) (nth 1 form)) | 2100 | (setq position (- (position-bytes position) (point-min) -1)) |
| 2101 | t))) | 2101 | (princ (format "(#$ . %d) nil" position) outbuffer) |
| 2102 | (setq position (- (position-bytes position) (point-min) -1)) | 2102 | (setq form (cdr form)) |
| 2103 | (princ (format "(#$ . %d) nil" position) outbuffer) | 2103 | (setq index (1+ index)))) |
| 2104 | (setq form (cdr form)) | 2104 | ((= index (nth 1 info)) |
| 2105 | (setq index (1+ index)))) | 2105 | (if position |
| 2106 | ((= index (nth 1 info)) | 2106 | (princ (format (if quoted "'(#$ . %d)" "(#$ . %d)") |
| 2107 | (if position | 2107 | position) |
| 2108 | (princ (format (if quoted "'(#$ . %d)" "(#$ . %d)") | 2108 | outbuffer) |
| 2109 | position) | 2109 | (let ((print-escape-newlines nil)) |
| 2110 | outbuffer) | 2110 | (goto-char (prog1 (1+ (point)) |
| 2111 | (let ((print-escape-newlines nil)) | 2111 | (prin1 (car form) outbuffer))) |
| 2112 | (goto-char (prog1 (1+ (point)) | 2112 | (insert "\\\n") |
| 2113 | (prin1 (car form) outbuffer))) | 2113 | (goto-char (point-max))))) |
| 2114 | (insert "\\\n") | 2114 | (t |
| 2115 | (goto-char (point-max))))) | 2115 | (prin1 (car form) outbuffer))))) |
| 2116 | (t | 2116 | (insert (nth 2 info))))) |
| 2117 | (prin1 (car form) outbuffer))))) | ||
| 2118 | (insert (nth 2 info)))))) | ||
| 2119 | nil) | 2117 | nil) |
| 2120 | 2118 | ||
| 2121 | (defun byte-compile-keep-pending (form &optional handler) | 2119 | (defun byte-compile-keep-pending (form &optional handler) |
| @@ -2401,39 +2399,37 @@ list that represents a doc string reference. | |||
| 2401 | ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. | 2399 | ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. |
| 2402 | (defun byte-compile-output-as-comment (exp quoted) | 2400 | (defun byte-compile-output-as-comment (exp quoted) |
| 2403 | (let ((position (point))) | 2401 | (let ((position (point))) |
| 2404 | (set-buffer | 2402 | (with-current-buffer outbuffer |
| 2405 | (prog1 (current-buffer) | 2403 | |
| 2406 | (set-buffer outbuffer) | 2404 | ;; Insert EXP, and make it a comment with #@LENGTH. |
| 2407 | 2405 | (insert " ") | |
| 2408 | ;; Insert EXP, and make it a comment with #@LENGTH. | 2406 | (if quoted |
| 2409 | (insert " ") | 2407 | (prin1 exp outbuffer) |
| 2410 | (if quoted | 2408 | (princ exp outbuffer)) |
| 2411 | (prin1 exp outbuffer) | 2409 | (goto-char position) |
| 2412 | (princ exp outbuffer)) | 2410 | ;; Quote certain special characters as needed. |
| 2413 | (goto-char position) | 2411 | ;; get_doc_string in doc.c does the unquoting. |
| 2414 | ;; Quote certain special characters as needed. | 2412 | (while (search-forward "\^A" nil t) |
| 2415 | ;; get_doc_string in doc.c does the unquoting. | 2413 | (replace-match "\^A\^A" t t)) |
| 2416 | (while (search-forward "\^A" nil t) | 2414 | (goto-char position) |
| 2417 | (replace-match "\^A\^A" t t)) | 2415 | (while (search-forward "\000" nil t) |
| 2418 | (goto-char position) | 2416 | (replace-match "\^A0" t t)) |
| 2419 | (while (search-forward "\000" nil t) | 2417 | (goto-char position) |
| 2420 | (replace-match "\^A0" t t)) | 2418 | (while (search-forward "\037" nil t) |
| 2421 | (goto-char position) | 2419 | (replace-match "\^A_" t t)) |
| 2422 | (while (search-forward "\037" nil t) | 2420 | (goto-char (point-max)) |
| 2423 | (replace-match "\^A_" t t)) | 2421 | (insert "\037") |
| 2424 | (goto-char (point-max)) | 2422 | (goto-char position) |
| 2425 | (insert "\037") | 2423 | (insert "#@" (format "%d" (- (position-bytes (point-max)) |
| 2426 | (goto-char position) | 2424 | (position-bytes position)))) |
| 2427 | (insert "#@" (format "%d" (- (position-bytes (point-max)) | 2425 | |
| 2428 | (position-bytes position)))) | 2426 | ;; Save the file position of the object. |
| 2429 | 2427 | ;; Note we should add 1 to skip the space | |
| 2430 | ;; Save the file position of the object. | 2428 | ;; that we inserted before the actual doc string, |
| 2431 | ;; Note we should add 1 to skip the space | 2429 | ;; and subtract 1 to convert from an 1-origin Emacs position |
| 2432 | ;; that we inserted before the actual doc string, | 2430 | ;; to a file position; they cancel. |
| 2433 | ;; and subtract 1 to convert from an 1-origin Emacs position | 2431 | (setq position (point)) |
| 2434 | ;; to a file position; they cancel. | 2432 | (goto-char (point-max))) |
| 2435 | (setq position (point)) | ||
| 2436 | (goto-char (point-max)))) | ||
| 2437 | position)) | 2433 | position)) |
| 2438 | 2434 | ||
| 2439 | 2435 | ||