Skip to content

Commit

Permalink
Precompute ghc supported options and languages
Browse files Browse the repository at this point in the history
Also, move option/language-pragma lists out of haskell-yas, because it's
nothing to do with yasnippet, and they are needed for completion.
  • Loading branch information
ikirill committed Jan 22, 2015
1 parent d9e533a commit f0f9800
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
12 changes: 12 additions & 0 deletions haskell-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ when Data.Map is the candidate.
:group 'shm
:type '(repeat 'string))

(defcustom haskell-ghc-supported-languages
(split-string (shell-command-to-string "ghc --supported-extensions"))
"List of language pragmas supported by the installed version of GHC."
:group 'haskell
:type '(repeat string))

(defcustom haskell-ghc-supported-options
(split-string (shell-command-to-string "ghc --show-options"))
"List of options supported by the installed version of GHC."
:group 'haskell
:type '(repeat string))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Accessor functions

Expand Down
12 changes: 0 additions & 12 deletions haskell-yas.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@
:group 'haskell
:prefix "haskell-yas-")

(defcustom haskell-yas-ghc-language-pragmas
(split-string (shell-command-to-string "ghc --supported-extensions"))
"List of language pragmas supported by the installed version of GHC."
:group 'haskell-yas
:type '(repeat string))

(defcustom haskell-yas-ghc-options
(split-string (shell-command-to-string "ghc --show-options"))
"List of options supported by the installed version of GHC."
:group 'haskell-yas
:type '(repeat string))

(defcustom haskell-yas-completing-function 'ido-completing-read
"Function to use for completing among alternatives."
:group 'haskell-yas
Expand Down
5 changes: 2 additions & 3 deletions haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
(require 'haskell-commands)
(require 'haskell-sandbox)
(require 'haskell-modules)
(require 'haskell-yas) ; import precomputed ghc options/pragmas

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Basic configuration hooks
Expand Down Expand Up @@ -80,7 +79,7 @@
(and (search-backward "{-#" nil t)
(search-forward-regexp "\\_<OPTIONS\\(?:_GHC\\)?\\_>" p t))))
(looking-back (rx symbol-start "-" (* (char alnum ?-)))))
(list (match-beginning 0) (match-end 0) haskell-yas-ghc-options))
(list (match-beginning 0) (match-end 0) haskell-ghc-supported-options))
;; Complete LANGUAGE :complete repl ":set -X..."
((and (nth 4 (syntax-ppss))
(save-excursion
Expand All @@ -89,7 +88,7 @@
(search-forward-regexp "\\_<LANGUAGE\\_>" p t))))
(setq symbol-bounds (bounds-of-thing-at-point 'symbol)))
(list (car symbol-bounds) (cdr symbol-bounds)
haskell-yas-ghc-language-pragmas))
haskell-ghc-supported-languages))
((setq symbol-bounds (bounds-of-thing-at-point 'symbol))
(cl-destructuring-bind (start . end) symbol-bounds
(list start end
Expand Down
2 changes: 1 addition & 1 deletion snippets/haskell-mode/lang-pragma
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# condition: (= (length "lang") (current-column))
# contributor: Luke Hoersten <[email protected]>, John Wiegley
# --
{-# LANGUAGE `(progn (require 'haskell-yas) (haskell-yas-complete "Extension: " haskell-yas-ghc-language-pragmas))` #-}
{-# LANGUAGE `(progn (require 'haskell-yas) (haskell-yas-complete "Extension: " haskell-ghc-supported-languages))` #-}

0 comments on commit f0f9800

Please sign in to comment.