Try to open pdf files properly in EWW

This commit is contained in:
Gerard Vermeulen 2022-10-27 00:49:22 +02:00
parent 61697f07e5
commit 319cb5bd71

View File

@ -829,6 +829,7 @@ defined in this Org file.
(smart-latex-engrave-org-source-blocks :no-manual t)
(toggle-engrave-faces-latex-face-apply-override :no-manual t)
(toggle-engrave-faces-latex-face-mapper-override :no-manual t)
(toggle-eww-display-pdf-around :no-manual t)
(toggle-org-babel-python-format-session-value-override :no-manual t)
"Python"
(choose-common-python-interpreter :no-manual t))))
@ -4960,11 +4961,15 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
nil t)))))
#+end_src
#+caption[Configure =eww= rendering]:
#+caption: Configure =eww= rendering.
#+name: lst:configure-eww-rendering
#+caption[Rename =eww= buffers and display =pdf= links properly]:
#+caption: Rename =eww= buffers and display =pdf= links properly.
#+name: lst:rename-eww-buffer-display-pdf-links
#+begin_src emacs-lisp
(with-eval-after-load 'eww
(defun eww-display-pdf-as-binary (fn &rest args)
(let ((buffer-file-coding-system 'binary))
(apply fn args)))
(defun eww-rename-buffer ()
"Rename the buffer using title or url."
(let* ((title (plist-get eww-data :title))
@ -4972,6 +4977,14 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
(rename-buffer (format "*%s # eww*" name) t)))
(add-hook 'eww-after-render-hook #'eww-rename-buffer))
(with-eval-after-load 'emacs
(defun toggle-eww-display-pdf-around ()
"Toggle `eww-display-advice' advice."
(interactive)
(toggle-advice 'eww-display-pdf :around #'eww-display-pdf-as-binary))
(toggle-eww-display-pdf-around))
#+end_src
*** [[https://en.wikipedia.org/wiki/Media_type#Mailcap][Mailcap]]