Skip to content

Commit

Permalink
Replace completing-read-function with custom for haskell-mode
Browse files Browse the repository at this point in the history
This should be backwards compatible with emacs23, which does not have
completing-read-function
  • Loading branch information
markus1189 committed Feb 25, 2014
1 parent 1248ab0 commit 6ca09d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion ghc-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
;; and removal of commonly ignored annotations.

;;; Code:

(require 'haskell-mode)
(require 'haskell-font-lock)

Expand Down
13 changes: 10 additions & 3 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@
(require 'haskell-string)
(with-no-warnings (require 'cl))

(defvar completing-read-function)

;; FIXME: code-smell: too many forward decls for haskell-session are required here
(defvar haskell-session)
(declare-function haskell-process-do-try-info "haskell-process" (sym))
Expand Down Expand Up @@ -641,6 +639,15 @@ If nil, use the Hoogle web-site."
(const "ghc -fno-code")
(string :tag "Other command")))

(defcustom haskell-completing-read-function 'ido-completing-read
"Default function to use for completion."
:group 'haskell
:type '(choice
(function-item :tag "ido" :value ido-completing-read)
(function-item :tag "helm" :value helm--completing-read-default)
(function-item :tag "completing-read" :value completing-read)
(function :tag "Custom function")))

(defcustom haskell-stylish-on-save nil
"Whether to run stylish-haskell on the buffer before saving."
:group 'haskell
Expand Down Expand Up @@ -717,7 +724,7 @@ Brings up the documentation for haskell-mode-hook."
(cond ((save-excursion (forward-word -1)
(looking-at "^import$"))
(insert " ")
(let ((module (funcall completing-read-function "Module: " (haskell-session-all-modules))))
(let ((module (funcall haskell-completing-read-function "Module: " (haskell-session-all-modules))))
(insert module)
(haskell-mode-format-imports)))
((not (string= "" (save-excursion (forward-char -1) (haskell-ident-at-point))))
Expand Down
6 changes: 2 additions & 4 deletions haskell-process.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
(require 'haskell-navigate-imports)
(with-no-warnings (require 'cl))

(defvar completing-read-function)

;; FIXME: haskell-process shouldn't depend on haskell-interactive-mode to avoid module-dep cycles
(declare-function haskell-interactive-mode-echo "haskell-interactive-mode" (session message &optional mode))
(declare-function haskell-interactive-mode-compile-error "haskell-interactive-mode" (session message))
Expand Down Expand Up @@ -434,7 +432,7 @@ for various things, but is optional."
"Prompts for a Cabal command to run."
(interactive)
(haskell-process-do-cabal
(funcall completing-read-function "Cabal command: "
(funcall haskell-completing-read-function "Cabal command: "
haskell-cabal-commands)))

(defun haskell-process-add-cabal-autogen ()
Expand Down Expand Up @@ -757,7 +755,7 @@ now."
((> (length modules) 1)
(when (y-or-n-p (format "Identifier `%s' not in scope, choose module to import?"
ident))
(funcall completing-read-function "Module: " modules)))
(funcall haskell-completing-read-function "Module: " modules)))
((= (length modules) 1)
(when (y-or-n-p (format "Identifier `%s' not in scope, import `%s'?"
ident
Expand Down
5 changes: 2 additions & 3 deletions haskell-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@

(require 'haskell-cabal)
(require 'haskell-string)
(require 'haskell-mode)
(with-no-warnings (require 'cl))

(defvar completing-read-function)

(declare-function haskell-interactive-mode "haskell-interactive-mode" ())
(declare-function haskell-kill-session-process "haskell-process" (&optional session))
(declare-function haskell-process-start "haskell-process" (session))
Expand Down Expand Up @@ -202,7 +201,7 @@ If DONTCREATE is non-nil don't create a new session."
(defun haskell-session-choose ()
"Find a session by choosing from a list of the current sessions."
(when haskell-sessions
(let* ((session-name (funcall completing-read-function
(let* ((session-name (funcall haskell-completing-read-function
"Choose Haskell session: "
(mapcar 'haskell-session-name haskell-sessions)))
(session (find-if (lambda (session)
Expand Down

0 comments on commit 6ca09d0

Please sign in to comment.