summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew G Cohen <cohen@andy.bu.edu>2023-10-06 14:34:28 +0800
committerAndrew G Cohen <cohen@andy.bu.edu>2024-05-10 08:25:48 +0800
commit006d5b70f343d95c7154632a2b59056d940018d5 (patch)
tree83d76ddefc8fcffe1a854cf854ae45b4caf9b50d
parente29eb0e0f18d7b1e4724c1bb26ff9718fe08548b (diff)
downloademacs-006d5b70f343d95c7154632a2b59056d940018d5.tar.gz
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.
-rw-r--r--lisp/doc-view.el58
1 files changed, 29 insertions, 29 deletions
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))