There are a few issues here on the AUCTeX's side.
The first, most important, is that AUCTeX doesn't handle the case in which the TeX file and the bibliography file share the same base name (e.g., the former is named mydocument.tex, and the latter mydocument.bib). That's an unfortunate design decision taken decades ago, which is difficult to fix nowadays without a substantial rewriting. I'd like to fix this issue, but this would basically be highly backward incompatible.
The second issue is that when AUCTeX parses the file it doesn't translate \jobname with the actual job name. This would be much easier to fix, but \jobname is often used to refer to files with the same base name as the master file, like in this case, so fixing the present issue would be useless, given the issue mentioned above.
The last issue is related to how AUCTeX guesses the command to run. It looks to the .bib and .bbl file: If the .bib file is newer than the .bbl file, it's necessary to run biber (or bibtex or whatever) again. However, if you insert the bibliography database inside the TeX file with the filecontents environment, every time you run latex, the .bib file is regenerated, so it's always newer than the .bbl file, thus confusing the mechanism used in AUCTeX to determine which command to run: AUCTeX would suggest to run the infinite sequence LaTeX (this creates the .bib file), then Biber (because there is no .bbl file), LaTeX (this regenerates the .bib file), Biber (because the .bib file now is newer than the .bbl file), LaTeX (this regenerates the .bib file), Biber (because the .bib file now is newer than the .bbl file), etc... Actually, there will be no infinite loop because AUCTeX will run a sequence of maximum 12 commands, but anyway not very useful.
Moral of this history:
- Avoid using
\jobname if you want to rely on AUCTeX ability to parse the file.
- Don't use a bibliography file with the same base name as the TeX file, essentially for the same reason as the previous point.
- If you want to use the
filecontents environment you'll need to run latex and biber manually with C-c C-c. Using C-c C-a would enter an infinite loop (not real infinite, it'd be a sequence of LaTeX - Biber repeated 6 times each).
However note that filecontents is usually employed to write simple self-contained examples. Real-world documents, however, have an external bibliography file. In this case, you won't have any problems, provided the bibliography file has a base name different from the TeX file's.
\addbibresource{mybib.bib}. After replacing it with\bibliography{mybib},biberis suggested correctly. However, nowViewis never suggested andbiber-->latexare repeated forever... – Robinaut May 15 '17 at 10:05.bibfile is newer than the.bbl, but with thefilecontentsmechanism the.bibfile is always newer than the.bbl, after a LaTeX run.C-c C-ais useful when AUCTeX can correctly guess the right sequence of commands to be run, otherwise you can manually run the command you with the good oldC-C C-c;-) – giordano May 15 '17 at 10:22filecontentsis useful for preparing self-contained examples, but for real-world documents I'd use a separated bibliography file. AUCTeX doesn't have problems in that case ;-) (The only limitation is that you can't have the bibliography file with the same base name as the TeX file, that was a really bad design decision and this is quite hard to fix.) – giordano May 15 '17 at 10:36latexmkcommand to AucTeX. – Paul Gaborit May 16 '17 at 01:17