Function: byte-compile-warning-prefix

byte-compile-warning-prefix is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile-warning-prefix LEVEL ENTRY)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
;; This is used as warning-prefix for the compiler.
;; It is always called with the warnings buffer current.
(defun byte-compile-warning-prefix (level entry)
  (let* ((inhibit-read-only t)
	 (dir (or byte-compile-root-dir default-directory))
	 (file (cond ((stringp byte-compile-current-file)
		      (format "%s:" (byte-compile-abbreviate-file
                                     byte-compile-current-file dir)))
		     ((bufferp byte-compile-current-file)
		      (format "Buffer %s:"
			      (buffer-name byte-compile-current-file)))
		     ;; We might be simply loading a file that
		     ;; contains explicit calls to byte-compile functions.
		     ((stringp load-file-name)
		      (format "%s:" (byte-compile-abbreviate-file
                                     load-file-name dir)))
		     (t "")))
         (offset (byte-compile--warning-source-offset))
	 (pos (if (and byte-compile-current-file offset)
		  (with-current-buffer byte-compile-current-buffer
                    (let (new-l new-c)
                      (save-excursion
                        (goto-char offset)
                        (setq new-l (1+ (count-lines (point-min)
                                                     (line-beginning-position)))
                              new-c (1+ (current-column)))
                        (format "%d:%d:" new-l new-c))))
		""))
	 (form (if (eq byte-compile-current-form :end) "end of data"
		 (or byte-compile-current-form "toplevel form"))))
    (when (or (and byte-compile-current-file
		   (not (equal byte-compile-current-file
			       byte-compile-last-logged-file)))
	      (and byte-compile-current-form
		   (not (eq byte-compile-current-form
			    byte-compile-last-warned-form))))
      (insert (format "\nIn %s:\n" form)))
    (when level
      (insert (format "%s%s " file pos))))
  (setq byte-compile-last-logged-file byte-compile-current-file
	byte-compile-last-warned-form byte-compile-current-form)
  entry)