Function: byte-compile-output-docform

byte-compile-output-docform is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile-output-docform PREFACE NAME INFO FORM SPECINDEX QUOTED)

Documentation

Print a form with a doc string. INFO is (prefix doc-index postfix).

If PREFACE and NAME are non-nil, print them too, before INFO and the FORM but after the doc string itself. If SPECINDEX is non-nil, it is the index in FORM of the function bytecode string. In that case, we output that argument and the following argument
(the constants vector) together, for lazy loading.
QUOTED says that we have to put a quote before the list that represents a doc string reference. defvaralias, autoload and custom-declare-variable need that.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-output-docform (preface name info form specindex quoted)
  "Print a form with a doc string.  INFO is (prefix doc-index postfix).
If PREFACE and NAME are non-nil, print them too,
before INFO and the FORM but after the doc string itself.
If SPECINDEX is non-nil, it is the index in FORM
of the function bytecode string.  In that case,
we output that argument and the following argument
\(the constants vector) together, for lazy loading.
QUOTED says that we have to put a quote before the
list that represents a doc string reference.
`defvaralias', `autoload' and `custom-declare-variable' need that."
  ;; We need to examine byte-compile-dynamic-docstrings
  ;; in the input buffer (now current), not in the output buffer.
  (let ((dynamic-docstrings byte-compile-dynamic-docstrings))
    (with-current-buffer byte-compile--outbuffer
      (let (position)

        ;; Insert the doc string, and make it a comment with #@LENGTH.
        (and (>= (nth 1 info) 0)
             dynamic-docstrings
             (progn
               ;; Make the doc string start at beginning of line
               ;; for make-docfile's sake.
               (insert "\n")
               (setq position
                     (byte-compile-output-as-comment
                      (nth (nth 1 info) form) nil))
               ;; If the doc string starts with * (a user variable),
               ;; negate POSITION.
               (if (and (stringp (nth (nth 1 info) form))
                        (> (length (nth (nth 1 info) form)) 0)
                        (eq (aref (nth (nth 1 info) form) 0) ?*))
                   (setq position (- position)))))

        (let ((print-continuous-numbering t)
              print-number-table
              (index 0)
              ;; FIXME: The bindings below are only needed for when we're
              ;; called from ...-defmumble.
              (print-escape-newlines t)
              (print-length nil)
              (print-level nil)
              (print-quoted t)
              (print-gensym t)
              (print-circle             ; Handle circular data structures.
               (not byte-compile-disable-print-circle)))
          (if preface
              (progn
                ;; FIXME: We don't handle uninterned names correctly.
                ;; E.g. if cl-define-compiler-macro uses uninterned name we get:
                ;;    (defalias '#1=#:foo--cmacro #[514 ...])
                ;;    (put 'foo 'compiler-macro '#:foo--cmacro)
                (insert preface)
                (prin1 name byte-compile--outbuffer)))
          (insert (car info))
          (prin1 (car form) byte-compile--outbuffer)
          (while (setq form (cdr form))
            (setq index (1+ index))
            (insert " ")
            (cond ((and (numberp specindex) (= index specindex)
                        ;; Don't handle the definition dynamically
                        ;; if it refers (or might refer)
                        ;; to objects already output
                        ;; (for instance, gensyms in the arg list).
                        (let (non-nil)
                          (when (hash-table-p print-number-table)
                            (maphash (lambda (_k v) (if v (setq non-nil t)))
                                     print-number-table))
                          (not non-nil)))
                   ;; Output the byte code and constants specially
                   ;; for lazy dynamic loading.
                   (let ((position
                          (byte-compile-output-as-comment
                           (cons (car form) (nth 1 form))
                           t)))
                     (princ (format "(#$ . %d) nil" position)
                            byte-compile--outbuffer)
                     (setq form (cdr form))
                     (setq index (1+ index))))
                  ((= index (nth 1 info))
                   (if position
                       (princ (format (if quoted "'(#$ . %d)"  "(#$ . %d)")
                                      position)
                              byte-compile--outbuffer)
                     (let ((print-escape-newlines nil))
                       (goto-char (prog1 (1+ (point))
                                    (prin1 (car form)
                                           byte-compile--outbuffer)))
                       (insert "\\\n")
                       (goto-char (point-max)))))
                  (t
                   (prin1 (car form) byte-compile--outbuffer)))))
        (insert (nth 2 info)))))
  nil)