aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2020-08-26 14:37:13 +0200
committerLars Ingebrigtsen2020-08-26 14:37:13 +0200
commitf68a8869d1b5d25855bdc5cb1654bb4c1b2a5cb2 (patch)
tree76413ac090bb855dd4f97951f4ceee54bebfa91d
parentbe7af20e732db65c33f5d41402675a403416ce7b (diff)
downloademacs-f68a8869d1b5d25855bdc5cb1654bb4c1b2a5cb2.tar.gz
emacs-f68a8869d1b5d25855bdc5cb1654bb4c1b2a5cb2.zip
Fix doc-view problem with file names with spaces in them
* lisp/doc-view.el (doc-view-get-bounding-box): Don't bug out on file names with spaces in them (bug#33344).
-rw-r--r--lisp/doc-view.el45
1 files changed, 25 insertions, 20 deletions
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 77c06a8eaf9..60f6d6350c9 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -1320,26 +1320,31 @@ dragging it to its bottom-right corner. See also
1320 1320
1321(defun doc-view-get-bounding-box () 1321(defun doc-view-get-bounding-box ()
1322 "Get the BoundingBox information of the current page." 1322 "Get the BoundingBox information of the current page."
1323 (let* ((page (doc-view-current-page)) 1323 (let ((page (doc-view-current-page))
1324 (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) 1324 (doc (let ((cache-doc (doc-view-current-cache-doc-pdf)))
1325 (if (file-exists-p cache-doc) 1325 (if (file-exists-p cache-doc)
1326 cache-doc 1326 cache-doc
1327 doc-view--buffer-file-name))) 1327 doc-view--buffer-file-name))))
1328 (o (shell-command-to-string 1328 (with-temp-buffer
1329 (concat doc-view-ghostscript-program 1329 (when (eq 0 (ignore-errors
1330 " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox " 1330 (process-file doc-view-ghostscript-program nil t
1331 (format "-dFirstPage=%s -dLastPage=%s %s" 1331 nil "-dSAFER" "-dBATCH" "-dNOPAUSE" "-q"
1332 page page doc))))) 1332 "-sDEVICE=bbox"
1333 (save-match-data 1333 (format "-dFirstPage=%s" page)
1334 (when (string-match (concat "%%BoundingBox: " 1334 (format "-dLastPage=%s" page)
1335 "\\([[:digit:]]+\\) \\([[:digit:]]+\\) " 1335 doc)))
1336 "\\([[:digit:]]+\\) \\([[:digit:]]+\\)") 1336 (goto-char (point-min))
1337 o) 1337 (save-match-data
1338 (mapcar #'string-to-number 1338 (when (re-search-forward
1339 (list (match-string 1 o) 1339 (concat "%%BoundingBox: "
1340 (match-string 2 o) 1340 "\\([[:digit:]]+\\) \\([[:digit:]]+\\) "
1341 (match-string 3 o) 1341 "\\([[:digit:]]+\\) \\([[:digit:]]+\\)")
1342 (match-string 4 o))))))) 1342 nil t)
1343 (mapcar #'string-to-number
1344 (list (match-string 1)
1345 (match-string 2)
1346 (match-string 3)
1347 (match-string 4)))))))))
1343 1348
1344(defvar doc-view-paper-sizes 1349(defvar doc-view-paper-sizes
1345 '((a4 595 842) 1350 '((a4 595 842)