FUEL: Help index pages implemented (but no vocab-index yet).
parent
796a7e9d37
commit
1ef58cbd43
|
@ -273,6 +273,12 @@ MEMO: fuel-article-title ( name -- title/f )
|
||||||
} cleave
|
} cleave
|
||||||
] { } make 3array ;
|
] { } make 3array ;
|
||||||
|
|
||||||
|
: (fuel-index) ( seq -- seq )
|
||||||
|
[ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
|
||||||
|
|
||||||
|
: fuel-index ( quot -- )
|
||||||
|
call (fuel-index) fuel-eval-set-result ; inline
|
||||||
|
|
||||||
MEMO: fuel-find-word ( name -- word/f )
|
MEMO: 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 ;
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
(fuel-help--insert-contents def res)))))))
|
(fuel-help--insert-contents def res)))))))
|
||||||
|
|
||||||
(defun fuel-help--get-article (name label)
|
(defun fuel-help--get-article (name label)
|
||||||
(message "Retriving article ...")
|
(message "Retrieving article ...")
|
||||||
(let* ((cmd `(:fuel* ((,name fuel-get-article)) "fuel" t))
|
(let* ((cmd `(:fuel* ((,name fuel-get-article)) "fuel" t))
|
||||||
(ret (fuel-eval--send/wait cmd 2000))
|
(ret (fuel-eval--send/wait cmd 2000))
|
||||||
(res (fuel-eval--retort-result ret)))
|
(res (fuel-eval--retort-result ret)))
|
||||||
|
|
|
@ -60,10 +60,13 @@
|
||||||
(message "Link %s pointing to %s named %s" label type link))
|
(message "Link %s pointing to %s named %s" label type link))
|
||||||
|
|
||||||
(defun fuel-markup--insert-button (label link type)
|
(defun fuel-markup--insert-button (label link type)
|
||||||
(insert-text-button (format "%s" label)
|
(let ((label (format "%s" label))
|
||||||
:type 'fuel-markup--button
|
(link (format "%s" link)))
|
||||||
'markup-link (format "%s" link)
|
(insert-text-button label
|
||||||
'markup-link-type type))
|
:type 'fuel-markup--button
|
||||||
|
'markup-link link
|
||||||
|
'markup-link-type type
|
||||||
|
'help-echo link)))
|
||||||
|
|
||||||
(defun fuel-markup--article-title (name)
|
(defun fuel-markup--article-title (name)
|
||||||
(fuel-eval--retort-result
|
(fuel-eval--retort-result
|
||||||
|
@ -86,6 +89,7 @@
|
||||||
($example . fuel-markup--example)
|
($example . fuel-markup--example)
|
||||||
($examples . fuel-markup--examples)
|
($examples . fuel-markup--examples)
|
||||||
($heading . fuel-markup--heading)
|
($heading . fuel-markup--heading)
|
||||||
|
($index . fuel-markup--index)
|
||||||
($instance . fuel-markup--instance)
|
($instance . fuel-markup--instance)
|
||||||
($io-error . fuel-markup--io-error)
|
($io-error . fuel-markup--io-error)
|
||||||
($link . fuel-markup--link)
|
($link . fuel-markup--link)
|
||||||
|
@ -142,6 +146,11 @@
|
||||||
((symbolp e) (fuel-markup--print (list '$link e)))
|
((symbolp e) (fuel-markup--print (list '$link e)))
|
||||||
(t (insert (format "\n%S\n" e)))))
|
(t (insert (format "\n%S\n" e)))))
|
||||||
|
|
||||||
|
(defun fuel-markup--print-str (e)
|
||||||
|
(with-temp-buffer
|
||||||
|
(fuel-markup--print e)
|
||||||
|
(buffer-string)))
|
||||||
|
|
||||||
(defun fuel-markup--maybe-nl ()
|
(defun fuel-markup--maybe-nl ()
|
||||||
(setq fuel-markup--maybe-nl (point)))
|
(setq fuel-markup--maybe-nl (point)))
|
||||||
|
|
||||||
|
@ -214,10 +223,8 @@
|
||||||
(insert (cadr e))))
|
(insert (cadr e))))
|
||||||
|
|
||||||
(defun fuel-markup--snippet (e)
|
(defun fuel-markup--snippet (e)
|
||||||
(let ((snip (cadr e)))
|
(let ((snip (fuel-markup--print-str (cdr e))))
|
||||||
(if (stringp snip)
|
(insert (fuel-font-lock--factor-str snip))))
|
||||||
(insert (fuel-font-lock--factor-str snip))
|
|
||||||
(fuel-markup--print snip))))
|
|
||||||
|
|
||||||
(defun fuel-markup--code (e)
|
(defun fuel-markup--code (e)
|
||||||
(fuel-markup--insert-nl-if-nb)
|
(fuel-markup--insert-nl-if-nb)
|
||||||
|
@ -247,7 +254,8 @@
|
||||||
(defun fuel-markup--link (e)
|
(defun fuel-markup--link (e)
|
||||||
(let* ((link (cadr e))
|
(let* ((link (cadr e))
|
||||||
(type (if (symbolp link) 'word 'article))
|
(type (if (symbolp link) 'word 'article))
|
||||||
(label (or (and (eq type 'article)
|
(label (or (car (cddr e))
|
||||||
|
(and (eq type 'article)
|
||||||
(fuel-markup--article-title link))
|
(fuel-markup--article-title link))
|
||||||
link)))
|
link)))
|
||||||
(fuel-markup--insert-button label link type)))
|
(fuel-markup--insert-button label link type)))
|
||||||
|
@ -258,8 +266,21 @@
|
||||||
(fuel-markup--link (list '$link link))
|
(fuel-markup--link (list '$link link))
|
||||||
(insert " ")))
|
(insert " ")))
|
||||||
|
|
||||||
(defun fuel-markup--vocab-subsection (e)
|
(defun fuel-markup--index-quotation (q)
|
||||||
(insert (format " %S " e)))
|
(cond ((null q) null)
|
||||||
|
((listp q) (vconcat (mapcar 'fuel-markup--index-quotation q)))
|
||||||
|
(t q)))
|
||||||
|
|
||||||
|
(defun fuel-markup--index (e)
|
||||||
|
(let* ((q (fuel-markup--index-quotation (cadr e)))
|
||||||
|
(cmd `(:fuel* ((,q fuel-index)) "fuel"
|
||||||
|
("builtins" "help" "help.topics" "classes"
|
||||||
|
"classes.builtin" "classes.tuple"
|
||||||
|
"classes.singleton" "classes.union"
|
||||||
|
"classes.intersection" "classes.predicate")))
|
||||||
|
(subs (fuel-eval--retort-result (fuel-eval--send/wait cmd 200))))
|
||||||
|
(when subs
|
||||||
|
(fuel-markup--print subs))))
|
||||||
|
|
||||||
(defun fuel-markup--vocab-link (e)
|
(defun fuel-markup--vocab-link (e)
|
||||||
(fuel-markup--insert-button (cadr e) (cadr e) 'vocab))
|
(fuel-markup--insert-button (cadr e) (cadr e) 'vocab))
|
||||||
|
@ -343,7 +364,10 @@
|
||||||
|
|
||||||
(defun fuel-markup--references (e)
|
(defun fuel-markup--references (e)
|
||||||
(fuel-markup--insert-heading "References")
|
(fuel-markup--insert-heading "References")
|
||||||
(fuel-markup--links (cons '$links (cdr e))))
|
(dolist (ref (cdr e))
|
||||||
|
(if (listp ref)
|
||||||
|
(fuel-markup--print ref)
|
||||||
|
(fuel-markup--subsection (list '$subsection ref)))))
|
||||||
|
|
||||||
(defun fuel-markup--see-also (e)
|
(defun fuel-markup--see-also (e)
|
||||||
(fuel-markup--insert-heading "See also")
|
(fuel-markup--insert-heading "See also")
|
||||||
|
@ -412,6 +436,9 @@
|
||||||
(defun fuel-markup--quotation (e)
|
(defun fuel-markup--quotation (e)
|
||||||
(insert (format " %S " e)))
|
(insert (format " %S " e)))
|
||||||
|
|
||||||
|
(defun fuel-markup--vocab-subsection (e)
|
||||||
|
(insert (format " %S " e)))
|
||||||
|
|
||||||
|
|
||||||
(provide 'fuel-markup)
|
(provide 'fuel-markup)
|
||||||
;;; fuel-markup.el ends here
|
;;; fuel-markup.el ends here
|
||||||
|
|
Loading…
Reference in New Issue