M-x ghc-debug.

This commit is contained in:
Kazu Yamamoto 2014-04-25 14:31:09 +09:00
parent 549d33d492
commit 3e812a8bfe
2 changed files with 30 additions and 8 deletions

View File

@ -160,14 +160,15 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ghc-run-ghc-mod (cmds) (defun ghc-run-ghc-mod (cmds &optional prog)
(ghc-executable-find ghc-module-command (let ((target (or prog ghc-module-command)))
(let ((cdir default-directory)) (ghc-executable-find target
(with-temp-buffer (let ((cdir default-directory))
(cd cdir) (with-temp-buffer
(apply 'ghc-call-process ghc-module-command nil t nil (cd cdir)
(append (ghc-make-ghc-options) cmds)) (apply 'ghc-call-process target nil t nil
(buffer-substring (point-min) (1- (point-max))))))) (append (ghc-make-ghc-options) cmds))
(buffer-substring (point-min) (1- (point-max))))))))
(defmacro ghc-executable-find (cmd &rest body) (defmacro ghc-executable-find (cmd &rest body)
;; (declare (indent 1)) ;; (declare (indent 1))

View File

@ -7,6 +7,7 @@
;; Put the following code to your "~/.emacs". ;; Put the following code to your "~/.emacs".
;; ;;
;; (autoload 'ghc-init "ghc" nil t) ;; (autoload 'ghc-init "ghc" nil t)
;; (autoload 'ghc-debug "ghc" nil t)
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init))) ;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;; ;;
;; Or if you wish to display error each goto next/prev error, ;; Or if you wish to display error each goto next/prev error,
@ -103,4 +104,24 @@
(defun ghc-abbrev-init () (defun ghc-abbrev-init ()
(set (make-local-variable 'dabbrev-case-fold-search) nil)) (set (make-local-variable 'dabbrev-case-fold-search) nil))
;;;###autoload
(defun ghc-debug ()
(interactive)
(let ((el-path (locate-file "ghc.el" load-path))
(ghc-mod-path (executable-find ghc-module-command))
(ghc-modi-path (executable-find ghc-interactive-command))
(el-ver ghc-version)
(ghc-mod-ver (ghc-run-ghc-mod '("version")))
(ghc-modi-ver (ghc-run-ghc-mod '("version") ghc-interactive-command)))
(switch-to-buffer (get-buffer-create "**GHC Debug**"))
(erase-buffer)
(insert "Path: check if you are using intended programs.\n")
(insert (format "\tghc.el path: \t%s\n" el-path))
(insert (format "\tghc-mod path: \t%s\n" ghc-mod-path))
(insert (format "\tghc-modi path: \t%s\n" ghc-modi-path))
(insert "\nVersion: all versions must be the same.\n")
(insert (format "\t ghc.el version %s\n" el-ver))
(insert (format "\t %s\n" ghc-mod-ver))
(insert (format "\t%s\n" ghc-modi-ver))))
(provide 'ghc) (provide 'ghc)