From 319cb5bd71b27b6e18fdccffd47f3321b9fe13c0 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Thu, 27 Oct 2022 00:49:22 +0200 Subject: [PATCH] Try to open pdf files properly in EWW --- README.org | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index febbf5f..ea3ac0e 100644 --- a/README.org +++ b/README.org @@ -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]]