6

恥ずかしいほど簡単な質問。Windows 764のEmacs23.4.1でCPerlモードを使用C-c cすると、スクリプトの実行に使用すると、Emacsはパスを引用符で囲みません。そのため、スペースのあるディレクトリがあると、Perlはファイルを見つけることができません。 "C:/Perl64/bin\perl.exe -w g:/foo/bar/first second/myscript.pl" このエラーメッセージを生成します: "Can't open perl script "g:/foo/bar/first": No such file or directory"

質問:ファイル名をPerl自体に渡すときにEmacsに引用符を使用させるにはどうすればよいですか?

編集:何らかの理由でコメントできません(おそらくブラウザの問題)ので、@ legosciaからのコメントに応じて元の投稿を編集しています:「Cccはコマンドモードを実行します-コンパイル」。Perlメニューでは、「実行」とマークされています。

4

1 に答える 1

2

私はmode-compile.elv2.29しか利用できませんが、そのバージョンでは、問題はあなたが説明したとおりであり、compileコマンドへの引数は適切にエスケープされず、それを有効にするオプションはありません。

これは少しハックですが、ファイル内でこれを使用してファイル名を正しくエスケープすることで、関連する関数を再定義できるはず.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設定されたときにもエスケープすることです。

于 2012-06-23T14:50:24.937 に答える