From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#33344: 26.1; doc-view bounding-box recognition doesn't work on path names with spaces Date: Mon, 12 Nov 2018 16:36:48 -0500 Message-ID: <9ein120yhb.fsf@fencepost.gnu.org> References: <2721782.Y6SdopJXAr@calvin> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1542058510 31425 195.159.176.226 (12 Nov 2018 21:35:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Nov 2018 21:35:10 +0000 (UTC) User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cc: 33344@debbugs.gnu.org To: Robert Spillner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 12 22:35:06 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gMJrN-00083L-35 for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Nov 2018 22:35:05 +0100 Original-Received: from localhost ([::1]:50756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJtT-0001Qp-DB for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Nov 2018 16:37:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJtJ-0001PY-Gb for bug-gnu-emacs@gnu.org; Mon, 12 Nov 2018 16:37:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJtH-0007g9-HK for bug-gnu-emacs@gnu.org; Mon, 12 Nov 2018 16:37:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMJtF-0007fT-TF for bug-gnu-emacs@gnu.org; Mon, 12 Nov 2018 16:37:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gMJtF-0002wc-Mv for bug-gnu-emacs@gnu.org; Mon, 12 Nov 2018 16:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Nov 2018 21:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33344 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33344-submit@debbugs.gnu.org id=B33344.154205862111312 (code B ref 33344); Mon, 12 Nov 2018 21:37:01 +0000 Original-Received: (at 33344) by debbugs.gnu.org; 12 Nov 2018 21:37:01 +0000 Original-Received: from localhost ([127.0.0.1]:48389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gMJtE-0002wN-QQ for submit@debbugs.gnu.org; Mon, 12 Nov 2018 16:37:01 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41250) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gMJtD-0002wA-3G for 33344@debbugs.gnu.org; Mon, 12 Nov 2018 16:36:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMJt6-0007Zk-Sq for 33344@debbugs.gnu.org; Mon, 12 Nov 2018 16:36:53 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMJt3-0007YE-Ow; Mon, 12 Nov 2018 16:36:50 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1gMJt2-0001uW-FQ; Mon, 12 Nov 2018 16:36:48 -0500 X-Spook: strategic Disaster Service disruption spy Response ASDIC X-Ran: {b2xl<8|2D8g~>33o~]=I3<44-u].W3~|ZPrECal>30Y`ko>Q-D3Wa6C}_hok1fSt&L]@{ X-Hue: cyan X-Attribution: GM In-Reply-To: <2721782.Y6SdopJXAr@calvin> (Robert Spillner's message of "Sun, 11 Nov 2018 12:36:04 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152326 Archived-At: Robert Spillner wrote: > in doc-view.el, line 1215, ghostscript is called via shell to grep the > bounding box of a ps or pdf-file. In line 1218, the last %s > (representing the filename) is used unquoted. Therefore, whenever the > filename or the directory pointing to this file has spaces in its name > gs won't be able to find it and determine a bounding box. > > Please change line 1218 from > > (format "-dFirstPage=%s -dLastPage=%s %s" > > to > > (format "-dFirstPage=%s -dLastPage=%s \"%s\"" Thanks for the report. I don't see a need for the shell to be involved at all here. The following seems to work for me - how about for you? --- i/lisp/doc-view.el +++ w/lisp/doc-view.el @@ -1204,25 +1204,30 @@ doc-view-set-slice-using-mouse (defun doc-view-get-bounding-box () "Get the BoundingBox information of the current page." - (let* ((page (doc-view-current-page)) - (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) - (if (file-exists-p cache-doc) - cache-doc - doc-view--buffer-file-name))) - (o (shell-command-to-string - (concat doc-view-ghostscript-program - " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox " - (format "-dFirstPage=%s -dLastPage=%s %s" - page page doc))))) - (save-match-data - (when (string-match (concat "%%BoundingBox: " - "\\([[:digit:]]+\\) \\([[:digit:]]+\\) " - "\\([[:digit:]]+\\) \\([[:digit:]]+\\)") o) - (mapcar #'string-to-number - (list (match-string 1 o) - (match-string 2 o) - (match-string 3 o) - (match-string 4 o))))))) + (let ((page (doc-view-current-page)) + (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) + (if (file-exists-p cache-doc) + cache-doc + doc-view--buffer-file-name)))) + (with-temp-buffer + (when (eq 0 (ignore-errors + (call-process doc-view-ghostscript-program nil t + nil "-dSAFER" "-dBATCH" "-dNOPAUSE" "-q" + "-sDEVICE=bbox" + (format "-dFirstPage=%s" page) + (format "-dLastPage=%s" page) + doc))) + (goto-char (point-min)) + (save-match-data + (when (re-search-forward + (concat "%%BoundingBox: " + "\\([[:digit:]]+\\) \\([[:digit:]]+\\) " + "\\([[:digit:]]+\\) \\([[:digit:]]+\\)") nil t) + (mapcar #'string-to-number + (list (match-string 1) + (match-string 2) + (match-string 3) + (match-string 4))))))))) (defvar doc-view-paper-sizes '((a4 595 842)