From 6ae822f00e513a11a42be72946282d1290e0b159 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Fri, 14 Mar 2014 14:01:07 +0900 Subject: [PATCH] defining ghc-debug. --- elisp/ghc-comp.el | 4 ++-- elisp/ghc-doc.el | 4 ++-- elisp/ghc-func.el | 20 +++++++++++++++++++- elisp/ghc-info.el | 2 +- elisp/ghc-ins-mod.el | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/elisp/ghc-comp.el b/elisp/ghc-comp.el index 4dac92c..674ac4e 100644 --- a/elisp/ghc-comp.el +++ b/elisp/ghc-comp.el @@ -100,7 +100,7 @@ unloaded modules are loaded") (ghc-read-lisp-list (lambda () (message "Initializing...") - (call-process ghc-module-command nil t nil "-l" "boot") + (ghc-call-process ghc-module-command nil t nil "-l" "boot") (message "Initializing...done")) n))) @@ -109,7 +109,7 @@ unloaded modules are loaded") (ghc-read-lisp-list (lambda () (message "Loading names...") - (apply 'call-process ghc-module-command nil '(t nil) nil + (apply 'ghc-call-process ghc-module-command nil '(t nil) nil `(,@(ghc-make-ghc-options) "-l" "browse" ,@mods)) (message "Loading names...done")) (length mods)))) diff --git a/elisp/ghc-doc.el b/elisp/ghc-doc.el index 37b8035..0317be6 100644 --- a/elisp/ghc-doc.el +++ b/elisp/ghc-doc.el @@ -34,7 +34,7 @@ (defun ghc-resolve-package-name (mod) (with-temp-buffer - (call-process "ghc-pkg" nil t nil "find-module" "--simple-output" mod) + (ghc-call-process "ghc-pkg" nil t nil "find-module" "--simple-output" mod) (goto-char (point-min)) (when (re-search-forward "\\([^ ]+\\)-\\([0-9]*\\(\\.[0-9]+\\)*\\)$" nil t) (ghc-make-pkg-ver @@ -43,7 +43,7 @@ (defun ghc-resolve-document-path (pkg) (with-temp-buffer - (call-process "ghc-pkg" nil t nil "field" pkg "haddock-html") + (ghc-call-process "ghc-pkg" nil t nil "field" pkg "haddock-html") (goto-char (point-max)) (forward-line -1) (beginning-of-line) diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index 4514df1..8d2f533 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -166,7 +166,7 @@ (let ((cdir default-directory)) (with-temp-buffer (cd cdir) - (apply 'call-process ghc-module-command nil t nil + (apply 'ghc-call-process ghc-module-command nil t nil (append (ghc-make-ghc-options) cmds)) (buffer-substring (point-min) (1- (point-max))))))) @@ -178,4 +178,22 @@ (put 'ghc-executable-find 'lisp-indent-function 1) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar ghc-debug nil) + +(defvar ghc-debug-buffer "*GHC Debug*") + +(defun ghc-call-process (cmd x y z &rest args) + (when ghc-debug + (with-current-buffer (set-buffer (get-buffer-create ghc-debug-buffer)) + (goto-char (point-max)) + (insert (format "%% %s %s\n" cmd (mapconcat 'identity args " "))))) + (apply 'call-process cmd x y z args) + (when ghc-debug + (let ((cbuf (current-buffer))) + (with-current-buffer (set-buffer (get-buffer-create ghc-debug-buffer)) + (goto-char (point-max)) + (insert-buffer-substring cbuf))))) + (provide 'ghc-func) diff --git a/elisp/ghc-info.el b/elisp/ghc-info.el index 7385717..5e4ea27 100644 --- a/elisp/ghc-info.el +++ b/elisp/ghc-info.el @@ -119,7 +119,7 @@ (ghc-read-lisp (lambda () (cd cdir) - (apply 'call-process ghc-module-command nil t nil + (apply 'ghc-call-process ghc-module-command nil t nil `(,@(ghc-make-ghc-options) "-l" "type" ,file ,modname ,ln ,cn)) (goto-char (point-min)) (while (search-forward "[Char]" nil t) diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index 5fc1515..3c305ad 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -53,7 +53,7 @@ (concat "(" fn ")"))) (regex (concat "^\\([a-zA-Z0-9.]+\\) " fn1 " ")) ret) - (call-process ghc-hoogle-command nil t nil "search" fn1) + (ghc-call-process ghc-hoogle-command nil t nil "search" fn1) (goto-char (point-min)) (while (re-search-forward regex nil t) (setq ret (cons (match-string 1) ret)))