2011-12-19 49 views
2

在Emacs24的Win7上,當Emacs程序想要打開(pdf)文件時遇到問題。激活或禁用openwith-mode時,問題依然存在。我要麼在Emacs裏面得到一個'錯誤類型參數安靜的'nil'消息,要麼啓動Acrobat Reader,但是會給出錯誤消息'無法打開/找到那個文件'。Emacs lisp - win7上文件名字符串的問題

我試圖調試它,總是以files.el結尾。 似乎要打開的pdf文件的名稱是通過連接絕對文件名和文件擴展名.pdf構造的。但是,爲AcroRd32提供的文件名字符串看起來像這樣:

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

這在命令行上也不起作用。我必須(手動)將其更改爲

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

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

,使其工作。

我不知道這是否被認爲是一個錯誤,或者它只是一個問題。我試圖將elisp代碼更改爲類似於

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

擺脫這些雙引號,但無濟於事。無論如何,我不想在像files.el這樣的基本庫中亂搞,而且永久性地調用它之後,很難對該庫進行edebug。

也許有人遇到同樣的問題,並找到了解決辦法?

[I使用GNU Emacs的24.0.91.1上MARVIN的2011-11-22(I386-的mingw-nt6.1.7601)。]

PS 1個測試例1

我得到以下錯誤消息當我做的Mx撥動調試的錯誤,然後嘗試在dired打開PDF文件:

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) 

和以下消息:

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

我的.emacs.d是一個真正的Windows符號鏈接(mklink)到Dropbox文件夾嗎?

PS 2測試案例2

這裏是我在Maven編譯緩衝區得到消息,做抄送CS(LilyPond的命令視圖)在,LY緩衝區時:

-*- 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 

在消息緩衝區中我發現

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

這個錯誤不會觸發調試器,雖然我做了Mx toggle-debug-on-error。

+0

確實[這個技巧](http://www.emacswiki.org/emacs/Sunrise_Commander_Tips#ExternalApps)幫助?你在發佈的Emacs版本中有這個問題嗎?你能給出一個完整的測試用例來描述如何重現這個? – 2011-12-19 19:17:58

+0

我將該補丁應用於openwith.el,但無濟於事 - 與以前相同的錯誤。實際上有兩個測試用例:在dired(用f或Cm)打開pdf文件 - >給出「錯誤的類型參數:arrayp,nil」,並在lilypond-mode中打開pdf文件 - >打開Acrobat Reader並顯示一條錯誤消息,就像「無法打開文件」。 – Thorsten 2011-12-20 01:27:32

回答

2

聽起來像一個錯誤,對我來說。考慮報告它:。

不知道爲什麼邁克爾閣下送你到一個Sunrise Commander頁面與小費約OpenWith。也許我在你的問題中錯過了某些東西,表明你使用了其中的一個軟件包?

我會建議報告一個Emacs錯誤。如果你想了解更多關於打開與文件類型相關的Windows應用程序等,那麼我建議諮詢this page

+0

嗯,我確實使用openwith-mode,並且它在linux上正常工作。我會嘗試報告它 - 我的第一個錯誤報告;) – Thorsten 2011-12-20 01:08:23

+0

我不確定這是一個連貫的單一錯誤。這可能是兩個不同的問題。當我在Windows上的Emacs 23.3.1上用'C-m'打開PDF時,它會進入'doc-view-mode',在那裏我得到'wrong-type-argument stringp nil'。但與Acrobat無關。不過,我不確定我是否設置了使文檔視圖模式在Windows上工作所需的所有庫和實用程序。 – 2011-12-20 02:04:11

+0

報告錯誤,提供儘可能多的信息,儘可能多地提供相關信息,最好包括一個連貫的配方來重現它,從'emacs -Q'開始。 Emacs維護人員將確定是否有錯誤(或兩個)。 – Drew 2011-12-21 00:56:14

0

這似乎是openwith.el的一個問題,所以我認爲你不會得到Emacs bug報告的很多幫助,因爲openwith.el不是Emacs的一部分。

我發現了一個類似的錯誤(我在Linux上),並決定使用「更乾淨」的替代方法並不會調整find-file-noselect(請參閱emacs.sxe上的原因)。該OpenWith wiki page向我指出的膠水代碼不太流行點點,

默認情況下,這個包的run-associated-program未與良好集成通常的Emacs工作流程,但這裏是如何將它與​​(也記錄在上面的鏈接中)集成在一起。

(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)