diff --git a/basis/environment/environment-docs.factor b/basis/environment/environment-docs.factor index e539b446f3..b48a7a01ad 100644 --- a/basis/environment/environment-docs.factor +++ b/basis/environment/environment-docs.factor @@ -7,12 +7,14 @@ HELP: (os-envs) { $values { "seq" sequence } } -{ $description "" } ; +{ $description "Returns a sequence of key/value pairs from the operating system." } +{ $notes "In most cases, use " { $link os-envs } " instead." } ; HELP: (set-os-envs) { $values { "seq" sequence } } -{ $description "" } ; +{ $description "Low-level word for replacing the current set of environment variables." } +{ $notes "In most cases, use " { $link set-os-envs } " instead." } ; HELP: os-env ( key -- value ) diff --git a/basis/html/streams/streams.factor b/basis/html/streams/streams.factor index 24d9dceb80..43fa8bda85 100644 --- a/basis/html/streams/streams.factor +++ b/basis/html/streams/streams.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators generic assocs help http io io.styles +USING: combinators generic assocs io io.styles io.files continuations io.streams.string kernel math math.order math.parser namespaces make quotations assocs sequences strings words html.elements xml.entities sbufs continuations destructors diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index 18ae8e1497..358c984276 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -242,7 +242,7 @@ HELP: shift-mod { "n" integer } { "s" integer } { "w" integer } { "n" integer } } -{ $description "" } ; +{ $description "Calls " { $link shift } " on " { $snippet "n" } " and " { $snippet "s" } ", wrapping the result to " { $snippet "w" } " bits." } ; HELP: unmask { $values diff --git a/extra/constructors/constructors.factor b/extra/constructors/constructors.factor index 6968fd7eda..2eab91310f 100644 --- a/extra/constructors/constructors.factor +++ b/extra/constructors/constructors.factor @@ -1,17 +1,19 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: slots kernel sequences fry accessors parser lexer words -effects.parser ; +effects.parser macros ; IN: constructors ! An experiment -: constructor-quot ( class slot-names body -- quot ) - [ <reversed> [ setter-word '[ swap _ execute ] ] map [ ] join ] dip - '[ _ new @ @ ] ; +MACRO: set-slots ( slots -- quot ) + <reversed> [ setter-word '[ swap _ execute ] ] map [ ] join ; + +: construct ( ... class slots -- instance ) + [ new ] dip set-slots ; inline : define-constructor ( name class effect body -- ) - [ [ in>> ] dip constructor-quot ] [ drop ] 2bi + [ [ in>> '[ _ _ construct ] ] dip compose ] [ drop ] 2bi define-declared ; : CONSTRUCTOR: diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index e70327bd35..55183734b3 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -2,15 +2,15 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators help help.crossref -help.markup help.topics io io.streams.string kernel make memoize -namespaces parser prettyprint sequences summary tools.vocabs -tools.vocabs.browser vocabs vocabs.loader words ; +help.markup help.topics io io.streams.string kernel make namespaces +parser prettyprint sequences summary tools.vocabs tools.vocabs.browser +vocabs vocabs.loader words ; IN: fuel.help <PRIVATE -MEMO: fuel-find-word ( name -- word/f ) +: fuel-find-word ( name -- word/f ) [ [ name>> ] dip = ] curry all-words swap filter dup empty? not [ first ] [ drop f ] if ; @@ -102,11 +102,11 @@ PRIVATE> : (fuel-vocab-help) ( name -- str ) 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 ] [ 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 ] [ tagged fuel-vocab-list ] bi 2array ; diff --git a/extra/fuel/pprint/pprint.factor b/extra/fuel/pprint/pprint.factor index 25f3aec14d..9dcbd76368 100644 --- a/extra/fuel/pprint/pprint.factor +++ b/extra/fuel/pprint/pprint.factor @@ -12,7 +12,7 @@ GENERIC: fuel-pprint ( obj -- ) <PRIVATE : fuel-maybe-scape ( ch -- seq ) - dup "\\\"?#()[]'`" member? [ CHAR: \ swap 2array ] [ 1array ] if ; + dup "\\\"?#()[]'`;" member? [ CHAR: \ swap 2array ] [ 1array ] if ; SYMBOL: :restarts diff --git a/misc/fuel/README b/misc/fuel/README index cf96e29f52..d712560b03 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -53,6 +53,14 @@ beast. factor image (overwriting the current one) with all the needed 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 'run-factor' starts a new factor listener process managed by Emacs. @@ -129,6 +137,7 @@ beast. | | (fuel-refactor-extract-vocab) | | 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-xa | extract region as a separate ARTICLE: form | |-----------------+------------------------------------------------------------| *** In the listener: diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 7a8fa0c234..4844233ae7 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -323,7 +323,7 @@ (sort-lines nil start (point)))))) (defun fuel-markup--vocab-link (e) - (fuel-markup--insert-button (cadr e) (cadr e) 'vocab)) + (fuel-markup--insert-button (cadr e) (or (car (cddr e)) (cadr e)) 'vocab)) (defun fuel-markup--vocab-links (e) (dolist (link (cdr e)) @@ -583,19 +583,23 @@ (defun fuel-markup--notes (e) (fuel-markup--elem-with-heading e "Notes")) -(defun fuel-markup--see (e) +(defun fuel-markup--word-info (e s) (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* (,(format "%s" word) fuel-word-see) "fuel" t))) - (res (and cmd - (fuel-eval--retort-result (fuel-eval--send/wait cmd 100))))) + (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) ,s) "fuel"))) + (ret (and cmd (fuel-eval--send/wait cmd))) + (res (and (not (fuel-eval--retort-error ret)) + (fuel-eval--retort-output ret)))) (if 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) - (insert (format " %S " e))) + (fuel-markup--word-info e 'synopsis)) + +(defun fuel-markup--null (e)) (provide 'fuel-markup) diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index 88ad73864a..504308fccd 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -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 ?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 ?r 'fuel-refactor-extract-region) (fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp) diff --git a/misc/fuel/fuel-refactor.el b/misc/fuel/fuel-refactor.el index 061adbb82c..bd62227755 100644 --- a/misc/fuel/fuel-refactor.el +++ b/misc/fuel/fuel-refactor.el @@ -78,17 +78,19 @@ (when found (setq result (fuel-refactor--reuse-p (car 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) - (let ((beg (save-excursion (fuel-syntax--beginning-of-defun) (point))) - (end (save-excursion - (re-search-backward fuel-syntax--end-of-def-regex nil t) - (forward-line 1) - (skip-syntax-forward "-")))) - (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))))) + (let ((start (goto-char (fuel-refactor--insertion-point)))) + (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) (unwind-protect @@ -233,5 +235,30 @@ The region is extended to the closest definition boundaries." (mark-defun) (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) ;;; fuel-refactor.el ends here diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index ad5a025a88..80bfd0afcb 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -158,7 +158,9 @@ "PREDICATE" "PRIMITIVE" "UNION")) -(defconst fuel-syntax--no-indent-def-starts '("SINGLETONS" +(defconst fuel-syntax--no-indent-def-starts '("ARTICLE" + "HELP" + "SINGLETONS" "SYMBOLS" "TUPLE" "VARS")) @@ -179,13 +181,12 @@ (defconst fuel-syntax--single-liner-regex (regexp-opt '("ABOUT:" - "ARTICLE:" "ALIAS:" "CONSTANT:" "C:" "DEFER:" "FORGET:" "GENERIC:" "GENERIC#" - "HELP:" "HEX:" "HOOK:" + "HEX:" "HOOK:" "IN:" "INSTANCE:" "LIBRARY:" "MAIN:" "MATH:" "MIXIN:"