Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
commit
3cc8915193
|
@ -36,24 +36,22 @@ t clone fuel-eval-res-flag set-global
|
|||
: fuel-eval-non-restartable ( -- )
|
||||
f fuel-eval-res-flag set-global ; inline
|
||||
|
||||
: push-fuel-status ( -- )
|
||||
: fuel-push-status ( -- )
|
||||
in get use get clone restarts get-global clone
|
||||
fuel-status boa
|
||||
fuel-status-stack get push ;
|
||||
|
||||
: pop-fuel-status ( -- )
|
||||
: fuel-pop-restarts ( restarts -- )
|
||||
fuel-eval-restartable? [ drop ] [ clone restarts set-global ] if ; inline
|
||||
|
||||
: fuel-pop-status ( -- )
|
||||
fuel-status-stack get empty? [
|
||||
fuel-status-stack get pop
|
||||
[ in>> in set ]
|
||||
[ use>> clone use set ]
|
||||
[
|
||||
restarts>> fuel-eval-restartable? [ drop ] [
|
||||
clone restarts set-global
|
||||
] if
|
||||
] tri
|
||||
[ restarts>> fuel-pop-restarts ] tri
|
||||
] unless ;
|
||||
|
||||
|
||||
! Lispy pretty printing
|
||||
|
||||
GENERIC: fuel-pprint ( obj -- )
|
||||
|
@ -67,11 +65,7 @@ M: integer fuel-pprint pprint ; inline
|
|||
M: string fuel-pprint pprint ; inline
|
||||
|
||||
M: sequence fuel-pprint
|
||||
dup empty? [ drop f fuel-pprint ] [
|
||||
"(" write
|
||||
[ " " write ] [ fuel-pprint ] interleave
|
||||
")" write
|
||||
] if ;
|
||||
"(" write [ " " write ] [ fuel-pprint ] interleave ")" write ; inline
|
||||
|
||||
M: tuple fuel-pprint tuple>array fuel-pprint ; inline
|
||||
|
||||
|
@ -117,14 +111,13 @@ M: source-file fuel-pprint path>> fuel-pprint ;
|
|||
: fuel-forget-output ( -- ) f fuel-eval-output set-global ; inline
|
||||
|
||||
: (fuel-begin-eval) ( -- )
|
||||
push-fuel-status
|
||||
fuel-push-status
|
||||
fuel-forget-error
|
||||
fuel-forget-result
|
||||
fuel-forget-output ;
|
||||
|
||||
: (fuel-end-eval) ( result -- )
|
||||
fuel-eval-output set-global fuel-retort
|
||||
pop-fuel-status ; inline
|
||||
: (fuel-end-eval) ( output -- )
|
||||
fuel-eval-output set-global fuel-retort fuel-pop-status ; inline
|
||||
|
||||
: (fuel-eval) ( lines -- )
|
||||
[ [ parse-lines ] with-compilation-unit call ] curry
|
||||
|
@ -155,16 +148,23 @@ M: source-file fuel-pprint path>> fuel-pprint ;
|
|||
: fuel-get-edit-location ( defspec -- )
|
||||
where fuel-normalize-loc 2array fuel-eval-set-result ; inline
|
||||
|
||||
: fuel-get-vocab-location ( vocab -- )
|
||||
>vocab-link fuel-get-edit-location ; inline
|
||||
|
||||
: fuel-get-doc-location ( defspec -- )
|
||||
props>> "help-loc" swap at
|
||||
fuel-normalize-loc 2array fuel-eval-set-result ;
|
||||
|
||||
: fuel-format-xrefs ( seq -- seq )
|
||||
[ word? ] filter [
|
||||
[ name>> ]
|
||||
[ vocabulary>> ]
|
||||
[ where fuel-normalize-loc ] tri 4array
|
||||
] map [ [ first ] dip first <=> ] sort ; inline
|
||||
! Cross-references
|
||||
|
||||
: fuel-word>xref ( word -- xref )
|
||||
[ name>> ] [ vocabulary>> ] [ where fuel-normalize-loc ] tri 4array ;
|
||||
|
||||
: fuel-sort-xrefs ( seq -- seq' )
|
||||
[ [ first ] dip first <=> ] sort ; inline
|
||||
|
||||
: fuel-format-xrefs ( seq -- seq' )
|
||||
[ word? ] filter [ fuel-word>xref ] map fuel-sort-xrefs ;
|
||||
|
||||
: fuel-callers-xref ( word -- )
|
||||
usage fuel-format-xrefs fuel-eval-set-result ; inline
|
||||
|
@ -172,9 +172,6 @@ M: source-file fuel-pprint path>> fuel-pprint ;
|
|||
: fuel-callees-xref ( word -- )
|
||||
uses fuel-format-xrefs fuel-eval-set-result ; inline
|
||||
|
||||
: fuel-get-vocab-location ( vocab -- )
|
||||
>vocab-link fuel-get-edit-location ; inline
|
||||
|
||||
! Completion support
|
||||
|
||||
: fuel-filter-prefix ( seq prefix -- seq )
|
||||
|
|
|
@ -78,15 +78,15 @@
|
|||
`(,@fuel-font-lock--parsing-lock-keywords
|
||||
(,fuel-syntax--stack-effect-regex . 'factor-font-lock-stack-effect)
|
||||
(,fuel-syntax--parsing-words-ext-regex . 'factor-font-lock-parsing-word)
|
||||
(,fuel-syntax--declaration-words-regex 1 'factor-font-lock-declaration)
|
||||
(,fuel-syntax--declaration-words-regex . 'factor-font-lock-declaration)
|
||||
(,fuel-syntax--word-definition-regex 2 'factor-font-lock-word)
|
||||
(,fuel-syntax--type-definition-regex 2 'factor-font-lock-type-name)
|
||||
(,fuel-syntax--method-definition-regex (1 'factor-font-lock-type-name)
|
||||
(2 'factor-font-lock-word))
|
||||
(,fuel-syntax--parent-type-regex 1 'factor-font-lock-type-name)
|
||||
(,fuel-syntax--constructor-regex . 'factor-font-lock-constructor)
|
||||
(,fuel-syntax--setter-regex 2 'factor-font-lock-setter-word)
|
||||
(,fuel-syntax--getter-regex 2 'factor-font-lock-getter-word)
|
||||
(,fuel-syntax--setter-regex . 'factor-font-lock-setter-word)
|
||||
(,fuel-syntax--getter-regex . 'factor-font-lock-getter-word)
|
||||
(,fuel-syntax--symbol-definition-regex 2 'factor-font-lock-symbol)
|
||||
(,fuel-syntax--use-line-regex 1 'factor-font-lock-vocabulary-name))
|
||||
"Font lock keywords definition for Factor mode.")
|
||||
|
|
|
@ -147,6 +147,10 @@ buffer."
|
|||
|
||||
;;; Fuel listener mode:
|
||||
|
||||
(defun fuel-listener--bol ()
|
||||
(interactive)
|
||||
(when (= (point) (comint-bol)) (beginning-of-line)))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode fuel-listener-mode comint-mode "Fuel Listener"
|
||||
"Major mode for interacting with an inferior Factor listener process.
|
||||
|
@ -160,6 +164,7 @@ buffer."
|
|||
|
||||
(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-a" 'fuel-listener--bol)
|
||||
(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)
|
||||
|
|
|
@ -62,8 +62,7 @@
|
|||
'("flushable" "foldable" "inline" "parsing" "recursive"))
|
||||
|
||||
(defconst fuel-syntax--declaration-words-regex
|
||||
(format "%s\\($\\| \\)"
|
||||
(regexp-opt fuel-syntax--declaration-words 'words)))
|
||||
(regexp-opt fuel-syntax--declaration-words 'words))
|
||||
|
||||
(defsubst fuel-syntax--second-word-regex (prefixes)
|
||||
(format "^%s +\\([^ \r\n]+\\)" (regexp-opt prefixes t)))
|
||||
|
@ -81,8 +80,8 @@
|
|||
|
||||
(defconst fuel-syntax--constructor-regex "<[^ >]+>")
|
||||
|
||||
(defconst fuel-syntax--getter-regex "\\( \\|^\\)\\([^ ]+>>\\)\\( \\|$\\)")
|
||||
(defconst fuel-syntax--setter-regex "\\( \\|^\\)\\(>>[^ ]+\\)\\( \\|$\\)")
|
||||
(defconst fuel-syntax--getter-regex "\\(^\\|\\_<\\)[^ ]+?>>\\_>")
|
||||
(defconst fuel-syntax--setter-regex "\\_<>>.+?\\_>")
|
||||
|
||||
(defconst fuel-syntax--symbol-definition-regex
|
||||
(fuel-syntax--second-word-regex '("SYMBOL:" "VAR:")))
|
||||
|
@ -104,7 +103,7 @@
|
|||
(format "^\\(%s:\\) " fuel-syntax--definition-starters-regex))
|
||||
|
||||
(defconst fuel-syntax--definition-end-regex
|
||||
(format "\\(\\(^\\| +\\);\\( +%s\\)*\\($\\| +\\)\\)"
|
||||
(format "\\(\\(^\\| +\\);\\( *%s\\)*\\($\\| +\\)\\)"
|
||||
fuel-syntax--declaration-words-regex))
|
||||
|
||||
(defconst fuel-syntax--single-liner-regex
|
||||
|
@ -124,39 +123,27 @@
|
|||
(format "\\(%s\\)\\|\\(%s .*\\)"
|
||||
fuel-syntax--end-of-def-line-regex
|
||||
fuel-syntax--single-liner-regex))
|
||||
|
||||
(defconst fuel-syntax--defun-signature-regex
|
||||
(format "\\(%s\\|%s\\)"
|
||||
(format ":[^ ]* [^ ]+\\(%s\\)*" fuel-syntax--stack-effect-regex)
|
||||
"M[^:]*: [^ ]+ [^ ]+"))
|
||||
|
||||
|
||||
;;; Factor syntax table
|
||||
|
||||
(defvar fuel-syntax--syntax-table
|
||||
(let ((i 0)
|
||||
(table (make-syntax-table)))
|
||||
;; Default is atom-constituent
|
||||
(while (< i 256)
|
||||
(modify-syntax-entry i "_ " table)
|
||||
(setq i (1+ i)))
|
||||
|
||||
;; Word components.
|
||||
(setq i ?0)
|
||||
(while (<= i ?9)
|
||||
(modify-syntax-entry i "w " table)
|
||||
(setq i (1+ i)))
|
||||
(setq i ?A)
|
||||
(while (<= i ?Z)
|
||||
(modify-syntax-entry i "w " table)
|
||||
(setq i (1+ i)))
|
||||
(setq i ?a)
|
||||
(while (<= i ?z)
|
||||
(modify-syntax-entry i "w " table)
|
||||
(setq i (1+ i)))
|
||||
(let ((table (make-syntax-table)))
|
||||
;; Default is word constituent
|
||||
(dotimes (i 256)
|
||||
(modify-syntax-entry i "w" table))
|
||||
|
||||
;; Whitespace
|
||||
(modify-syntax-entry ?\t " " table)
|
||||
(modify-syntax-entry ?\f " " table)
|
||||
(modify-syntax-entry ?\r " " table)
|
||||
(modify-syntax-entry ? " " table)
|
||||
|
||||
;; (end of) Comments
|
||||
(modify-syntax-entry ?\n ">" table)
|
||||
(modify-syntax-entry ?\ " " table)
|
||||
(modify-syntax-entry ?\n " " table)
|
||||
|
||||
;; Parenthesis
|
||||
(modify-syntax-entry ?\[ "(]" table)
|
||||
|
@ -170,13 +157,11 @@
|
|||
;; Strings
|
||||
(modify-syntax-entry ?\" "\"" table)
|
||||
(modify-syntax-entry ?\\ "/" table)
|
||||
table)
|
||||
"Syntax table used while in Factor mode.")
|
||||
table))
|
||||
|
||||
(defconst fuel-syntax--syntactic-keywords
|
||||
`(("\\(#!\\)" (1 "<"))
|
||||
(" \\(!\\)" (1 "<"))
|
||||
("^\\(!\\)" (1 "<"))
|
||||
`(("\\(#!\\) .*\\(\n\\)" (1 "<") (2 ">"))
|
||||
("\\( \\|^\\)\\(!\\) .*\\(\n\\)" (2 "<") (3 ">"))
|
||||
("\\(!(\\) .* \\()\\)" (1 "<") (2 ">"))
|
||||
("\\(\\[\\)\\(let\\|wlet\\|let\\*\\)\\( \\|$\\)" (1 "(]"))
|
||||
("\\(\\[\\)\\(|\\) +[^|]* \\(|\\)" (1 "(]") (2 "(|") (3 ")|"))
|
||||
|
@ -282,11 +267,6 @@
|
|||
(re-search-forward fuel-syntax--end-of-def-regex nil t)
|
||||
(point)))
|
||||
|
||||
(defconst fuel-syntax--defun-signature-regex
|
||||
(format "\\(%s\\|%s\\)"
|
||||
(format ":[^ ]* [^ ]+\\(%s\\)*" fuel-syntax--stack-effect-regex)
|
||||
"M[^:]*: [^ ]+ [^ ]+"))
|
||||
|
||||
(defun fuel-syntax--beginning-of-body ()
|
||||
(let ((p (point)))
|
||||
(and (fuel-syntax--beginning-of-defun)
|
||||
|
|
Loading…
Reference in New Issue