Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
commit
768992ee74
|
@ -2,15 +2,15 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: accessors arrays assocs combinators help help.crossref
|
USING: accessors arrays assocs combinators help help.crossref
|
||||||
help.markup help.topics io io.streams.string kernel make memoize
|
help.markup help.topics io io.streams.string kernel make namespaces
|
||||||
namespaces parser prettyprint sequences summary tools.vocabs
|
parser prettyprint sequences summary tools.vocabs tools.vocabs.browser
|
||||||
tools.vocabs.browser vocabs vocabs.loader words ;
|
vocabs vocabs.loader words ;
|
||||||
|
|
||||||
IN: fuel.help
|
IN: fuel.help
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
MEMO: fuel-find-word ( name -- word/f )
|
: fuel-find-word ( name -- word/f )
|
||||||
[ [ name>> ] dip = ] curry all-words swap filter
|
[ [ name>> ] dip = ] curry all-words swap filter
|
||||||
dup empty? not [ first ] [ drop f ] if ;
|
dup empty? not [ first ] [ drop f ] if ;
|
||||||
|
|
||||||
|
@ -102,11 +102,11 @@ PRIVATE>
|
||||||
: (fuel-vocab-help) ( name -- str )
|
: (fuel-vocab-help) ( name -- str )
|
||||||
dup empty? [ fuel-vocab-children-help ] [ (fuel-vocab-element) ] if ;
|
dup empty? [ fuel-vocab-children-help ] [ (fuel-vocab-element) ] if ;
|
||||||
|
|
||||||
MEMO: (fuel-get-vocabs/author) ( author -- element )
|
: (fuel-get-vocabs/author) ( author -- element )
|
||||||
[ "Vocabularies by " prepend \ $heading swap 2array ]
|
[ "Vocabularies by " prepend \ $heading swap 2array ]
|
||||||
[ authored fuel-vocab-list ] bi 2array ;
|
[ authored fuel-vocab-list ] bi 2array ;
|
||||||
|
|
||||||
MEMO: (fuel-get-vocabs/tag) ( tag -- element )
|
: (fuel-get-vocabs/tag) ( tag -- element )
|
||||||
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
|
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
|
||||||
[ tagged fuel-vocab-list ] bi 2array ;
|
[ tagged fuel-vocab-list ] bi 2array ;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ GENERIC: fuel-pprint ( obj -- )
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: fuel-maybe-scape ( ch -- seq )
|
: fuel-maybe-scape ( ch -- seq )
|
||||||
dup "\\\"?#()[]'`" member? [ CHAR: \ swap 2array ] [ 1array ] if ;
|
dup "\\\"?#()[]'`;" member? [ CHAR: \ swap 2array ] [ 1array ] if ;
|
||||||
|
|
||||||
SYMBOL: :restarts
|
SYMBOL: :restarts
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,14 @@ beast.
|
||||||
factor image (overwriting the current one) with all the needed
|
factor image (overwriting the current one) with all the needed
|
||||||
vocabs.
|
vocabs.
|
||||||
|
|
||||||
|
Alternatively, you can add the following line to your
|
||||||
|
.factor-boot-rc file:
|
||||||
|
|
||||||
|
"fuel" require
|
||||||
|
|
||||||
|
This will ensure that the image generated while bootstrapping
|
||||||
|
Factor contains fuel and the vocabularies it depends on.
|
||||||
|
|
||||||
*** Connecting to a running Factor
|
*** Connecting to a running Factor
|
||||||
|
|
||||||
'run-factor' starts a new factor listener process managed by Emacs.
|
'run-factor' starts a new factor listener process managed by Emacs.
|
||||||
|
@ -129,6 +137,7 @@ beast.
|
||||||
| | (fuel-refactor-extract-vocab) |
|
| | (fuel-refactor-extract-vocab) |
|
||||||
| C-cC-xi | replace word by its definition (fuel-refactor-inline-word) |
|
| C-cC-xi | replace word by its definition (fuel-refactor-inline-word) |
|
||||||
| C-cC-xw | rename all uses of a word (fuel-refactor-rename-word) |
|
| C-cC-xw | rename all uses of a word (fuel-refactor-rename-word) |
|
||||||
|
| C-cC-xa | extract region as a separate ARTICLE: form |
|
||||||
|-----------------+------------------------------------------------------------|
|
|-----------------+------------------------------------------------------------|
|
||||||
|
|
||||||
*** In the listener:
|
*** In the listener:
|
||||||
|
|
|
@ -583,19 +583,23 @@
|
||||||
(defun fuel-markup--notes (e)
|
(defun fuel-markup--notes (e)
|
||||||
(fuel-markup--elem-with-heading e "Notes"))
|
(fuel-markup--elem-with-heading e "Notes"))
|
||||||
|
|
||||||
(defun fuel-markup--see (e)
|
(defun fuel-markup--word-info (e s)
|
||||||
(let* ((word (nth 1 e))
|
(let* ((word (nth 1 e))
|
||||||
(cmd (and word `(:fuel* (,(format "%s" word) fuel-word-see) "fuel" t)))
|
(cmd (and word `(:fuel* ((:quote ,(format "%s" word)) ,s) "fuel")))
|
||||||
(res (and cmd
|
(ret (and cmd (fuel-eval--send/wait cmd)))
|
||||||
(fuel-eval--retort-result (fuel-eval--send/wait cmd 100)))))
|
(res (and (not (fuel-eval--retort-error ret))
|
||||||
|
(fuel-eval--retort-output ret))))
|
||||||
(if res
|
(if res
|
||||||
(fuel-markup--code (list '$code res))
|
(fuel-markup--code (list '$code res))
|
||||||
(fuel-markup--snippet (list '$snippet word)))))
|
(fuel-markup--snippet (list '$snippet " " word)))))
|
||||||
|
|
||||||
(defun fuel-markup--null (e))
|
(defun fuel-markup--see (e)
|
||||||
|
(fuel-markup--word-info e 'see))
|
||||||
|
|
||||||
(defun fuel-markup--synopsis (e)
|
(defun fuel-markup--synopsis (e)
|
||||||
(insert (format " %S " e)))
|
(fuel-markup--word-info e 'synopsis))
|
||||||
|
|
||||||
|
(defun fuel-markup--null (e))
|
||||||
|
|
||||||
|
|
||||||
(provide 'fuel-markup)
|
(provide 'fuel-markup)
|
||||||
|
|
|
@ -198,6 +198,7 @@ interacting with a factor listener is at your disposal.
|
||||||
(fuel-mode--key ?e ?w 'fuel-edit-word)
|
(fuel-mode--key ?e ?w 'fuel-edit-word)
|
||||||
(fuel-mode--key ?e ?x 'fuel-eval-definition)
|
(fuel-mode--key ?e ?x 'fuel-eval-definition)
|
||||||
|
|
||||||
|
(fuel-mode--key ?x ?a 'fuel-refactor-extract-article)
|
||||||
(fuel-mode--key ?x ?i 'fuel-refactor-inline-word)
|
(fuel-mode--key ?x ?i 'fuel-refactor-inline-word)
|
||||||
(fuel-mode--key ?x ?r 'fuel-refactor-extract-region)
|
(fuel-mode--key ?x ?r 'fuel-refactor-extract-region)
|
||||||
(fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp)
|
(fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp)
|
||||||
|
|
|
@ -78,17 +78,19 @@
|
||||||
(when found (setq result (fuel-refactor--reuse-p (car found)))))
|
(when found (setq result (fuel-refactor--reuse-p (car found)))))
|
||||||
(and result found))))
|
(and result found))))
|
||||||
|
|
||||||
|
(defsubst fuel-refactor--insertion-point ()
|
||||||
|
(max (save-excursion (fuel-syntax--beginning-of-defun) (point))
|
||||||
|
(save-excursion
|
||||||
|
(re-search-backward fuel-syntax--end-of-def-regex nil t)
|
||||||
|
(forward-line 1)
|
||||||
|
(skip-syntax-forward "-"))))
|
||||||
|
|
||||||
(defun fuel-refactor--insert-word (word stack-effect code)
|
(defun fuel-refactor--insert-word (word stack-effect code)
|
||||||
(let ((beg (save-excursion (fuel-syntax--beginning-of-defun) (point)))
|
(let ((start (goto-char (fuel-refactor--insertion-point))))
|
||||||
(end (save-excursion
|
(open-line 1)
|
||||||
(re-search-backward fuel-syntax--end-of-def-regex nil t)
|
(insert ": " word " " stack-effect "\n" code " ;\n")
|
||||||
(forward-line 1)
|
(indent-region start (point))
|
||||||
(skip-syntax-forward "-"))))
|
(move-overlay fuel-stack--overlay start (point))))
|
||||||
(let ((start (goto-char (max beg end))))
|
|
||||||
(open-line 1)
|
|
||||||
(insert ": " word " " stack-effect "\n" code " ;\n")
|
|
||||||
(indent-region start (point))
|
|
||||||
(move-overlay fuel-stack--overlay start (point)))))
|
|
||||||
|
|
||||||
(defun fuel-refactor--extract-other (start end code)
|
(defun fuel-refactor--extract-other (start end code)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
|
@ -233,5 +235,30 @@ The region is extended to the closest definition boundaries."
|
||||||
(mark-defun)
|
(mark-defun)
|
||||||
(mark))))
|
(mark))))
|
||||||
|
|
||||||
|
;;; Extract article:
|
||||||
|
|
||||||
|
(defun fuel-refactor-extract-article (begin end)
|
||||||
|
"Extracts region as a new ARTICLE form."
|
||||||
|
(interactive "r")
|
||||||
|
(let ((topic (read-string "Article topic: "))
|
||||||
|
(title (read-string "Article title: ")))
|
||||||
|
(kill-region begin end)
|
||||||
|
(insert (format "{ $subsection %s }\n" topic))
|
||||||
|
(end-of-line 0)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (fuel-refactor--insertion-point))
|
||||||
|
(open-line 1)
|
||||||
|
(let ((start (point)))
|
||||||
|
(insert (format "ARTICLE: %S %S\n" topic title))
|
||||||
|
(yank)
|
||||||
|
(when (looking-at "^ *$") (end-of-line 0))
|
||||||
|
(insert " ;")
|
||||||
|
(unwind-protect
|
||||||
|
(progn
|
||||||
|
(move-overlay fuel-stack--overlay start (point))
|
||||||
|
(sit-for fuel-stack-highlight-period))
|
||||||
|
(delete-overlay fuel-stack--overlay))))))
|
||||||
|
|
||||||
|
|
||||||
(provide 'fuel-refactor)
|
(provide 'fuel-refactor)
|
||||||
;;; fuel-refactor.el ends here
|
;;; fuel-refactor.el ends here
|
||||||
|
|
|
@ -158,7 +158,9 @@
|
||||||
"PREDICATE" "PRIMITIVE"
|
"PREDICATE" "PRIMITIVE"
|
||||||
"UNION"))
|
"UNION"))
|
||||||
|
|
||||||
(defconst fuel-syntax--no-indent-def-starts '("SINGLETONS"
|
(defconst fuel-syntax--no-indent-def-starts '("ARTICLE"
|
||||||
|
"HELP"
|
||||||
|
"SINGLETONS"
|
||||||
"SYMBOLS"
|
"SYMBOLS"
|
||||||
"TUPLE"
|
"TUPLE"
|
||||||
"VARS"))
|
"VARS"))
|
||||||
|
@ -179,13 +181,12 @@
|
||||||
|
|
||||||
(defconst fuel-syntax--single-liner-regex
|
(defconst fuel-syntax--single-liner-regex
|
||||||
(regexp-opt '("ABOUT:"
|
(regexp-opt '("ABOUT:"
|
||||||
"ARTICLE:"
|
|
||||||
"ALIAS:"
|
"ALIAS:"
|
||||||
"CONSTANT:" "C:"
|
"CONSTANT:" "C:"
|
||||||
"DEFER:"
|
"DEFER:"
|
||||||
"FORGET:"
|
"FORGET:"
|
||||||
"GENERIC:" "GENERIC#"
|
"GENERIC:" "GENERIC#"
|
||||||
"HELP:" "HEX:" "HOOK:"
|
"HEX:" "HOOK:"
|
||||||
"IN:" "INSTANCE:"
|
"IN:" "INSTANCE:"
|
||||||
"LIBRARY:"
|
"LIBRARY:"
|
||||||
"MAIN:" "MATH:" "MIXIN:"
|
"MAIN:" "MATH:" "MIXIN:"
|
||||||
|
|
Loading…
Reference in New Issue