2012-06-19 4 views
6

뻔뻔스럽고 간단한 질문입니다. Windows 7 64에서 Emacs 23.4.1의 CPerl 모드를 사용하여 C-c c을 사용하여 스크립트를 실행하면 Emacs는 경로를 따옴표로 묶지 않으므로 공백이있는 모든 디렉토리에서 Perl이 파일을 찾을 수 없게됩니다. "Can't open perl script "g:/foo/bar/first": No such file or directory"Perl : Perl 스크립트의 전체 경로에 따옴표를 추가하려면 어떻게해야합니까?

질문 : 나는 자신을있는 Perl 파일 이름을 전달할 때 이맥스는 따옴표를 사용하도록 어떻게 "C:/Perl64/bin\perl.exe -w g:/foo/bar/first second/myscript.pl" 이 오류 메시지를 생성?

편집 : @legoscia의 댓글에 대한 응답으로 원래 게시물을 편집하고 있으므로 어떤 이유로 ("브라우저 문제"로) 주석을 달 수 없습니다 : "C-c c는 명령 모드 컴파일을 실행합니다". Perl 메뉴에서 "실행"으로 표시됩니다.

+0

'C-c c'는 비표준 바인딩 인 것으로 보입니다. 'C-h c C-c c'라고 입력하면 어떻게됩니까? – legoscia

+1

'mode-compile.el'은 표준이 아닙니다. http://perso.tls.cena.fr/boubaker/distrib/mode-compile.el 또는 다른 것을 사용하고 있습니까? – phils

+0

@phils 의도적으로'mode-compile.el'을 사용하고있는 것이 아닙니다. - 설치를 시도한 기억이 없으며, 사용하는 유일한 언어가 해석되어서 직접적으로 그렇게 할 필요가 없습니다. (R, Perl) . 아마 그것은 ESS와 함께 설치된 무언가입니다 ...? Perl 스크립트가 버퍼에 있으면 주요 모드는 CPerl이고 부 모드는 Abbrev입니다. 분명히 다른 것은 없습니다. – SlowLearner

답변

2

나는 mode-compile.el v2.29 만 사용할 수 있습니다. 그러나 해당 버전에서 설명하는 것과 똑같은 문제가 발생합니다. 컴파일 명령의 인수가 올바르게 이스케이프되지 않으며 활성화 할 수있는 옵션이 없습니다.

그것은 해킹 약간입니다하지만 당신은 정확한 당신의 .emacs 파일이와 파일 이름을 탈출하여 관련 기능을 재정의 할 수 있어야한다 :

(eval-after-load 'mode-compile 
    '(progn 
    (defun mc--shell-compile (shell dbgflags &optional errors-regexp-alist) 
     ;; Run SHELL with debug flags DBGFLAGS on current-buffer 
     (let* ((shcmd (or (mc--which shell) 
          (error "Compilation abort: command %s not found" shell))) 
      (shfile (or mc--remote-pathname (buffer-file-name) 
          (error "Compilation abort: Buffer %s has no filename" 
           (buffer-name)))) 
      (run-cmd (concat shcmd " " dbgflags " " (shell-quote-argument shfile) " " 
           (setq mc--shell-args 
            (read-string (if mode-compile-expert-p 
                "Argv: " 
                (format "Arguments to %s %s script: " 
                  shfile shell)) 
               mc--shell-args))))) 
     ;; Modify compilation-error-regexp-alist if needed 
     (if errors-regexp-alist 
      (progn 
       ;; Set compilation-error-regexp-alist from compile 
       (or (listp errors-regexp-alist) 
        (error "Compilation abort: In mc--shell-compile errors-regexp-alist not a list.")) 
       ;; Add new regexp alist to compilation-error-regexp-alist 
       (mapcar '(lambda(x) 
         (if (mc--member x compilation-error-regexp-alist) nil 
          (setq compilation-error-regexp-alist 
           (append (list x) 
             compilation-error-regexp-alist)))) 
         errors-regexp-alist))) 
     ;; Run compile with run-cmd 
     (mc--compile run-cmd))))) 

내가 변화 라인이 변경되었다

(run-cmd (concat shcmd " " dbgflags " " shfile " " 

(run-cmd (concat shcmd " " dbgflags " " (shell-quote-argument shfile) " " 

에 더 완전한 수정도하는 것 dbgflags (그들이 설정되어있는 곳이면 전체 변수를 이스케이프하는 것만으로는 적합하지 않을 것입니다.)과 mc--shell-args을 설정하면 이스케이프됩니다.

+1

+1하지만 저자에게 글을 쓰고 소스를 수정하는 것이 좋습니다. 추신. elisp 코드에''접두사를 붙이면 Stack Overflow가 구문 강조를 올바르게합니다. – phils

+0

유용한 팁, 정말로 감사합니다. 실제로 패치를 업스트림으로 보내는 것이 현명한 방법입니다. –

관련 문제