Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comint everywhere #1547

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,250 changes: 138 additions & 1,112 deletions doc/haskell-mode.texi

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions ghci-script-mode.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
;;; ghci-script-mode.el --- GHCi scripts major mode -*- lexical-binding: t -*-

;; Copyright (c) 2014 Chris Done. All rights reserved.
;; Copyright (c) 2017 Vasantha Ganesh Kanniappan <[email protected]>

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand All @@ -17,7 +18,7 @@

;;; Code:

(require 'haskell)
(require 'inf-haskell)

(defvar ghci-script-mode-keywords
;; The comment syntax can't be described simply in syntax-table.
Expand Down Expand Up @@ -55,12 +56,9 @@
(defun ghci-script-mode-load ()
"Load the current script file into the GHCi session."
(interactive)
(let ((buffer (haskell-session-interactive-buffer (haskell-session)))
(filename (buffer-file-name)))
(let ((filename (buffer-file-name)))
(save-buffer)
(with-current-buffer buffer
(set-marker haskell-interactive-mode-prompt-start (point-max))
(haskell-interactive-mode-run-expr
(concat ":script " filename)))))
(inferior-haskell-get-result (concat ":script " filename))
(message (format "Loaded %s" filename))))

(provide 'ghci-script-mode)
570 changes: 28 additions & 542 deletions haskell-commands.el

Large diffs are not rendered by default.

48 changes: 31 additions & 17 deletions haskell-completions.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
;;; Code:

(require 'haskell-mode)
(require 'haskell-process)
(require 'haskell-interactive-mode)
(require 'inf-haskell)

;;;###autoload
(defgroup haskell-completions nil
Expand Down Expand Up @@ -361,16 +360,9 @@ Returns nil if no completions available."
;; and haskell-completions-identifier-prefix
(let* ((is-import (eql typ 'haskell-completions-module-name-prefix))
(candidates
(when (and (haskell-session-maybe)
(not (haskell-process-cmd
(haskell-interactive-process)))
;; few possible extra checks would be:
;; (haskell-process-get 'is-restarting)
;; (haskell-process-get 'evaluating)
)
;; if REPL is available and not busy try to query it for
;; completions list in case of module name or identifier
;; prefixes
(progn
(if (not inferior-haskell-buffer)
(switch-to-haskell))
(haskell-completions-sync-complete-repl pfx is-import))))
;; append candidates with keywords
(list beg end (append
Expand All @@ -382,11 +374,33 @@ Returns nil if no completions available."
When optional IMPORT argument is non-nil complete PREFIX
prepending \"import \" keyword (useful for module names). This
function is supposed for internal use."
(haskell-process-get-repl-completions
(haskell-interactive-process)
(if import
(concat "import " prefix)
prefix)))
(inferior-haskell-get-completions
(if import
(concat "import " prefix)
prefix)))

(defun inferior-haskell-get-result-list (prefix)
"Get the completions from ghci using `:complete' and split by \n (and trim white spaces)"
(haskell-string-split-to-lines
(inferior-haskell-get-result
(concat
(format ":complete repl \"%s\""
prefix)))))

(defun inferior-haskell-get-completions (unsanitized-completions)
"gets the completions result list sanitizes and returns it, the first result
is meta data so we remove it"
(when (stringp unsanitized-completions)
(cdr (cl-mapcar #'inferior-haskell-sanitize
(inferior-haskell-get-result-list unsanitized-completions)))))

(defun inferior-haskell-sanitize (txt)
"the completions from ghci (using `:complete') are of the form
\"SomeCompletion1\"
\"SomeCompletion2\"
etc. So we trim the double quotes from the completion to get the string"
(when (stringp txt)
(haskell-string-trim-prefix "\"" (haskell-string-trim-suffix "\"" txt))))

(provide 'haskell-completions)
;;; haskell-completions.el ends here
Loading