From: Andrew G Cohen Date: Fri, 6 Oct 2023 06:34:28 +0000 (+0800) Subject: Improve doc-type determination in doc-view X-Git-Tag: archive/raspbian/1%30.1+1-3+rpi1^2~2^2~20^2~1571 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=006d5b70f343d95c7154632a2b59056d940018d5;p=emacs.git 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. --- diff --git a/lisp/doc-view.el b/lisp/doc-view.el index c4b384c35c6..4ae9a5e6629 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -2092,35 +2092,35 @@ GOTO-PAGE-FN other than `doc-view-goto-page'." (defun doc-view-set-doc-type () "Figure out the current document type (`doc-view-doc-type')." (let ((name-types - (when buffer-file-name - (cdr (assoc-string - (file-name-extension buffer-file-name) - '( - ;; DVI - ("dvi" dvi) - ;; PDF - ("pdf" pdf) ("epdf" pdf) - ;; EPUB - ("epub" epub) - ;; PostScript - ("ps" ps) ("eps" ps) - ;; DjVu - ("djvu" djvu) - ;; OpenDocument formats. - ("odt" odf) ("ods" odf) ("odp" odf) ("odg" odf) - ("odc" odf) ("odi" odf) ("odm" odf) ("ott" odf) - ("ots" odf) ("otp" odf) ("otg" odf) - ;; Microsoft Office formats (also handled by the odf - ;; conversion chain). - ("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf) - ("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf) - ;; CBZ - ("cbz" cbz) - ;; FB2 - ("fb2" fb2) - ;; (Open)XPS - ("xps" xps) ("oxps" oxps)) - t)))) + (cdr (assoc-string + (file-name-extension + (or buffer-file-name (buffer-name (current-buffer)))) + '( + ;; DVI + ("dvi" dvi) + ;; PDF + ("pdf" pdf) ("epdf" pdf) + ;; EPUB + ("epub" epub) + ;; PostScript + ("ps" ps) ("eps" ps) + ;; DjVu + ("djvu" djvu) + ;; OpenDocument formats. + ("odt" odf) ("ods" odf) ("odp" odf) ("odg" odf) + ("odc" odf) ("odi" odf) ("odm" odf) ("ott" odf) + ("ots" odf) ("otp" odf) ("otg" odf) + ;; Microsoft Office formats (also handled by the odf + ;; conversion chain). + ("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf) + ("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf) + ;; CBZ + ("cbz" cbz) + ;; FB2 + ("fb2" fb2) + ;; (Open)XPS + ("xps" xps) ("oxps" oxps)) + t))) (content-types (save-excursion (goto-char (point-min))