From 545f0557f2a2a4134da7ab7fa0b55e9fb91b65f4 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Tue, 15 Sep 2015 12:14:36 +0900 Subject: [PATCH] ensuring that root ends with a file separator. --- elisp/ghc-func.el | 11 ++++++----- elisp/ghc-process.el | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index 34eff59..886e552 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -207,12 +207,13 @@ (defun ghc-run-ghc-mod (cmds &optional prog) (let ((target (or prog ghc-module-command))) (ghc-executable-find target - (let ((cdir default-directory)) + (let ((cdir (or ghc-process-root ;; ghc-mod version/debug + default-directory))) ;; ghc-mod root (with-temp-buffer - (cd cdir) - (apply 'ghc-call-process target nil t nil - (append (ghc-make-ghc-options) cmds)) - (buffer-substring (point-min) (1- (point-max)))))))) + (let ((default-directory cdir)) + (apply 'ghc-call-process target nil t nil + (append (ghc-make-ghc-options) cmds)) + (buffer-substring (point-min) (1- (point-max))))))))) (defmacro ghc-executable-find (cmd &rest body) ;; (declare (indent 1)) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index db9f8f1..75be11d 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -42,7 +42,7 @@ (if hook1 (funcall hook1)) (let* ((cbuf (current-buffer)) (name ghc-process-process-name) - (root ghc-process-process-name) + (root (file-name-as-directory ghc-process-process-name)) (buf (get-buffer-create (concat " ghc-mod:" name))) (file (buffer-file-name)) (cpro (get-process name))) @@ -51,7 +51,7 @@ (setq ghc-process-original-file file) (setq ghc-process-hook hook2) (setq ghc-process-root root) - (let ((pro (ghc-get-process cpro name buf)) + (let ((pro (ghc-get-process cpro name buf root)) (map-cmd (format "map-file %s\n" file))) ;; map-file (unless skip-map-file @@ -86,18 +86,18 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defun ghc-get-process (cpro name buf) - (let ((default-directory name)) - (cond - ((not cpro) - (ghc-start-process name buf)) - ((not (eq (process-status cpro) 'run)) - (delete-process cpro) - (ghc-start-process name buf)) - (t cpro)))) +(defun ghc-get-process (cpro name buf root) + (cond + ((not cpro) + (ghc-start-process name buf root)) + ((not (eq (process-status cpro) 'run)) + (delete-process cpro) + (ghc-start-process name buf root)) + (t cpro))) -(defun ghc-start-process (name buf) - (let* ((process-connection-type nil) ;; using PIPE due to ^D +(defun ghc-start-process (name buf root) + (let* ((default-directory root) + (process-connection-type nil) ;; using PIPE due to ^D (opts (append ghc-debug-options '("-b" "\n" "-l" "--line-prefix=O: ,E: ") (ghc-make-ghc-options)