Witam na mojej prywatnej stronie internetowej!
[If this is all Polish to you, click here: English]
Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.
Marcin ‘mbork’ Borkowski
As I wrote many times, I use pdf-tools as main pdf viewer. I thought that one thing that would be nice is being able to open pdfs in it from outside Emacs. For example, texdoc could use it instead of Evince (which is pretty nice, but it’s not Emacs!).
Finally, I sat down to it. (Of course, my solution is Linux-centric; it might work on a Mac, but I have no access to such a weird machine to check it.) The first step is to create an emacsclient.desktop file in ~/.local/share/applications:
[Desktop Entry] Name=Emacs Exec=emacsclient -r -a emacs Type=Application MimeType=application/pdf;text/plain;text/x-tex NoDisplay=false Terminal=false
You can add more MimeTypes if you want. Then you run update-desktop-database ~/.local/share/applications/ so that file managers (other than Dired) will know about “opening with Emacs”. Finally, make this the default for pdfs: xdg-mime default emacs-pdf.desktop application/pdf. And from now on, double-clicking a pdf in a graphical file manager or launching texdoc <package-name> will open pdf files in Emacs (using the current Emacs instance if the server is running).