Function: comp-log-to-buffer

comp-log-to-buffer is a byte-compiled function defined in comp.el.gz.

Signature

(comp-log-to-buffer DATA &optional QUOTED)

Documentation

Log DATA to comp-log-buffer-name.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(cl-defun comp-log-to-buffer (data &optional quoted)
  "Log DATA to `comp-log-buffer-name'."
  (let* ((print-f (if quoted #'prin1 #'princ))
         (log-buffer
             (or (get-buffer comp-log-buffer-name)
                 (with-current-buffer (get-buffer-create comp-log-buffer-name)
                   (setf buffer-read-only t)
                   (current-buffer))))
         (log-window (get-buffer-window log-buffer))
         (inhibit-read-only t)
         at-end-p)
    (with-current-buffer log-buffer
      (unless (eq major-mode 'native-comp-limple-mode)
        (native-comp-limple-mode))
      (when (= (point) (point-max))
        (setf at-end-p t))
      (save-excursion
        (goto-char (point-max))
        (cl-typecase data
          (atom (funcall print-f data log-buffer))
          (t (dolist (elem data)
               (funcall print-f elem log-buffer)
               (insert "\n"))))
        (insert "\n"))
      (when (and at-end-p log-window)
        ;; When log window's point is at the end, follow the tail.
        (with-selected-window log-window
          (goto-char (point-max)))))))