;;; Code:
-(require 'fuel-eval)
+(require 'fuel-stack)
(require 'fuel-completion)
+(require 'fuel-eval)
(require 'fuel-connection)
(require 'fuel-syntax)
(require 'fuel-base)
(goto-char (point-max))
(unless seen (error "No prompt found!"))))
-\f
-;;; Completion support
-
-(defsubst fuel-listener--current-vocab () nil)
-(defsubst fuel-listener--usings () nil)
-
-(defun fuel-listener--setup-completion ()
- (setq fuel-syntax--current-vocab-function 'fuel-listener--current-vocab)
- (setq fuel-syntax--usings-function 'fuel-listener--usings)
- (set-syntax-table fuel-syntax--syntax-table))
+(defun fuel-listener-nuke ()
+ (interactive)
+ (fuel-con--setup-connection fuel-listener--buffer))
\f
;;; Interface: starting fuel listener
(pop-to-buffer buf)
(switch-to-buffer buf))))
+\f
+;;; Completion support
+
+(defsubst fuel-listener--current-vocab () nil)
+(defsubst fuel-listener--usings () nil)
+
+(defun fuel-listener--setup-completion ()
+ (setq fuel-syntax--current-vocab-function 'fuel-listener--current-vocab)
+ (setq fuel-syntax--usings-function 'fuel-listener--usings)
+ (set-syntax-table fuel-syntax--syntax-table))
+
+\f
+;;; Stack mode support
+
+(defun fuel-listener--stack-region ()
+ (fuel--region-to-string (if (zerop (fuel-syntax--brackets-depth))
+ (comint-line-beginning-position)
+ (1+ (fuel-syntax--brackets-start)))))
+
+(defun fuel-listener--setup-stack-mode ()
+ (setq fuel-stack--region-function 'fuel-listener--stack-region))
+
\f
;;; Fuel listener mode:
(set (make-local-variable 'comint-prompt-regexp) fuel-con--prompt-regex)
(set (make-local-variable 'comint-use-prompt-regexp) t)
(set (make-local-variable 'comint-prompt-read-only) t)
- (fuel-listener--setup-completion))
+ (set-syntax-table fuel-syntax--syntax-table)
+ (fuel-listener--setup-completion)
+ (fuel-listener--setup-stack-mode))
(define-key fuel-listener-mode-map "\C-cz" 'run-factor)
(define-key fuel-listener-mode-map "\C-c\C-z" 'run-factor)
(define-key fuel-listener-mode-map "\C-ca" 'fuel-autodoc-mode)
(define-key fuel-listener-mode-map "\C-ch" 'fuel-help)
+(define-key fuel-listener-mode-map "\C-cs" 'fuel-stack-mode)
(define-key fuel-listener-mode-map "\M-." 'fuel-edit-word-at-point)
(define-key fuel-listener-mode-map "\C-cv" 'fuel-edit-vocabulary)
(define-key fuel-listener-mode-map "\C-c\C-v" 'fuel-edit-vocabulary)
(defvar fuel-stack-mode-string " S"
"Modeline indicator for fuel-stack-mode"))
+(make-variable-buffer-local
+ (defvar fuel-stack--region-function
+ '(lambda ()
+ (fuel--region-to-string (1+ (fuel-syntax--beginning-of-sexp-pos))))))
+
(defun fuel-stack--eldoc ()
(when (looking-at-p " \\|$")
- (let* ((r (fuel--region-to-string (1+ (fuel-syntax--beginning-of-sexp-pos))))
- (e (fuel-stack--infer-effect/prop r)))
+ (let* ((r (funcall fuel-stack--region-function))
+ (e (and r
+ (not (string-match "^ *$" r))
+ (fuel-stack--infer-effect/prop r))))
(when e
(if fuel-stack-mode-show-sexp-p
- (concat (fuel--shorten-str r 30) ": " e)
+ (concat (fuel--shorten-str r 30) " -> " e)
e)))))
(define-minor-mode fuel-stack-mode