The problem is probably incomplete or incorrect setup of the rst
utilities (and possibly xpdf
).
So forget about Emacs for the moment. Open a terminal running a shell and type this command:
rst2pdf myfile.rst myfile.pdf
where myfile.rst
is your input file. Did that produce a PDF? If not, you have to fix that first: do not go on until you can complete this step successfully.
When you have produced a PDF successfully, then try to preview it with this command:
xpdf myfile.pdf
Did that show you the PDF? If not, you have to fix this first: do not go on until you can preview the PDF.
Once both of these steps are successful, then, and only then, you can go back to Emacs: do C-x C-f myfile.rst
and then do C-c C-c C-p
. The command that is executed under the covers will be similar to this:
rst2pdf /tmp/rst/myfile.rst /tmp/rst_elikNHBA.pdf && xpdf /tmp/rst_elikNHBA.pdf ; rm /tmp/rst_elikNHBA.pdf
which is basically a combination of what I showed above. But note that the PDF is produced in a temporary file which is removed after the preview.
EDIT: The OP states in a comment that the two steps above go well, but when he visits the file in Emacs and does C-c C-c C-p
nothing happens. So we have to turn to debugging what Emacs is doing.
In the buffer of myfile.rst
, is the major mode reported as rst-mode
? You can check if that is the case, with C-h v major-mode
but be careful to do it in the correct buffer, that of myfile.rst
. It should say:
Its value is ‘rst-mode’
Original value was ‘fundamental-mode’
Local in buffer myfile.rst; global value is fundamental-mode
Does it?
If not, either your emacs does not include the rst.el
library or your auto-mode-alist
does not know that files with the rst
suffix should be in rst-mode
. Neither of these is likely
but you never know. BTW, please add the Emacs version to your question: do M-x emacs-version
to find it. You should always include the version in any question you ask in the future.
In that same buffer, do C-h k C-c C-c C-p
- it should say:
C-c C-c C-p runs the command rst-compile-pdf-preview (found in
rst-mode-map), which is an interactive compiled Lisp function in
‘rst.el’.
Does it?
If both of those are correct, it should all work: the file should be compiled into a (temporary) PDF file and xpdf
should open it for viewing; when you close xpdf
, the PDF file is removed. Note that while xpdf
is open, the PDF file still exists, so you can sneak in from a terminal and copy it somewhere else for safekeeping - it's only when xpdf
is closed that the PDF file is removed.
If it still does not work, then the only recourse I can suggest is to run the command under a debugger to see what's going on.
Also, if nothing happens, take another look at the *Messages*
buffer and see if there is anything of note in there. I would expect either success or an error message.
I should also mention that I've tried all this on my system and it works fine.