Function: byte-compile-output-as-comment
byte-compile-output-as-comment is a byte-compiled function defined in
bytecomp.el.gz.
Signature
(byte-compile-output-as-comment EXP QUOTED)
Documentation
Print Lisp object EXP in the output file at point, inside a comment.
Return the file (byte) position it will have. Leave point after the inserted text. If QUOTED is non-nil, print with quoting; otherwise, print without quoting.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-output-as-comment (exp quoted)
"Print Lisp object EXP in the output file at point, inside a comment.
Return the file (byte) position it will have. Leave point after
the inserted text. If QUOTED is non-nil, print with quoting;
otherwise, print without quoting."
(with-current-buffer byte-compile--outbuffer
(let ((position (point)) end)
;; Insert EXP, and make it a comment with #@LENGTH.
(insert " ")
(if quoted
(prin1 exp byte-compile--outbuffer)
(princ exp byte-compile--outbuffer))
(setq end (point-marker))
(set-marker-insertion-type end t)
(goto-char position)
;; Quote certain special characters as needed.
;; get_doc_string in doc.c does the unquoting.
(while (search-forward "\^A" end t)
(replace-match "\^A\^A" t t))
(goto-char position)
(while (search-forward "\000" end t)
(replace-match "\^A0" t t))
(goto-char position)
(while (search-forward "\037" end t)
(replace-match "\^A_" t t))
(goto-char end)
(insert "\037")
(goto-char position)
(insert "#@" (format "%d" (- (position-bytes end)
(position-bytes position))))
;; Save the file position of the object.
;; Note we add 1 to skip the space that we inserted before the actual doc
;; string, and subtract point-min to convert from an 1-origin Emacs
;; position to a file position.
(prog1
(- (position-bytes (point)) (point-min) -1)
(goto-char end)
(set-marker end nil)))))