Austin Seipp  committed 3216a78

Basic infrastructure for inserting function types. Issue #14.

Signed-off-by: Austin Seipp <>

  • Participants
  • Parent commits cb20a78

Comments (0)

Files changed (1)

File cryptol-mode.el

 (require 'easymenu)
 (require 'font-lock)
 (require 'generic-x)
+(require 'thingatpt)
 ;;; -- Customization variables -------------------------------------------------
 (defvar cryptol-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c C-l") 'cryptol-repl)
+    (define-key map (kbd "M-t") 'cryptol-insert-type-sig)
   "Keymap for `cryptol-mode'.")
   "Process output from cryptol, removing stupid libedit noise on Linux.
   TODO: Elaborate further on this stupidity."
   (if (not (eq nil args))
-      (let ((cryptol-output (process-lines cryptol-command "-v")))
+      (let ((cryptol-output (apply 'process-lines (append (list cryptol-command) args))))
 	(if (not (eq nil (string-prefix-p "No entry for terminal type "
 					  (car cryptol-output))))
 	    (nthcdr 2 cryptol-output)
       (setq *cryptol-version* cryptol-version)
+(defun get-type-sig-for-symbol (sym)
+  "Get the type signature for a symbol."
+  (interactive)
+  (let ((out (process-lines-cryptol "-qns" (buffer-file-name) "-c" (concat ":type " sym))))
+    (mapconcat 'identity out " ")))
 (defun cryptol-backends ()
   "Show the backends supported by the `cryptol-command'."
     (message (concat "cryptol-mode v" cryptol-mode-version
 		     ", using Cryptol version " cryptol-ver-out))))
+(defun cryptol-insert-type-sig ()
+  "Insert a type signature for the symbol under point."
+  (interactive)
+  (let ((sym (thing-at-point 'symbol)))
+    (message (get-type-sig-for-symbol sym)))
+  )
 ;;; -- imenu support -----------------------------------------------------------
 (easy-menu-define cryptol-mode-menu cryptol-mode-map