FUEL: stack mode available in listener.
parent
41b0bc0dd9
commit
588dc002ce
|
@ -78,6 +78,7 @@ C-cC-eC-r is the same as C-cC-er)).
|
|||
- TAB : complete word at point
|
||||
- M-. : edit word at point in Emacs
|
||||
- C-ca : toggle autodoc mode
|
||||
- C-cs : toggle stack mode
|
||||
- C-cv : edit vocabulary
|
||||
- C-ch : help for word at point
|
||||
- C-ck : run file
|
||||
|
|
|
@ -74,12 +74,14 @@
|
|||
len))
|
||||
|
||||
(defsubst fuel--region-to-string (begin &optional end)
|
||||
(mapconcat 'identity
|
||||
(split-string (buffer-substring-no-properties begin
|
||||
(or end (point)))
|
||||
nil
|
||||
t)
|
||||
" "))
|
||||
(let ((end (or end (point))))
|
||||
(if (< begin end)
|
||||
(mapconcat 'identity
|
||||
(split-string (buffer-substring-no-properties begin end)
|
||||
nil
|
||||
t)
|
||||
" ")
|
||||
"")))
|
||||
|
||||
(defsubst empty-string-p (str) (equal str ""))
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'fuel-eval)
|
||||
(require 'fuel-stack)
|
||||
(require 'fuel-completion)
|
||||
(require 'fuel-eval)
|
||||
(require 'fuel-connection)
|
||||
(require 'fuel-syntax)
|
||||
(require 'fuel-base)
|
||||
|
@ -102,16 +103,9 @@ buffer."
|
|||
(goto-char (point-max))
|
||||
(unless seen (error "No prompt found!"))))
|
||||
|
||||
|
||||
;;; 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))
|
||||
|
||||
|
||||
;;; Interface: starting fuel listener
|
||||
|
@ -128,6 +122,28 @@ buffer."
|
|||
(pop-to-buffer buf)
|
||||
(switch-to-buffer buf))))
|
||||
|
||||
|
||||
;;; 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))
|
||||
|
||||
|
||||
;;; 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))
|
||||
|
||||
|
||||
;;; Fuel listener mode:
|
||||
|
||||
|
@ -138,12 +154,15 @@ buffer."
|
|||
(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)
|
||||
|
|
|
@ -96,13 +96,20 @@ With prefix argument, use current region instead"
|
|||
(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
|
||||
|
|
Loading…
Reference in New Issue