1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Improve doc-type determination in doc-view

* lisp/doc-view.el (doc-view-set-doc-type): If buffer-file-name is not
set try the buffer-name to identify the doc type.
This commit is contained in:
Andrew G Cohen 2023-10-06 14:34:28 +08:00
parent e29eb0e0f1
commit 006d5b70f3

View file

@ -2092,35 +2092,35 @@ GOTO-PAGE-FN other than `doc-view-goto-page'."
(defun doc-view-set-doc-type () (defun doc-view-set-doc-type ()
"Figure out the current document type (`doc-view-doc-type')." "Figure out the current document type (`doc-view-doc-type')."
(let ((name-types (let ((name-types
(when buffer-file-name (cdr (assoc-string
(cdr (assoc-string (file-name-extension
(file-name-extension buffer-file-name) (or buffer-file-name (buffer-name (current-buffer))))
'( '(
;; DVI ;; DVI
("dvi" dvi) ("dvi" dvi)
;; PDF ;; PDF
("pdf" pdf) ("epdf" pdf) ("pdf" pdf) ("epdf" pdf)
;; EPUB ;; EPUB
("epub" epub) ("epub" epub)
;; PostScript ;; PostScript
("ps" ps) ("eps" ps) ("ps" ps) ("eps" ps)
;; DjVu ;; DjVu
("djvu" djvu) ("djvu" djvu)
;; OpenDocument formats. ;; OpenDocument formats.
("odt" odf) ("ods" odf) ("odp" odf) ("odg" odf) ("odt" odf) ("ods" odf) ("odp" odf) ("odg" odf)
("odc" odf) ("odi" odf) ("odm" odf) ("ott" odf) ("odc" odf) ("odi" odf) ("odm" odf) ("ott" odf)
("ots" odf) ("otp" odf) ("otg" odf) ("ots" odf) ("otp" odf) ("otg" odf)
;; Microsoft Office formats (also handled by the odf ;; Microsoft Office formats (also handled by the odf
;; conversion chain). ;; conversion chain).
("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf) ("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf)
("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf) ("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf)
;; CBZ ;; CBZ
("cbz" cbz) ("cbz" cbz)
;; FB2 ;; FB2
("fb2" fb2) ("fb2" fb2)
;; (Open)XPS ;; (Open)XPS
("xps" xps) ("oxps" oxps)) ("xps" xps) ("oxps" oxps))
t)))) t)))
(content-types (content-types
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))