Function: compilation-fake-loc
compilation-fake-loc is a byte-compiled function defined in
compile.el.gz.
Signature
(compilation-fake-loc MARKER FILE &optional LINE COL)
Documentation
Preassociate MARKER with FILE.
FILE should be ABSOLUTE-FILENAME or (RELATIVE-FILENAME . DIRNAME). This is useful when you compile temporary files, but want automatic translation of the messages to the real buffer from which the temporary file came. This may also affect previous messages about FILE.
Optional args LINE and COL default to 1 and beginning of indentation respectively. The marker is expected to reflect this. In the simplest case the marker points to the first line of the region that was saved to the temp file.
If you concatenate several regions into the temp file (e.g. a header with variable assignments and a code region), you must call this several times, once each for the last line of one region and the first line of the next region.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/compile.el.gz
(defun compilation-fake-loc (marker file &optional line col)
"Preassociate MARKER with FILE.
FILE should be ABSOLUTE-FILENAME or (RELATIVE-FILENAME . DIRNAME).
This is useful when you compile temporary files, but want
automatic translation of the messages to the real buffer from
which the temporary file came. This may also affect previous messages
about FILE.
Optional args LINE and COL default to 1 and beginning of
indentation respectively. The marker is expected to reflect
this. In the simplest case the marker points to the first line
of the region that was saved to the temp file.
If you concatenate several regions into the temp file (e.g. a
header with variable assignments and a code region), you must
call this several times, once each for the last line of one
region and the first line of the next region."
(or (consp file) (setq file (list file)))
(compilation--flush-file-structure file)
(let ((fs (compilation-get-file-structure file)))
;; Between the current call to compilation-fake-loc and the first
;; occurrence of an error message referring to `file', the data is
;; only kept in the weak hash-table compilation-locs, so we need
;; to prevent this entry in compilation-locs from being GC'd
;; away. --Stef
(push fs compilation-gcpro)
(let ((loc (compilation-assq (or line 1) (cdr fs))))
(setq loc (compilation-assq col loc))
(cl-assert (null (cdr loc)))
(setcdr loc (compilation--make-cdrloc line fs marker))
loc)))