Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor into new_ui

db4
Slava Pestov 2009-01-11 14:52:10 -06:00
commit fc5c893744
10 changed files with 152 additions and 27 deletions

View File

@ -26,7 +26,7 @@ HELP: scaffold-undocumented
HELP: scaffold-vocab
{ $values
{ "vocab-root" "a vocabulary root string" } { "string" string } }
{ $description "Creates a direcory in the given root for a new vocabulary and adds a main .factor file, a tests file, and an authors.txt file." } ;
{ $description "Creates a directory in the given root for a new vocabulary and adds a main .factor file, a tests file, and an authors.txt file." } ;
HELP: using
{ $description "Stores the vocabularies that are pulled into the documentation file from looking up the stack effect types." } ;

View File

@ -4,9 +4,10 @@
USING: accessors arrays assocs classes.tuple combinators
compiler.units continuations debugger definitions help help.crossref
help.markup help.topics io io.pathnames io.streams.string kernel lexer
make math math.order memoize namespaces parser quotations prettyprint
make math math.order memoize namespaces parser prettyprint quotations
sequences sets sorting source-files strings summary tools.crossref
tools.vocabs tools.vocabs.browser vectors vocabs vocabs.parser words ;
tools.scaffold tools.vocabs tools.vocabs.browser vectors vocabs
vocabs.loader vocabs.parser words ;
IN: fuel
@ -330,7 +331,7 @@ SYMBOL: vocab-list
[ describe-words ] with-string-writer \ describe-words swap 2array ; inline
: (fuel-vocab-help) ( name -- element )
\ article swap dup >vocab-link
dup require \ article swap dup >vocab-link
[
{
[ vocab-authors [ \ $authors prefix , ] when* ]
@ -360,13 +361,24 @@ MEMO: (fuel-get-vocabs/author) ( author -- element )
: fuel-get-vocabs/author ( author -- )
(fuel-get-vocabs/author) fuel-eval-set-result ;
MEMO: (fuel-get-vocabs/tag ( tag -- element )
MEMO: (fuel-get-vocabs/tag) ( tag -- element )
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
[ tagged fuel-vocab-list ] bi 2array ;
: fuel-get-vocabs/tag ( tag -- )
(fuel-get-vocabs/tag fuel-eval-set-result ;
(fuel-get-vocabs/tag) fuel-eval-set-result ;
! Scaffold support
: fuel-scaffold-vocab ( root name devname -- )
developer-name set
[ scaffold-vocab ] 2keep [ (normalize-path) ] dip dup
append-path append-path ".factor" append fuel-eval-set-result ;
: fuel-scaffold-help ( name devname -- )
developer-name set
dup require dup scaffold-help vocab-docs-path
(normalize-path) fuel-eval-set-result ;
! -run=fuel support

View File

@ -43,6 +43,26 @@ beast.
Many aspects of the environment can be customized:
M-x customize-group fuel will show you how many.
*** Faster listener startup
On startup, run-factor loads the fuel vocabulary, which can take a
while. If you want to speedup the load process, type 'save' in the
listener prompt just after invoking run-factor. This will save a
factor image (overwriting the current one) with all the needed
vocabs.
*** Vocabulary creation
FUEL offers a basic interface with Factor's scaffolding utilities.
To create a new vocabulary directory and associated files:
M-x fuel-scaffold-vocab
and when in a vocab file, to create a docs file with boilerplate
for each word:
M-x fuel-scaffold-help
* Quick key reference
(Triple chords ending in a single letter <x> accept also C-<x> (e.g.

View File

@ -111,7 +111,7 @@ code in the buffer."
(= (- be (point)) (current-indentation))
(= ln (line-number-at-pos be)))
(fuel-syntax--indentation-at bs))
((or (fuel-syntax--is-eol bs)
((or (fuel-syntax--is-last-char bs)
(not (eq ?\ (char-after (1+ bs)))))
(fuel-syntax--increased-indentation
(fuel-syntax--indentation-at bs)))
@ -238,15 +238,17 @@ code in the buffer."
;;; Keymap:
(defun factor-mode-insert-and-indent (n)
(interactive "p")
(self-insert-command n)
(defun factor-mode--insert-and-indent (n)
(interactive "*p")
(let ((start (point)))
(self-insert-command n)
(save-excursion (font-lock-fontify-region start (point))))
(indent-according-to-mode))
(defvar factor-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [?\]] 'factor-mode-insert-and-indent)
(define-key map [?}] 'factor-mode-insert-and-indent)
(define-key map [?\]] 'factor-mode--insert-and-indent)
(define-key map [?}] 'factor-mode--insert-and-indent)
(define-key map "\C-m" 'newline-and-indent)
(define-key map "\C-co" 'factor-mode-visit-other-file)
(define-key map "\C-c\C-o" 'factor-mode-visit-other-file)

View File

@ -1,6 +1,6 @@
;;; fu.el --- Startup file for FUEL
;; Copyright (C) 2008 Jose Antonio Ortega Ruiz
;; Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz
;; See http://factorcode.org/license.txt for BSD license.
;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
@ -24,6 +24,11 @@
"Minor mode showing in the minibuffer a synopsis of Factor word at point."
t)
(autoload 'fuel-scaffold-vocab "fuel-scaffold.el"
"Create a new Factor vocabulary." t)
(autoload 'fuel-scaffold-help "fuel-scaffold.el"
"Create a Factor vocabulary help file." t)
;;; fu.el ends here

View File

@ -42,7 +42,7 @@
(factor (case sexp
(:rs 'fuel-eval-restartable)
(:nrs 'fuel-eval-non-restartable)
(:in (fuel-syntax--current-vocab))
(:in (or (fuel-syntax--current-vocab) "fuel"))
(:usings `(:array ,@(fuel-syntax--usings)))
(:get 'fuel-eval-set-result)
(:end '\;)
@ -70,7 +70,7 @@
(defsubst factor--fuel-in (in)
(cond ((or (eq in :in) (null in)) :in)
((eq in 'f) 'f)
((eq in 't) "fuel-scratchpad")
((eq in 't) "fuel")
((stringp in) in)
(t (error "Invalid 'in' (%s)" in))))

View File

@ -107,7 +107,6 @@
(list (cons 'font-lock-syntactic-keywords
fuel-syntax--syntactic-keywords))))))
;;; Fontify strings as Factor code:

View File

@ -102,6 +102,8 @@ buffer."
(defun fuel-listener-nuke ()
(interactive)
(goto-char (point-max))
(comint-kill-region comint-last-input-start (point))
(comint-redirect-cleanup)
(fuel-con--setup-connection fuel-listener--buffer))

View File

@ -0,0 +1,84 @@
;;; fuel-scaffold.el -- interaction with tools.scaffold
;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
;; See http://factorcode.org/license.txt for BSD license.
;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
;; Keywords: languages, fuel, factor
;; Start date: Sun Jan 11, 2009 18:40
;;; Comentary:
;; Utilities for creating new vocabulary files and other boilerplate.
;; Mainly, an interface to Factor's tools.scaffold.
;;; Code:
(require 'fuel-eval)
(require 'fuel-edit)
(require 'fuel-syntax)
(require 'fuel-base)
;;; Customisation:
(defgroup fuel-scaffold nil
"Options for FUEL's scaffolding."
:group 'fuel)
(defcustom fuel-scaffold-developer-name user-full-name
"The name to be inserted as yours in scaffold templates."
:type 'string
:group 'fuel-scaffold)
;;; Auxiliary functions:
(defun fuel-scaffold--vocab-roots ()
(let ((cmd '(:fuel* (vocab-roots get :get) "fuel")))
(fuel-eval--retort-result (fuel-eval--send/wait cmd))))
;;; User interface:
(defun fuel-scaffold-vocab ()
"Creates a directory in the given root for a new vocabulary and
adds source, tests and authors.txt files.
You can configure `fuel-scaffold-developer-name' (set by default to
`user-full-name') for the name to be inserted in the generated files."
(interactive)
(let* ((name (read-string "Vocab name: "))
(root (completing-read "Vocab root: "
(fuel-scaffold--vocab-roots)
nil t "resource:"))
(cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name)
(fuel-scaffold-vocab)) "fuel"))
(ret (fuel-eval--send/wait cmd))
(file (fuel-eval--retort-result ret)))
(unless file
(error "Error creating vocab (%s)" (car (fuel-eval--retort-error ret))))
(find-file file)
(goto-char (point-max))))
(defun fuel-scaffold-help (&optional arg)
"Creates, if it does not already exist, a help file with
scaffolded help for each word in the current vocabulary.
With prefix argument, ask for the vocabulary name.
You can configure `fuel-scaffold-developer-name' (set by default to
`user-full-name') for the name to be inserted in the generated file."
(interactive "P")
(let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
(fuel-edit--read-vocabulary-name nil)))
(cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help)
"fuel"))
(ret (fuel-eval--send/wait cmd))
(file (fuel-eval--retort-result ret)))
(unless file
(error "Error creating help file" (car (fuel-eval--retort-error ret))))
(find-file file)))
(provide 'fuel-scaffold)
;;; fuel-scaffold.el ends here

View File

@ -44,14 +44,14 @@
(defconst fuel-syntax--parsing-words
'(":" "::" ";" "<<" "<PRIVATE" ">>"
"ALIAS:"
"ABOUT:" "ALIAS:" "ARTICLE:"
"B" "BIN:"
"C:" "C-STRUCT:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method"
"DEFER:"
"ERROR:" "EXCLUDE:"
"f" "FORGET:" "FROM:"
"GENERIC#" "GENERIC:"
"HEX:" "HOOK:"
"HELP:" "HEX:" "HOOK:"
"IN:" "initial:" "INSTANCE:" "INTERSECTION:"
"M:" "MACRO:" "MACRO::" "MAIN:" "MATH:" "MEMO:" "MEMO:" "METHOD:" "MIXIN:"
"OCT:"
@ -63,12 +63,12 @@
"UNION:" "USE:" "USING:"
"VARS:"))
(defconst fuel-syntax--bracers
'("B" "BV" "C" "CS" "H" "T" "V" "W"))
(defconst fuel-syntax--parsing-words-regex
(regexp-opt fuel-syntax--parsing-words 'words))
(defconst fuel-syntax--bracers
'("B" "BV" "C" "CS" "H" "T" "V" "W"))
(defconst fuel-syntax--brace-words-regex
(format "%s{" (regexp-opt fuel-syntax--bracers t)))
@ -91,7 +91,7 @@
"\\_<-?\\([0-9]+\\+\\)?[0-9]+/-?[0-9]+\\_>")
(defconst fuel-syntax--float-regex
"\\_<-?[0-9]+\\.[0-9]*\\([eE]-?[0-9]+\\)?\\_>")
"\\_<-?[0-9]+\\.[0-9]*\\([eE][+-]?[0-9]+\\)?\\_>")
(defconst fuel-syntax--word-definition-regex
(fuel-syntax--second-word-regex
@ -148,12 +148,14 @@
fuel-syntax--declaration-words-regex))
(defconst fuel-syntax--single-liner-regex
(format "^%s" (regexp-opt '("ALIAS:"
(format "^%s" (regexp-opt '("ABOUT:"
"ARTICLE:"
"ALIAS:"
"CONSTANT:" "C:"
"DEFER:"
"FORGET:"
"GENERIC:" "GENERIC#"
"HEX:" "HOOK:"
"HELP:" "HEX:" "HOOK:"
"IN:" "INSTANCE:"
"MAIN:" "MATH:" "MIXIN:"
"OCT:"
@ -216,8 +218,7 @@
(" \\(|\\) " (1 "(|"))
(" \\(|\\)$" (1 ")"))
;; Opening brace words:
(,(format "\\_<%s\\({\\)\\_>" (regexp-opt fuel-syntax--bracers)) (1 "(}"))
("\\_<\\({\\)\\_>" (1 "(}"))
("\\_<\\w*\\({\\)\\_>" (1 "(}"))
("\\_<\\(}\\)\\_>" (1 "){"))
;; Parenthesis:
("\\_<\\((\\)\\_>" (1 "()"))
@ -261,7 +262,7 @@
(defsubst fuel-syntax--looking-at-emptiness ()
(looking-at "^[ ]*$\\|$"))
(defsubst fuel-syntax--is-eol (pos)
(defsubst fuel-syntax--is-last-char (pos)
(save-excursion
(goto-char (1+ pos))
(fuel-syntax--looking-at-emptiness)))