From 992633dd32f9131a6bdf56b2a032617e98cd098b Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sun, 4 Jan 2009 00:01:51 +0100 Subject: [PATCH] FUEL: Help system now displays vocab help. --- extra/fuel/fuel.factor | 11 +++++++++++ misc/fuel/fuel-help.el | 11 +++++++++++ misc/fuel/fuel-markup.el | 21 ++++++++++++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 8e4249fe22..5306ff9d00 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -273,6 +273,17 @@ MEMO: fuel-article-title ( name -- title/f ) } cleave ] { } make 3array ; +: (fuel-vocab-help) ( name -- element ) + \ article swap dup >vocab-link + [ + [ summary [ , ] [ "No summary available" , ] if* ] + [ drop \ $nl , ] + [ vocab-help article [ content>> % ] when* ] tri + ] { } make 3array ; + +: fuel-vocab-help ( name -- ) + (fuel-vocab-help) fuel-eval-set-result ; inline + : (fuel-index) ( seq -- seq ) [ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ; diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el index ba77ea7ef1..8124fff19f 100644 --- a/misc/fuel/fuel-help.el +++ b/misc/fuel/fuel-help.el @@ -111,10 +111,21 @@ (fuel-help--insert-contents label res) (message ""))) +(defun fuel-help--get-vocab (name) + (message "Retrieving vocabulary help ...") + (let* ((cmd `(:fuel* ((,name fuel-vocab-help)) "fuel" (,name))) + (ret (fuel-eval--send/wait cmd 2000)) + (res (fuel-eval--retort-result ret))) + (if (not res) + (message "No help available for vocabulary %s" name) + (fuel-help--insert-contents label res) + (message "")))) + (defun fuel-help--follow-link (label link type) (let ((fuel-help-always-ask nil)) (cond ((eq type 'word) (fuel-help--word-help nil link)) ((eq type 'article) (fuel-help--get-article link label)) + ((eq type 'vocab) (fuel-help--get-vocab link)) (t (message (format "Links of type %s not yet implemented" type)))))) (defun fuel-help--insert-contents (def art &optional nopush) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 6f139b05b5..9896c4a934 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -102,6 +102,7 @@ ($nl . fuel-markup--newline) ($notes . fuel-markup--notes) ($parsing-note . fuel-markup--parsing-note) + ($predicate . fuel-markup--predicate) ($prettyprinting-note . fuel-markup--prettyprinting-note) ($quotation . fuel-markup--quotation) ($references . fuel-markup--references) @@ -199,6 +200,12 @@ (fuel-markup--link (cons '$link (cdr e))) (fuel-markup--maybe-nl)) +(defun fuel-markup--vocab-subsection (e) + (fuel-markup--insert-nl-if-nb) + (insert " - ") + (fuel-markup--vocab-link (cons '$vocab-link (cdr e))) + (fuel-markup--maybe-nl)) + (defun fuel-markup--newline (e) (fuel-markup--insert-newline) (newline)) @@ -292,8 +299,8 @@ (insert " "))) (defun fuel-markup--vocabulary (e) - (fuel-markup--insert-heading "Vocabulary:" t) - (insert " " (cadr e)) + (fuel-markup--insert-heading "Vocabulary: " t) + (fuel-markup--vocab-link (cons '$vocab-link (cdr e))) (newline)) (defun fuel-markup--list (e) @@ -335,6 +342,13 @@ (fuel-markup--print (cdr val)) (newline))) +(defun fuel-markup--predicate (e) + (fuel-markup--values '($values ("object" object) ("?" "a boolean"))) + (let ((word (make-symbol (substring (format "%s" (cadr e)) 0 -1)))) + (fuel-markup--description + `($description "Tests if the object is an instance of the " + ($link ,word) " class.")))) + (defun fuel-markup--side-effects (e) (fuel-markup--insert-heading "Side effects") (insert "Modifies ") @@ -436,9 +450,6 @@ (defun fuel-markup--quotation (e) (insert (format " %S " e))) -(defun fuel-markup--vocab-subsection (e) - (insert (format " %S " e))) - (provide 'fuel-markup) ;;; fuel-markup.el ends here