Recently I am indulging in Emacs. I tried to use it as my LaTeX tool, so I installed pdf-tools. If I add
(pdf-tools-install)
in my init file, it will take about 2 seconds to start Emacs. So I want to write a function such that "pdf-tools-install" will run after I open a pdf file. But "add-hook" only works when a major mode is recognized, and we can recognize pdf only after pdf-tools is installed. I think it may relate to regex, but I don't know much about it. Could you help me with this function? Thanks!
(add-hook 'doc-view-mode-hook #'pdf-tools-install)
C-c C-c
in my documents it switches between pdfview and Docview so you could see if pdf-tools is initialize when the pdf is opened after applying politza answer.doc-view-mode
.