Subject: bug#18981: 24.3; gs and filenames with percent signs

From: [email-masked] (Юрий Пухальский)
Date: Fri, 07 Nov 2014 14:02:19 +0300

I've a file named: A13+Datasheet+-+v1.12+%282012-03-29%29.pdf
When I invoke docview (hitting return in dired), it doesn't work because
of percent signs in the file name: DocView: process pdf/ps->png changed status to exited abnormally with code 1.
Tracing docview I get:

1 -> doc-view-start-process: name="pdf/ps->png" program="gs" args=("-dSAFER" "-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4" "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET" "-r100" "-sOutputFile=/tmp/docview1000/A13+Datasheet+-+v1.12+%282012-03-29%29.pdf-1dc1b37082c745e206fc9363f828eb08/page-%d.png" "/home/pooh/work/srvdoc/A13+Datasheet+-+v1.12+%282012-03-29%29.pdf") callback=#[0 "\302\303\300!\304\305\306\307 \"\304\310%\210	\203\311	!\210\304\312p\313\"\207" [100 doc-view-current-timer write-region prin1-to-string nil expand-file-name "resolution.el" doc-view-current-cache-dir silently cancel-timer doc-view-display force] 6 "

(fn)"]

I see the percent signs from the filename verbatim in gs invocation, but
it's not allowed as they are (I think) getting to the printf-like
function (for %d in batches), and therefore must be presented as %%.

So the fix is easy: when preparing the invocation string for gs, change
single percent signs to double.

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu)
 of 2014-10-06 on pooh
Windowing system distributor `The X.Org Foundation', version 11.0.11500000
Configured using:
 `configure '--prefix=/usr' '--build=x86_64-pc-linux-gnu'
 '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man'
 '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc'
 '--localstatedir=/var/lib' '--libdir=/usr/lib64'
 '--disable-silent-rules' '--disable-dependency-tracking'
 '--program-suffix=-emacs-24' '--infodir=/usr/share/info/emacs-24'
 '--localstatedir=/var'
 '--enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64'
 '--with-gameuser=games' '--without-compress-info' '--without-hesiod'
 '--without-kerberos' '--without-kerberos5' '--without-gpm'
 '--without-dbus' '--without-gnutls' '--without-xml2'
 '--without-selinux' '--without-wide-int' '--with-sound' '--with-x'
 '--without-ns' '--without-gconf' '--without-gsettings'
 '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png'
 '--with-rsvg' '--with-tiff' '--with-xpm' '--without-imagemagick'
 '--without-xft' '--without-libotf' '--without-m17n-flt'
 '--with-x-toolkit=no' 'GENTOO_PACKAGE=app-editors/emacs-24.3-r6'
 'build_alias=x86_64-pc-linux-gnu' 'host_alias=x86_64-pc-linux-gnu'
 'CFLAGS=-O2 -pipe -march=k8' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed'
 'CPPFLAGS=''

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Dired by name

Minor modes in effect:
  bug-reference-mode: t
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  jabber-activity-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<left> <left> <left> <left> <backspace> C-e <return> 
M-p M-p <up> M-b M-b M-b <right> <right> <right> <backspace> 
M-b M-b M-b <right> <backspace> C-a # <return> M-p 
M-p M-b M-b M-b M-b M-b <right> <backspace> <return> 
M-p M-p C-a C-d <return> C-c C-c M-x m a n <return> 
g s <return> <S-next> <S-prior> <next> <M-next> M-> 
M-p M-p M-p C-a C-d <down> <down> <left> <left> <left> 
<left> M-p M-p <up> M-b M-b M-b <right> <right> <right> 
% <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> % 
<return> C-c C-c <help-echo> M-p C-a <down> M-f M-f 
M-f M-f M-f M-b <left> <left> C-d <down> <down> M-b 
M-b M-b M-b M-b M-b M-b M-b M-b <left> <left> <backspace> 
<return> C-c C-c C-x o C-x k <return> C-x o <down-mouse-1> 
<mouse-1> <down-mouse-1> <mouse-1> <down-mouse-5> <mouse-5> 
<double-down-mouse-5> <double-mouse-5> <triple-down-mouse-5> 
<triple-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<triple-down-mouse-5> <triple-mouse-5> <triple-down-mouse-5> 
<triple-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<down-mouse-4> <mouse-4> <double-down-mouse-4> <double-mouse-4> 
<triple-down-mouse-4> <triple-mouse-4> <triple-down-mouse-4> 
<triple-mouse-4> <down-mouse-5> <mouse-5> <double-down-mouse-5> 
<double-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<triple-down-mouse-5> <triple-mouse-5> <down-mouse-4> 
<mouse-4> <double-down-mouse-4> <double-mouse-4> <down-mouse-4> 
<mouse-4> <double-down-mouse-4> <double-mouse-4> <triple-down-mouse-4> 
<triple-mouse-4> <triple-down-mouse-4> <triple-mouse-4> 
<triple-down-mouse-4> <triple-mouse-4> <triple-down-mouse-4> 
<triple-mouse-4> <triple-down-mouse-4> <triple-mouse-4> 
<down-mouse-5> <mouse-5> <down-mouse-5> <mouse-5> <double-down-mouse-5> 
<double-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<triple-down-mouse-5> <triple-mouse-5> <triple-down-mouse-5> 
<triple-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<down-mouse-5> <mouse-5> <double-down-mouse-5> <double-mouse-5> 
<triple-down-mouse-5> <triple-mouse-5> <triple-down-mouse-5> 
<triple-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
<triple-down-mouse-5> <triple-mouse-5> <down-mouse-4> 
<mouse-4> <double-down-mouse-4> <double-mouse-4> <triple-down-mouse-4> 
<triple-mouse-4> <down-mouse-1> <mouse-1> $ d a t e 
s t r M-d C-x C-s M-x b u r <tab> <return> q C-h b 
C-g C-h h C-x k <return> C-h C-h C-g M-x b u g - <tab> 
<M-backspace> <backspace> <tab> <tab> m o <tab> <return> 
C-h f b u f - 0 <backspace> g <tab> <backspace> r <tab> 
e <tab> <backspace> <backspace> <backspace> <backspace> 
g - r e <tab> m <tab> <return> <help-echo> M-x r e 
p o r t <tab> e m <tab> <return>

