Inserting instance initial body now works :)
This commit is contained in:
parent
a45fb4c6f5
commit
90abb89a98
@ -252,7 +252,7 @@ initialBody fname args =
|
|||||||
arglist -> if isSymbolName fname
|
arglist -> if isSymbolName fname
|
||||||
then (head arglist) ++ " " ++ fname ++ " " ++ (intercalate " " (tail arglist))
|
then (head arglist) ++ " " ++ fname ++ " " ++ (intercalate " " (tail arglist))
|
||||||
else fname ++ " " ++ (intercalate " " arglist)
|
else fname ++ " " ++ (intercalate " " arglist)
|
||||||
++ " = _" ++ fname ++ "_body"
|
++ " = " ++ (if isSymbolName fname then "" else '_':fname) ++ "_body"
|
||||||
|
|
||||||
initialBodyArgs :: [FnArg] -> [String] -> [String] -> [String]
|
initialBodyArgs :: [FnArg] -> [String] -> [String] -> [String]
|
||||||
initialBodyArgs [] _ _ = []
|
initialBodyArgs [] _ _ = []
|
||||||
|
@ -39,4 +39,31 @@
|
|||||||
(cmd (format "split %s %s %s\n" file ln cn)))
|
(cmd (format "split %s %s %s\n" file ln cn)))
|
||||||
(ghc-sync-process cmd)))
|
(ghc-sync-process cmd)))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;
|
||||||
|
;;; Initial code from signature
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(defun ghc-initial-code-from-signature ()
|
||||||
|
(interactive)
|
||||||
|
(let ((info (ghc-obtain-initial-code-from-signature)))
|
||||||
|
(if (null info)
|
||||||
|
(message "Cannot obtain initial code")
|
||||||
|
(let* ((ln-current (line-number-at-pos))
|
||||||
|
(pos (car info))
|
||||||
|
(ln-end (ghc-sinfo-get-end-line pos))
|
||||||
|
(ln-diff (+ 1 (- ln-end ln-current)))
|
||||||
|
(fns-to-insert (cadr info)))
|
||||||
|
(goto-char (line-end-position ln-diff))
|
||||||
|
(dolist (fn-to-insert fns-to-insert)
|
||||||
|
(newline-and-indent)
|
||||||
|
(insert fn-to-insert))))))
|
||||||
|
|
||||||
|
(defun ghc-obtain-initial-code-from-signature ()
|
||||||
|
(let* ((ln (int-to-string (line-number-at-pos)))
|
||||||
|
(cn (int-to-string (1+ (current-column))))
|
||||||
|
(file (buffer-file-name))
|
||||||
|
(cmd (format "sig %s %s %s\n" file ln cn)))
|
||||||
|
(ghc-sync-process cmd)))
|
||||||
|
|
||||||
(provide 'ghc-rewrite)
|
(provide 'ghc-rewrite)
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
(defvar ghc-shallower-key "\C-c<")
|
(defvar ghc-shallower-key "\C-c<")
|
||||||
(defvar ghc-deeper-key "\C-c>")
|
(defvar ghc-deeper-key "\C-c>")
|
||||||
(defvar ghc-case-split-key "\C-c\C-p")
|
(defvar ghc-case-split-key "\C-c\C-p")
|
||||||
|
(defvar ghc-initial-sig-key "\C-c\C-s")
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;
|
;;;
|
||||||
@ -107,6 +108,7 @@
|
|||||||
(define-key haskell-mode-map ghc-shallower-key 'ghc-make-indent-shallower)
|
(define-key haskell-mode-map ghc-shallower-key 'ghc-make-indent-shallower)
|
||||||
(define-key haskell-mode-map ghc-deeper-key 'ghc-make-indent-deeper)
|
(define-key haskell-mode-map ghc-deeper-key 'ghc-make-indent-deeper)
|
||||||
(define-key haskell-mode-map ghc-case-split-key 'ghc-case-split)
|
(define-key haskell-mode-map ghc-case-split-key 'ghc-case-split)
|
||||||
|
(define-key haskell-mode-map ghc-initial-sig-key 'ghc-initial-code-from-signature)
|
||||||
(ghc-comp-init)
|
(ghc-comp-init)
|
||||||
(setq ghc-initialized t))
|
(setq ghc-initialized t))
|
||||||
(ghc-import-module)
|
(ghc-import-module)
|
||||||
|
Loading…
Reference in New Issue
Block a user