1

as I already told I've installed rst2pdf docutil, but if I run

 M-x rst-compile-pdf-preview

I get a quick message saying that Ive to use C-c C-c C-p but, entering that, I obtain

You can run the command ‘rst-compile-pdf-preview’ with C-c C-c C-p

and if I made that I do not obtain nothing What I still have to do?

Thank you

Renato

RenatoP
  • 121
  • 4

3 Answers3

2

rst2pdf convert the document to a PDF file and launch a preview program.

Maybe emacs doesn't find the preview program (maybe you don't have xpdf installed or not in your path)

djangoliv
  • 3,169
  • 16
  • 31
  • it's like the compilation doesen't start. I just receive the message "You can run the command ‘rst-compile-pdf-preview’ with C-c C-c C-p". but if I also type it I have no feedback. The file.pdf is no produced. – RenatoP Aug 03 '22 at 10:53
  • Do `C-x b *Messages*` to visit your `*Messages*` buffer and see if there are any error messages that might help you. – NickD Aug 03 '22 at 12:48
  • Mark set Beginning of buffer [50 times] End of buffer [32 times] Beginning of buffer [36 times] is undefined ren.rst has auto save data; consider M-x recover-this-file Making completion list... You can run the command ‘rst-compile-pdf-preview’ with C-c C-c C-p End of buffer [14 times] Beginning of buffer [7 times] I cannot read anythings bad here. Do you? – RenatoP Aug 03 '22 at 13:53
  • Nope - you'll have to dig deeper... – NickD Aug 03 '22 at 14:40
  • I've never told that I'm working on Mac Osx 12.5 . Could it be important? – RenatoP Aug 04 '22 at 08:55
  • If you launch `xpdf`, do you have a graphical interface? – djangoliv Aug 04 '22 at 09:02
  • yes, Xpdfreader is open – RenatoP Aug 07 '22 at 09:56
  • yes, Xpdfreader is open But, back in emacs, I've opened two buffer:README.rst and *MESSAGES* to see what happen: if I give C-c C-c C-p or if run M-x rst-compile-pdf-previw, the *MESSAGES* buffer don't show nothing, like the command were not issued – RenatoP Aug 07 '22 at 10:41
2

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.

NickD
  • 27,023
  • 3
  • 23
  • 42
  • the first steps goes well, xpdf myfile.pdf show with xpdfreader the file But when on emacs I type C-x C-f myfile.rst and the C-c C-c C-p, nothing appens – RenatoP Aug 03 '22 at 16:59
  • Added some suggestions for debugging the Emacs side, since the system side seems OK. – NickD Aug 03 '22 at 17:52
  • emacs 28.1. When I run – RenatoP Aug 05 '22 at 15:06
  • - emacs 28.1 - 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’. It is bound to C-c C-c C-p. (rst-compile-pdf-preview) Convert the document to a PDF file and launch a preview program. I have the suspect that xpdf is not binded to emacs. on my mac previw program is the defaul program to open .pdf. How can I be sure that when I type C-C C-c C-p the command to create a .pdf are give to emacs? – RenatoP Aug 05 '22 at 15:12
  • What does `C-h v rst-pdf-program` say? It should be `xpdf` by default, but maybe it's different in your setup? – NickD Aug 05 '22 at 15:27
  • rst-pdf-program is a variable defined in ‘rst.el’. Its value is "xpdf" Program used to preview PDF files. This variable may be risky if used as a file-local variable. So, this show that my idea is not correct isn't it? – RenatoP Aug 05 '22 at 15:42
  • I give up - I don't know what could be wrong. Maybe you can find an experienced emacs user nearby (maybe at a local university?) and see if they can come up with a solution. – NickD Aug 05 '22 at 15:45
  • Can I check if the result of command: "C-x C-f myfile.rst and then do C-c C-c C-p The command that is executed under the covers" is similar to this? rst2pdf /tmp/rst/myfile.rst /tmp/rst_elikNHBA.pdf && xpdf /tmp/rst_elikNHBA.pdf ; rm /tmp/rst_elikNHBA.pdf – RenatoP Aug 05 '22 at 17:27
  • The way I got that command was by running `C-c C-c C-p` after I instrumented `rst-compile-pdf-preview` with [edebug](https://www.gnu.org/software/emacs/manual/html_node/elisp/Edebug.html) - you can try that but it does require some experience. – NickD Aug 05 '22 at 17:31
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/138312/discussion-between-renatop-and-nickd). – RenatoP Aug 05 '22 at 21:09
0

I've finaly solved the situation. I've installed a VM (Manjaro) and installed all the tool chain: emacs,python3 was already installed, docutils, rst2pdf,Xpdfreader. created my .rst file (emacs recognised the file type) and finaly with C-c C-c C-c O've created the .html and with C-c C-c C-p emacs has created the .pdf that was opened with Xpdfreader and the I safe it.

I made the same path on mac osx 12.5 but before I've removed the old installation of python 3 and installed a brand new python version. I think the prob was there. thank you to all that gave me indications and suggestion

Renato

RenatoP
  • 121
  • 4