0

It's a while that a try to use emacs for compiling .rst as .pdf I made numerous proof, the last thing that came to mind is: how to be sure that emacs knows where rst2pdf is, i mean in wich directory. Is there a specific file where i must configure path of the routine that I use? It's strange that rst2html works, but rst2pdf doesn't (both reside on the same directory)

Renato

RenatoP
  • 121
  • 4
  • What were the exact commands in both cases? We cannot answer without knowing what was done. Did you solved the ```xpdf``` issue? – Ian Aug 14 '22 at 08:14
  • ./XpdfReader-linux64-4.04/xpdf pdf.pdf (pdf.pdf is the pdf file that I would open), I receive this message:"./XpdfReader-linux64-4.04/xpdf.bin: error while loading shared libraries: libicui18n.so.56: cannot open shared object file: No such file or directory" what can I do? – RenatoP Aug 15 '22 at 10:32
  • First add a tag to your question revealing the OS in question - I saw you have a macOS and switched to Debian - choose one to talk about. I used linux some twenty years ago and never come back. (I am on macOSX). Also I observed (read your chat with @NickD) you have messed up your path - in the first description appears python@3.10, followed later by python@3.9 and in another replay you state the ```rst2pdf``` is in path for python@3.9 - so yet is not found since the first one is taken and obviously is not there. – Ian Aug 15 '22 at 12:06
  • Do not use any virtual environment, since this introduces other complication(s). Be careful about the commands - i.e. while ```rst2pdf foo foo.pdf``` may work, the command to export to html should be ```rst2html.py foo foo.html``` (try in terminal ```which rst2html```). – Ian Aug 15 '22 at 12:12
  • IMHO at this time your xpdfreader installation is broken/incomplete. Maybe @NickD may help you. – Ian Aug 15 '22 at 12:15

1 Answers1

0

The snippet below modify the command rst-compile to compile to .pdf instead of .html. At any time you can revert to default (.html) by commenting the last line.

One mention: in the :init section you should modify the path "/usr/local/bin" to the python path where is the rst2pdf.


(use-package rst
  :defer t
  :diminish
  :init
  (setenv "PATH" (concat "/usr/local/bin:"
                       (getenv "PATH")))
  (add-to-list 'exec-path "/usr/local/bin")
  :config
  (setq auto-mode-alist
      (append '(("\\.txt$" . rst-mode)
                ("\\.rst$" . rst-mode)
                ("\\.rest$" . rst-mode)) auto-mode-alist))
  (setq rst-compile-primary-toolset 'pdf) ;;
  )

If xpdf troubles you, you can install the package pdf-tools.

Ian
  • 1,321
  • 10
  • 12
  • where do I can find the rst-compile? I mean: How can I paste your code to rst-compile? – RenatoP Aug 15 '22 at 13:33
  • ```rst-compile``` is a command, you can start it with ```M-x rst-compile``` which is bound to ```C-c C-c C-c```. You should copy/paste it into your ```init.el``` file - depends how you configured your Emacs(i.e. if you use other config files). Take care there is a call to the package ```use-package``` - do you use it? – Ian Aug 15 '22 at 13:46
  • No...I'm definitely a newbe in emacs. with command locate init.el, I've found this file. In wich one do I have to paste the code? locate init.el /Applications/Emacs.app/Contents/Resources/lisp/emulation/viper-init.el.gz /Applications/Emacs.app/Contents/Resources/lisp/emulation/viper-init.elc /Applications/Emacs.app/Contents/Resources/lisp/vc/ediff-init.el.gz /Applications/Emacs.app/Contents/Resources/lisp/vc/ediff-init.elc /Users/renatopontefice/old_sphinx/docutils-0.19/tools/editors/emacs/tests/init.el – RenatoP Aug 15 '22 at 14:13
  • How can I send you my init.el to see where do I can put your snippet? Or can I paste it wherever in init.el? (I don't know the lisp syntax) – RenatoP Aug 15 '22 at 14:32
  • No-no, nither one. Check in terminal ```ls -al``` and look for the folder ```.emacs.d``` - there should be already present; if not, create it and inside should reside your ```init.el``` file. Get some inspiration from https://github.com/daviwil/emacs-from-scratch (based on evil-mode) or .https://github.com/seagle0128/.emacs.d . Always in Emacs is available the command ```C-h i``` for documentation, and select the node ```Emacs``` and read it. – Ian Aug 16 '22 at 08:30
  • Warning (initialization): An error occurred while loading ‘/Users/renatopontefice/.emacs.d/init.el’: Symbol's function definition is void: use-package To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable logging I was looking if init.el was in correct path, and it seems yes. What is this error? with this code I should press C-c C-c C-p to obtain .pdf?It still doesn't happen – RenatoP Aug 16 '22 at 17:20
  • Post your code on GitHub and I will comment there. – Ian Aug 17 '22 at 07:50
  • sorry, I'm not practice of github, anyway, the code is the one you send me 2 or 3 days ago – RenatoP Aug 17 '22 at 17:14