From 9b17f0a7f213cea6067d4c678a3eedb2fb8659be Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 15 Dec 2008 19:01:07 -0600 Subject: [PATCH 1/6] bubble-chamber: Rearrange the example configurations --- extra/bubble-chamber/bubble-chamber.factor | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/extra/bubble-chamber/bubble-chamber.factor b/extra/bubble-chamber/bubble-chamber.factor index 086faf4f23..292ac7e59f 100644 --- a/extra/bubble-chamber/bubble-chamber.factor +++ b/extra/bubble-chamber/bubble-chamber.factor @@ -524,6 +524,24 @@ M:: update-frame-buffer ( BUBBLE-CHAMBER -- ) ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +: hadron-chamber ( -- ) + bubble-chamber-window + 1000 [ hadron add-particle ] times + big-bang + drop ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! Experimental +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: muon-chamber ( -- ) + bubble-chamber-window + 1000 [ muon add-particle ] times + dup particles>> [ collide randomize-collision-theta ] each + drop ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + : original-big-bang ( -- ) bubble-chamber { 1000 1000 } >>size @@ -541,22 +559,6 @@ M:: update-frame-buffer ( BUBBLE-CHAMBER -- ) ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: hadron-chamber ( -- ) - bubble-chamber-window - 1000 [ hadron add-particle ] times - big-bang - drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: muon-chamber ( -- ) - bubble-chamber-window - 1000 [ muon add-particle ] times - dup particles>> [ collide randomize-collision-theta ] each - drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - : original-big-bang-variant ( -- ) bubble-chamber-window 1789 [ muon add-particle ] times @@ -565,4 +567,3 @@ M:: update-frame-buffer ( BUBBLE-CHAMBER -- ) 111 [ axion add-particle ] times dup particles>> [ collide randomize-collision-theta ] each drop ; - From 23330d7653793f13ad2e6e7508da4fae1c608c55 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 15 Dec 2008 19:02:46 -0600 Subject: [PATCH 2/6] Add runnable demo vocabulary 'bubble-chamber.ten-hadrons' --- extra/bubble-chamber/ten-hadrons/tags.txt | 1 + extra/bubble-chamber/ten-hadrons/ten-hadrons.factor | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 extra/bubble-chamber/ten-hadrons/tags.txt create mode 100644 extra/bubble-chamber/ten-hadrons/ten-hadrons.factor diff --git a/extra/bubble-chamber/ten-hadrons/tags.txt b/extra/bubble-chamber/ten-hadrons/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/bubble-chamber/ten-hadrons/tags.txt @@ -0,0 +1 @@ +demos diff --git a/extra/bubble-chamber/ten-hadrons/ten-hadrons.factor b/extra/bubble-chamber/ten-hadrons/ten-hadrons.factor new file mode 100644 index 0000000000..a29ecf8990 --- /dev/null +++ b/extra/bubble-chamber/ten-hadrons/ten-hadrons.factor @@ -0,0 +1,8 @@ + +USING: ui bubble-chamber ; + +IN: bubble-chamber.ten-hadrons + +: main ( -- ) [ ten-hadrons ] with-ui ; + +MAIN: main \ No newline at end of file From 078988b5231131e8a64253745368630cec8106a6 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 15 Dec 2008 19:03:31 -0600 Subject: [PATCH 3/6] Add runnable demo vocabulary 'bubble-chamber.hadron-chamber' --- extra/bubble-chamber/hadron-chamber/hadron-chamber.factor | 8 ++++++++ extra/bubble-chamber/hadron-chamber/tags.txt | 1 + 2 files changed, 9 insertions(+) create mode 100644 extra/bubble-chamber/hadron-chamber/hadron-chamber.factor create mode 100644 extra/bubble-chamber/hadron-chamber/tags.txt diff --git a/extra/bubble-chamber/hadron-chamber/hadron-chamber.factor b/extra/bubble-chamber/hadron-chamber/hadron-chamber.factor new file mode 100644 index 0000000000..4046724b82 --- /dev/null +++ b/extra/bubble-chamber/hadron-chamber/hadron-chamber.factor @@ -0,0 +1,8 @@ + +USING: ui bubble-chamber ; + +IN: bubble-chamber.hadron-chamber + +: main ( -- ) [ hadron-chamber ] with-ui ; + +MAIN: main \ No newline at end of file diff --git a/extra/bubble-chamber/hadron-chamber/tags.txt b/extra/bubble-chamber/hadron-chamber/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/bubble-chamber/hadron-chamber/tags.txt @@ -0,0 +1 @@ +demos From 5d20b0e202a3cf63d0e20d76dc7ab77fa5085be5 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 15 Dec 2008 19:03:55 -0600 Subject: [PATCH 4/6] Add runnable demo vocabulary 'bubble-chamber.original' --- extra/bubble-chamber/original/original.factor | 8 ++++++++ extra/bubble-chamber/original/tags.txt | 1 + 2 files changed, 9 insertions(+) create mode 100644 extra/bubble-chamber/original/original.factor create mode 100644 extra/bubble-chamber/original/tags.txt diff --git a/extra/bubble-chamber/original/original.factor b/extra/bubble-chamber/original/original.factor new file mode 100644 index 0000000000..4d1744eb64 --- /dev/null +++ b/extra/bubble-chamber/original/original.factor @@ -0,0 +1,8 @@ + +USING: ui bubble-chamber ; + +IN: bubble-chamber.original + +: main ( -- ) [ original ] with-ui ; + +MAIN: main \ No newline at end of file diff --git a/extra/bubble-chamber/original/tags.txt b/extra/bubble-chamber/original/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/bubble-chamber/original/tags.txt @@ -0,0 +1 @@ +demos From 472a8edcc880467836555966d2f6a4f0d2630e52 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Tue, 16 Dec 2008 02:09:18 +0100 Subject: [PATCH 5/6] FUEL: Word completion in listener, bound to TAB by default. --- extra/fuel/fuel.factor | 19 +++++++++++-------- misc/fuel/README | 12 ++++++++++-- misc/fuel/fuel-completion.el | 17 ++++++++++------- misc/fuel/fuel-listener.el | 22 +++++++++++++++++++--- misc/fuel/fuel-syntax.el | 16 ++++++++++++++-- 5 files changed, 64 insertions(+), 22 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 5a39fe9f2b..bf36969219 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -163,32 +163,35 @@ M: source-file fuel-pprint path>> fuel-pprint ; : fuel-get-edit-location ( defspec -- ) where [ first2 [ (normalize-path) ] dip 2array fuel-eval-set-result - ] when* ; + ] when* ; inline : fuel-get-vocab-location ( vocab -- ) - >vocab-link fuel-get-edit-location ; + >vocab-link fuel-get-edit-location ; inline : (fuel-get-vocabs) ( -- seq ) all-vocabs-seq [ vocab-name ] map ; inline : fuel-get-vocabs ( -- ) - (fuel-get-vocabs) fuel-eval-set-result ; + (fuel-get-vocabs) fuel-eval-set-result ; inline MEMO: (fuel-vocab-words) ( name -- seq ) >vocab-link words [ name>> ] map ; -: fuel-vocabs-words ( names/f -- seq ) - [ (fuel-get-vocabs) ] unless* prune - [ (fuel-vocab-words) ] map concat natural-sort ; +: fuel-current-words ( -- seq ) + use get [ keys ] map concat ; inline + +: fuel-vocabs-words ( names -- seq ) + prune [ (fuel-vocab-words) ] map concat ; inline : (fuel-get-words) ( prefix names/f -- seq ) - fuel-vocabs-words swap [ drop-prefix nip length 0 = ] curry filter ; + [ fuel-vocabs-words ] [ fuel-current-words ] if* natural-sort + swap [ drop-prefix nip length 0 = ] curry filter ; : fuel-get-words ( prefix names -- ) (fuel-get-words) fuel-eval-set-result ; inline : fuel-run-file ( path -- ) run-file ; inline -: fuel-startup ( -- ) "listener" run ; inline +: fuel-startup ( -- ) "listener" run-file ; inline MAIN: fuel-startup diff --git a/misc/fuel/README b/misc/fuel/README index 3754e816a9..2bf58cbdc7 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -55,19 +55,27 @@ the same as C-cz)). - C-cz : switch to listener - C-co : cycle between code, tests and docs factor files - - M-. : edit word at point in Emacs (also in listener) + - M-. : edit word at point in Emacs - M-TAB : complete word at point - C-cC-ev : edit vocabulary - C-cr, C-cC-er : eval region - C-M-r, C-cC-ee : eval region, extending it to definition boundaries - C-M-x, C-cC-ex : eval definition around point - - C-ck, C-cC-ek : compile file + - C-ck, C-cC-ek : run file - C-cC-da : toggle autodoc mode - C-cC-dd : help for word at point - C-cC-ds : short help word at point +* In the listener: + + - TAB : complete word at point + - M-. : edit word at point in Emacs + - C-cv : edit vocabulary + - C-ch : help for word at point + - C-ck : run file + * In the debugger (it pops up upon eval/compilation errors): - g : go to error diff --git a/misc/fuel/fuel-completion.el b/misc/fuel/fuel-completion.el index bffa2aa0fc..66657cbfcf 100644 --- a/misc/fuel/fuel-completion.el +++ b/misc/fuel/fuel-completion.el @@ -32,9 +32,11 @@ (fuel-eval--send/wait '(:fuel* (fuel-get-vocabs) "fuel" (:array))))))) fuel-completion--vocabs) -(defsubst fuel-completion--words (prefix vocabs) - (fuel-eval--retort-result - (fuel-eval--send/wait `(:fuel* (,prefix V{ ,@vocabs } fuel-get-words) t ,vocabs)))) +(defun fuel-completion--words (prefix vocabs) + (let ((vs (if vocabs (cons :array vocabs) 'f)) + (us (or vocabs 't))) + (fuel-eval--retort-result + (fuel-eval--send/wait `(:fuel* (,prefix ,vs fuel-get-words) t ,us))))) ;;; Completions window handling, heavily inspired in slime's: @@ -135,10 +137,11 @@ terminates a current completion." ;;; Completion functionality: -(defsubst fuel-completion--word-list (prefix) - (let ((fuel-log--inhibit-p t)) - (fuel-completion--words - prefix `("syntax" ,(fuel-syntax--current-vocab) ,@(fuel-syntax--usings))))) +(defun fuel-completion--word-list (prefix) + (let* ((fuel-log--inhibit-p t) + (cv (fuel-syntax--current-vocab)) + (vs (and cv `("syntax" ,cv ,@(fuel-syntax--usings))))) + (fuel-completion--words prefix vs))) (defun fuel-completion--complete (prefix) (let* ((words (fuel-completion--word-list prefix)) diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el index 7c71cbf03c..d2f8cff9db 100644 --- a/misc/fuel/fuel-listener.el +++ b/misc/fuel/fuel-listener.el @@ -15,6 +15,8 @@ (require 'fuel-eval) (require 'fuel-base) +(require 'fuel-completion) +(require 'fuel-syntax) (require 'comint) @@ -68,10 +70,10 @@ buffer." (error "Could not run factor: image file %s not readable" image)) (message "Starting FUEL listener ...") (comint-exec (fuel-listener--buffer) "factor" - factor nil `("-run=fuel" ,(format "-i=%s" image))) + factor nil `("-run=listener" ,(format "-i=%s" image))) (pop-to-buffer (fuel-listener--buffer)) (goto-char (point-max)) - (comint-send-string nil "USE: fuel \"\\nFUEL loaded\\n\" write\n") + (comint-send-string nil "USE: fuel \"FUEL loaded\\n\" write\n") (fuel-listener--wait-for-prompt 30) (message "FUEL listener up and running!"))) @@ -101,6 +103,17 @@ 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)) + ;;; Interface: starting fuel listener @@ -126,13 +139,16 @@ buffer." \\{fuel-listener-mode-map}" (set (make-local-variable 'comint-prompt-regexp) fuel-listener--prompt-regex) (set (make-local-variable 'comint-prompt-read-only) t) - (setq fuel-listener--compilation-begin nil)) + (fuel-listener--setup-completion)) (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-ch" 'fuel-help) (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) (define-key fuel-listener-mode-map "\C-ck" 'fuel-run-file) +(define-key fuel-listener-mode-map (kbd "TAB") 'fuel-completion--complete-symbol) (provide 'fuel-listener) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index a492a7b647..936bded3a5 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -241,7 +241,13 @@ ;;; USING/IN: -(defun fuel-syntax--current-vocab () +(make-variable-buffer-local + (defvar fuel-syntax--current-vocab-function 'fuel-syntax--find-in)) + +(defsubst fuel-syntax--current-vocab () + (funcall fuel-syntax--current-vocab-function)) + +(defun fuel-syntax--find-in () (let* ((vocab) (ip (save-excursion @@ -258,7 +264,13 @@ (setq vocab (format "%s.%s" vocab (downcase sub)))))))) vocab)) -(defun fuel-syntax--usings () +(make-variable-buffer-local + (defvar fuel-syntax--usings-function 'fuel-syntax--find-usings)) + +(defsubst fuel-syntax--usings () + (funcall fuel-syntax--usings-function)) + +(defun fuel-syntax--find-usings () (save-excursion (let ((usings) (in (fuel-syntax--current-vocab))) From de10ff8cb41884c065b1a156d955d1e8d609b3e3 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Tue, 16 Dec 2008 02:29:24 +0100 Subject: [PATCH 6/6] FUEL: Highlight matched subword in completion buffer; autodoc in listener. --- misc/fuel/README | 1 + misc/fuel/fuel-completion.el | 2 +- misc/fuel/fuel-listener.el | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/fuel/README b/misc/fuel/README index 2bf58cbdc7..9686124813 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -72,6 +72,7 @@ the same as C-cz)). - TAB : complete word at point - M-. : edit word at point in Emacs + - C-ca : toggle autodoc mode - C-cv : edit vocabulary - C-ch : help for word at point - C-ck : run file diff --git a/misc/fuel/fuel-completion.el b/misc/fuel/fuel-completion.el index 66657cbfcf..6b89dbb008 100644 --- a/misc/fuel/fuel-completion.el +++ b/misc/fuel/fuel-completion.el @@ -110,7 +110,7 @@ terminates a current completion." (defun fuel-completion--display-comp-list (completions base) (let ((savedp (fuel-completion--maybe-save-window-configuration))) (with-output-to-temp-buffer fuel-completion--comp-buffer - (display-completion-list completions) + (display-completion-list completions base) (let ((offset (- (point) 1 (length base)))) (with-current-buffer standard-output (setq completion-base-size offset) diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el index d2f8cff9db..f2dc760f94 100644 --- a/misc/fuel/fuel-listener.el +++ b/misc/fuel/fuel-listener.el @@ -143,6 +143,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-ca" 'fuel-autodoc-mode) (define-key fuel-listener-mode-map "\C-ch" 'fuel-help) (define-key fuel-listener-mode-map "\M-." 'fuel-edit-word-at-point) (define-key fuel-listener-mode-map "\C-cv" 'fuel-edit-vocabulary)