Use a struct for accessing initial info data

This commit is contained in:
Alejandro Serrano 2014-07-02 17:04:28 +02:00
parent ccc21461b2
commit 5db4044f29

View File

@ -47,17 +47,19 @@
;;; Initial code from signature ;;; Initial code from signature
;;; ;;;
(ghc-defstruct icsinfo sort pos fns)
(defun ghc-initial-code-from-signature () (defun ghc-initial-code-from-signature ()
(interactive) (interactive)
(let ((info (ghc-obtain-initial-code-from-signature))) (let ((info (ghc-obtain-initial-code-from-signature)))
(if (null info) (if (null info)
(message "Cannot obtain initial code") (message "Cannot obtain initial code")
(let* ((ln-current (line-number-at-pos)) (let* ((ln-current (line-number-at-pos))
(sort (car info)) (sort (ghc-icsinfo-get-sort info))
(pos (cadr info)) (pos (ghc-icsinfo-get-pos info))
(ln-end (ghc-sinfo-get-end-line pos)) (ln-end (ghc-sinfo-get-end-line pos))
(ln-diff (+ 1 (- ln-end ln-current))) (ln-diff (+ 1 (- ln-end ln-current)))
(fns-to-insert (caddr info))) (fns-to-insert (ghc-icsinfo-get-fns info)))
(goto-char (line-end-position ln-diff)) (goto-char (line-end-position ln-diff))
(dolist (fn-to-insert fns-to-insert) (dolist (fn-to-insert fns-to-insert)
(if (equal sort "function") (if (equal sort "function")