Recent messages:
byte-code: End of buffer [2 times]
Saving file /home/pooh/work/freelance/mixpanel/get_events.sh...
Wrote /home/pooh/work/freelance/mixpanel/get_events.sh
Type "q" in help window to restore its previous buffer, C-M-v to scroll help.
Quit
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Making completion list...
Bug-Reference mode enabled

Load-path shadows:
/usr/share/emacs/site-lisp/emms/tq hides /usr/share/emacs/24.3/lisp/emacs-lisp/tq

Features:
(shadow emacsbug sendmail bug-reference thai-util thai-word view man
trace tar-mode calc-map calc-stat calc-vec calc-aent tabify org-table
pcmpl-gnu etags wdired pcmpl-linux arc-mode archive-mode time-stamp tcl
nroff-mode midnight calc-alg calc-ext calc-menu calc calc-loaddefs
calc-macs reposition vc-cvs vc-rcs vc-dir diff-mode add-log log-view
pcvs-util vc iso-transl parse-time sort smiley gnus-cite mail-extr
gnus-bcklg gnus-async gnus-ml disp-table qp timezone mm-archive url-http
url-gw url-cache url-auth url-handlers network-stream pop3 nnrss mm-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse url-vars nndraft nnmh nnfolder nnml
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 epg-config mm-view mml-smime smime dig gnus-cache gnus-sum
vc-dispatcher vc-svn autoconf-mode tramp-cmds mule-util conf-mode
org-element pcmpl-unix make-mode sql sgml-mode ruby-mode org-wl org-w3m
org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs org-html
org-exp ob-exp org-exp-blocks org-agenda org-info org-gnus org-docview
org-bibtex bibtex org-bbdb org warnings ob-tangle ob-ref ob-lob ob-table
org-footnote org-src ob-comint ob-keys org-pcomplete org-list org-faces
org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob
org-compat org-macs ob-eval org-loaddefs find-func cal-menu calendar
cal-loaddefs grep two-column js json thingatpt quail debug nxml-uchnm
rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri
rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok
doc-view jka-compr image-mode dabbrev help-mode skeleton vc-git
sh-script smie executable tramp-cache tramp-sh tramp tramp-compat
auth-source eieio byte-opt bytecomp byte-compile cconv password-cache
tramp-loaddefs pp cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs shell pcomplete compile
misearch multi-isearch dired-aux gnus-demon nntp gnus-group gnus-undo
nnmail mail-source gnus-start gnus-spec gnus-win nnoo gnus-int
gnus-range message cl-macs gv rfc822 mml easymenu mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus gnus-ems nnheader gnus-util
mail-utils mm-util mail-prsvr emms-cache emms-info-ogginfo
emms-info-mp3info emms-info later-do emms-playlist-mode
emms-player-mplayer emms-player-simple emms-source-playlist
emms-source-file dired emms-setup emms emms-compat server jabber
jabber-osd jabber-wmii jabber-xmessage jabber-festival jabber-sawfish
jabber-ratpoison jabber-screen jabber-socks5 jabber-ft-server
jabber-si-server jabber-ft-client jabber-ft-common jabber-si-client
jabber-si-common jabber-feature-neg jabber-truncate jabber-time
jabber-autoaway jabber-vcard-avatars jabber-chatstates jabber-events
jabber-vcard jabber-avatar mailcap jabber-activity jabber-watch
jabber-modeline advice help-fns advice-preload jabber-ahc-presence
jabber-ahc jabber-version jabber-ourversion jabber-muc-nick-completion
hippie-exp comint ansi-color ring jabber-browse jabber-search
jabber-register jabber-roster format-spec jabber-presence assoc
jabber-muc jabber-newdisco jabber-widget jabber-disco wid-edit
jabber-chat ewoc jabber-history jabber-chatbuffer jabber-alert jabber-iq
jabber-keymap jabber-core jabber-sasl sasl sasl-anonymous sasl-login
sasl-plain fsm jabber-logon cl cl-lib jabber-conn srv dns starttls tls
jabber-xml xml jabber-menu jabber-autoloads jabber-util site-gentoo
w3m-load edmacro kmacro imenu emms-auto time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dynamic-setting x multi-tty emacs)