Fool around with converting pdfs to html for dirvish preview. Broken.

This commit is contained in:
MitchMarq42 2022-07-20 17:31:42 -08:00
parent 7987d82e35
commit 826c6543ec

View File

@ -109,20 +109,36 @@
(use-package dirvish
:straight (:files (:defaults "extensions/*.el"))
:commands 'dirvish
:custom (dirvish-attributes '(all-the-icons collapse))
:init (dirvish-override-dired-mode)
(setq dirvish-attributes '(all-the-icons collapse))
(dirvish-define-preview exa (file)
"Use `exa' to generate directory preview."
:require ("exa") ; tell Dirvish to check if we have the executable
(when (file-directory-p file) ; we only interest in directories here
`(shell . ("exa" "--color=always" "-al" ,file)))) ; use the command output as preview
(add-to-list 'dirvish-preview-dispatchers 'exa)
(defun convert-pdf-to-html (pdf)
"Take PDF and convert it into a html file, which is returned.
Requires `mutool' to be installed and available in $PATH (it comes with MuPDF)."
(let ((html (file-name-with-extension pdf ".html")))
(shell-command (concat
(format
"mutool convert -F html -O preserve-images -o '%s' "
html) (format "'%s'" pdf))) html))
(defun view-pdf-in-webkit (pdf)
"View PDF in BUFFER by using `mutool'. This works by converting it to a
html file and viewing that file in `xwidget-webkit'. Requires `mutool' to be
installed and available in $PATH (it comes with MuPDF). Also requires Emacs to
be built with `xwidget' support."
(xwidget-webkit-browse-url
(format "file://%s" (convert-pdf-to-html pdf))))
(dirvish-define-preview pdf (file ext)
"Use `mupdf' and `xwidget-webkit' to generate pdf preview."
:require ("mutool")
(when (equal ext "pdf")
(if (featurep 'xwidget webkit)
(view-pdf-in-webkit file))))
(add-to-list 'dirvish-preview-dispatchers 'pdf)
(setq dired-listing-switches "-l --almost-all")
:hook (dirvish-mode . turn-off-line-numbers)
:general
(general-define-key
:states 'normal
:keymaps '(dirvish-mode-map local)
:keymaps 'dirvish-mode-map
"h" 'dired-up-directory
"l" 'dired-find-file
"/" 'dirvish-narrow)
@ -132,6 +148,8 @@
:prefix-map 'file-tree-map
:prefix "SPC t"
"t" 'dirvish-side))
;; Completion framework...
;; (use-package ivy
;; :diminish
@ -288,11 +306,15 @@
(airline-display-directory t)
(airline-eshell-colors nil)
(airline-shortened-directory-length 20)
(airline-utf-glyph-separator-left 9585)
(airline-utf-glyph-separator-right 9586)
;; (airline-utf-glyph-separator-left "")
;; (airline-utf-glyph-separator-right "")
:custom-face (mode-line ((t (:box (:line-width 2 :style released-button)))))
;; (airline-utf-glyph-separator-left 9585)
;; (airline-utf-glyph-separator-right 9586)
(airline-utf-glyph-separator-left (string-to-char ""))
(airline-utf-glyph-separator-right (string-to-char ""))
:custom-face
(mode-line
((t
(:box (:line-width 2 :style released-button)
(:height (:inherit 'fixed-pitch))))))
:config
;; (load-theme 'airline-kolor t)
(load-theme 'airline-ravenpower t))
@ -708,8 +730,8 @@
:custom (inferior-lisp-program "sbcl")
:init (load (expand-file-name "~/quicklisp/slime-helper.el")))
(use-package nyan-mode
:init (nyan-mode))
;; (use-package pdf-tools
;; :config (add-hook 'pdf-view-mode-hook 'turn-off-line-numbers))
(provide 'mitch-packages)
;;; mitch-packages.el ends here