我只有 mode-compile.el v2.29 可用,但在那个版本中,问题与您描述的完全一样,编译命令的参数没有正确转义,并且没有启用它的选项。
这有点 hack,但您应该能够重新定义相关函数,并在文件中正确转义文件名.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
它们也被设置的时候。