2
votes

On Win7 with Emacs24 I encounter problems when Emacs programs want to open (pdf) files. The problems remain when I activate or deactivate openwith-mode. I either get a 'wrong-type-argument arrayp nil' message inside Emacs or Acrobat Reader is started but gives an error message 'can't open/find that file'.

I tried to debug it and always ended up in files.el. It seems that the name of the pdf-file to be opened is constructed by concatenating the absolute filename and the file extension .pdf. However, the filename-string given to AcroRd32 appears to look like this:

AcroRd32 "c:\\absolute\file\name".pdf

This doesn't work on the command line either. I have to change it (manually) to

AcroRd32 "c:\\absolute\file\name.pdf"

or to

AcroRd32 c:\\absolute\file\name.pdf

to make it work.

I don't know if this is considered a bug, or if it is a problem only for me. I tried to change the elisp code to something like

(format "%s" (concat absolute-filename file-extension))

to get rid of those double-quotes, but to no avail. And anyway, I don't feel comfortable to mess around in a basic library like files.el, and its really hard to edebug that library since its invoked permanently.

Maybe somebody encountered the same problem and found a solution?

[I use GNU Emacs 24.0.91.1 (i386-mingw-nt6.1.7601) of 2011-11-22 on MARVIN.]

PS 1 Test Case 1

I get the following error message when I do M-x toggle-debug-on-error and then try to open a pdf file in dired:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  file-truename(nil)
  find-file-noselect-1(#<buffer test.pdf<4>> "~/.emacs.d/org/projects/sandbox/test.pdf" nil nil "~/.emacs.d/org/projects/sandbox/test.pdf" ((2816 7 . 27468) (16087 . 35227)))
  find-file-noselect("c:/Users/tj2/.emacs.d/org/projects/sandbox/test.pdf" nil nil nil)
  find-file("c:/Users/tj2/.emacs.d/org/projects/sandbox/test.pdf")
  dired-find-file()
  call-interactively(dired-find-file nil nil)

and the following message:

Openwith mode enabled
find-file-noselect-1: Wrong type argument: arrayp, nil

Does it matter that my .emacs.d is really a windows symlink (mklink) to a Dropboxfolder?

PS 2 Test Case 2

here is the message I get in the maven-compile buffer, when doing C-c C-s (LilyPond-command-view) in a ,ly buffer:

-*- mode: compilation; default-directory: "~/.emacs.d/org/projects/sandbox/" -*-
Compilation started at Tue Dec 20 09:16:28

AcroRd32 "c:/Users/tj2/.emacs.d/org/projects/sandbox/2test".pdf

Compilation exited abnormally with code 1 at Tue Dec 20 09:16:35

In the message buffer I find

Compilation exited abnormally with code 1
Error during redisplay: (invalid-regexp "Unmatched ( or \\(")

This error doesn't trigger the debugger, although I did M-x toggle-debug-on-error.

2
Does this tip help? Do you have this problem in a released version of Emacs? Can you give a full test case that describes how to reproduce this?Michael Hoffman
I applied that patch to openwith.el, but to no avail - same error as before. There are actually two test cases: open a pdf file in dired (with f or C-m) -> gives "Wrong type argument: arrayp, nil", and opening a pdf file in lilypond-mode -> opens Acrobat Reader with an error message, something like "cannot open file".Thorsten

2 Answers

2
votes

Sounds like a bug, to me. Consider reporting it: M-x report-emacs-bug.

Dunno why Michael H. sent you to a Sunrise Commander page with a tip about OpenWith. Perhaps I'm missing something in your question where you indicate that you use one of those packages?

I would suggest reporting an Emacs bug. And if you want to see more about opening Windows apps associated with file types etc. then I'd suggest consulting this page.

0
votes

This seems to be a problem with openwith.el, so I don't think you'll get much help with an Emacs bug report since openwith.el is not part of Emacs.

I've found a similar error (I'm on Linux) and decided that it would be better to use a "cleaner" alternative that doesn't tweak find-file-noselect (see that page on emacs.sxe for why). The OpenWith wiki page pointed me to a less-popular little bit of glue code,

By default this package's run-associated-program is not well-integrated with the usual Emacs workflow, but here is how you can integrate it with helm-find-files (also documented at the above link).

(require 'run-assoc)
(setq associated-program-alist
      '(("evince" "\\.pdf$")
        ("play" "\\.mp3$")))

(defun helm-find-files-maybe-run-assoc (orig-fun &rest args)
  (let ((sel (helm-get-selection)))
    (if (string-match (mapconcat
               (lambda (x) (second x))
               associated-program-alist "\\|")
              (helm-get-selection))
    (run-associated-program sel)
      (apply orig-fun args))))

(advice-add 'helm-execute-selection-action
        :around #'helm-find-files-maybe-run-assoc)