/misc/fuel/fuel-markup.el

http://github.com/abeaumont/factor · Emacs Lisp · 623 lines · 506 code · 104 blank · 13 comment · 2 complexity · d7058e083ed9a57a80f3633e4b7365bb MD5 · raw file

  1. ;;; fuel-markup.el -- printing factor help markup
  2. ;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
  3. ;; See http://factorcode.org/license.txt for BSD license.
  4. ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
  5. ;; Keywords: languages, fuel, factor
  6. ;; Start date: Thu Jan 01, 2009 21:43
  7. ;;; Comentary:
  8. ;; Utilities for printing Factor's help markup.
  9. ;;; Code:
  10. (require 'fuel-eval)
  11. (require 'fuel-font-lock)
  12. (require 'fuel-base)
  13. (require 'fuel-table)
  14. (require 'button)
  15. ;;; Customization:
  16. (fuel-font-lock--defface fuel-font-lock-markup-title
  17. 'bold fuel-help "article titles in help buffers")
  18. (fuel-font-lock--defface fuel-font-lock-markup-heading
  19. 'bold fuel-help "headlines in help buffers")
  20. (fuel-font-lock--defface fuel-font-lock-markup-link
  21. 'link fuel-help "links to topics in help buffers")
  22. (fuel-font-lock--defface fuel-font-lock-markup-emphasis
  23. 'italic fuel-help "emphasized words in help buffers")
  24. (fuel-font-lock--defface fuel-font-lock-markup-strong
  25. 'link fuel-help "bold words in help buffers")
  26. ;;; Links:
  27. (make-variable-buffer-local
  28. (defvar fuel-markup--follow-link-function 'fuel-markup--echo-link))
  29. (define-button-type 'fuel-markup--button
  30. 'action 'fuel-markup--follow-link
  31. 'face 'fuel-font-lock-markup-link
  32. 'follow-link t)
  33. (defun fuel-markup--follow-link (button)
  34. (when fuel-markup--follow-link-function
  35. (funcall fuel-markup--follow-link-function
  36. (button-get button 'markup-link)
  37. (button-get button 'markup-label)
  38. (button-get button 'markup-link-type))))
  39. (defun fuel-markup--echo-link (link label type)
  40. (message "Link %s pointing to %s named %s" label type link))
  41. (defun fuel-markup--insert-button (label link type)
  42. (let ((label (format "%s" label))
  43. (link (if (listp link) link (format "%s" link))))
  44. (insert-text-button label
  45. :type 'fuel-markup--button
  46. 'markup-link link
  47. 'markup-label label
  48. 'markup-link-type type
  49. 'help-echo (format "%s (%s)" label type))))
  50. (defun fuel-markup--article-title (name)
  51. (let ((name (if (listp name) (cons :seq name) name)))
  52. (fuel-eval--retort-result
  53. (fuel-eval--send/wait `(:fuel* ((,name fuel-get-article-title)) "fuel")))))
  54. (defun fuel-markup--link-at-point ()
  55. (let ((button (condition-case nil (forward-button 0) (error nil))))
  56. (when button
  57. (list (button-get button 'markup-link)
  58. (button-get button 'markup-label)
  59. (button-get button 'markup-link-type)))))
  60. ;;; Markup printers:
  61. (defconst fuel-markup--printers
  62. '(($all-tags . fuel-markup--all-tags)
  63. ($all-authors . fuel-markup--all-authors)
  64. ($author . fuel-markup--author)
  65. ($authors . fuel-markup--authors)
  66. ($class-description . fuel-markup--class-description)
  67. ($code . fuel-markup--code)
  68. ($command . fuel-markup--command)
  69. ($command-map . fuel-markup--null)
  70. ($contract . fuel-markup--contract)
  71. ($curious . fuel-markup--curious)
  72. ($definition . fuel-markup--definition)
  73. ($describe-vocab . fuel-markup--describe-vocab)
  74. ($description . fuel-markup--description)
  75. ($doc-path . fuel-markup--doc-path)
  76. ($emphasis . fuel-markup--emphasis)
  77. ($error-description . fuel-markup--error-description)
  78. ($errors . fuel-markup--errors)
  79. ($example . fuel-markup--example)
  80. ($examples . fuel-markup--examples)
  81. ($heading . fuel-markup--heading)
  82. ($index . fuel-markup--index)
  83. ($instance . fuel-markup--instance)
  84. ($io-error . fuel-markup--io-error)
  85. ($link . fuel-markup--link)
  86. ($links . fuel-markup--links)
  87. ($list . fuel-markup--list)
  88. ($low-level-note . fuel-markup--low-level-note)
  89. ($markup-example . fuel-markup--markup-example)
  90. ($maybe . fuel-markup--maybe)
  91. ($methods . fuel-markup--methods)
  92. ($nl . fuel-markup--newline)
  93. ($notes . fuel-markup--notes)
  94. ($operation . fuel-markup--link)
  95. ($or . fuel-markup--or)
  96. ($parsing-note . fuel-markup--parsing-note)
  97. ($predicate . fuel-markup--predicate)
  98. ($prettyprinting-note . fuel-markup--prettyprinting-note)
  99. ($quotation . fuel-markup--quotation)
  100. ($references . fuel-markup--references)
  101. ($related . fuel-markup--related)
  102. ($see . fuel-markup--see)
  103. ($see-also . fuel-markup--see-also)
  104. ($shuffle . fuel-markup--shuffle)
  105. ($side-effects . fuel-markup--side-effects)
  106. ($slot . fuel-markup--snippet)
  107. ($snippet . fuel-markup--snippet)
  108. ($strong . fuel-markup--strong)
  109. ($subheading . fuel-markup--subheading)
  110. ($subsection . fuel-markup--subsection)
  111. ($subsections . fuel-markup--subsections)
  112. ($synopsis . fuel-markup--synopsis)
  113. ($syntax . fuel-markup--syntax)
  114. ($table . fuel-markup--table)
  115. ($tag . fuel-markup--tag)
  116. ($tags . fuel-markup--tags)
  117. ($unchecked-example . fuel-markup--example)
  118. ($value . fuel-markup--value)
  119. ($values . fuel-markup--values)
  120. ($values-x/y . fuel-markup--values-x/y)
  121. ($var-description . fuel-markup--var-description)
  122. ($vocab-link . fuel-markup--vocab-link)
  123. ($vocab-links . fuel-markup--vocab-links)
  124. ($vocab-subsection . fuel-markup--vocab-subsection)
  125. ($vocabulary . fuel-markup--vocabulary)
  126. ($warning . fuel-markup--warning)
  127. (article . fuel-markup--article)
  128. (describe-words . fuel-markup--describe-words)
  129. (vocab-list . fuel-markup--vocab-list)))
  130. (make-variable-buffer-local
  131. (defvar fuel-markup--maybe-nl nil))
  132. (defun fuel-markup--print (e)
  133. (cond ((null e) (insert "f"))
  134. ((stringp e) (fuel-markup--insert-string e))
  135. ((and (listp e) (symbolp (car e))
  136. (assoc (car e) fuel-markup--printers))
  137. (funcall (cdr (assoc (car e) fuel-markup--printers)) e))
  138. ((and (symbolp e)
  139. (assoc e fuel-markup--printers))
  140. (funcall (cdr (assoc e fuel-markup--printers)) e))
  141. ((listp e) (mapc 'fuel-markup--print e))
  142. ((symbolp e) (fuel-markup--print (list '$link e)))
  143. (t (insert (format "\n%S\n" e)))))
  144. (defun fuel-markup--print-str (e)
  145. (with-temp-buffer
  146. (fuel-markup--print e)
  147. (buffer-string)))
  148. (defun fuel-markup--maybe-nl ()
  149. (setq fuel-markup--maybe-nl (point)))
  150. (defun fuel-markup--insert-newline (&optional justification nosqueeze)
  151. (fill-region (save-excursion (beginning-of-line) (point))
  152. (point)
  153. (or justification 'left)
  154. nosqueeze)
  155. (newline))
  156. (defsubst fuel-markup--insert-nl-if-nb (&optional no-fill)
  157. (unless (eq (save-excursion (beginning-of-line) (point)) (point))
  158. (if no-fill (newline) (fuel-markup--insert-newline))))
  159. (defsubst fuel-markup--put-face (txt face)
  160. (put-text-property 0 (length txt) 'font-lock-face face txt)
  161. txt)
  162. (defun fuel-markup--insert-heading (txt &optional no-nl)
  163. (fuel-markup--insert-nl-if-nb)
  164. (delete-blank-lines)
  165. (unless (bobp) (newline))
  166. (fuel-markup--put-face txt 'fuel-font-lock-markup-heading)
  167. (fuel-markup--insert-string txt)
  168. (unless no-nl (newline)))
  169. (defun fuel-markup--insert-string (str)
  170. (when fuel-markup--maybe-nl
  171. (newline 2)
  172. (setq fuel-markup--maybe-nl nil))
  173. (insert str))
  174. (defun fuel-markup--article (e)
  175. (setq fuel-markup--maybe-nl nil)
  176. (insert (fuel-markup--put-face (cadr e) 'fuel-font-lock-markup-title))
  177. (newline 2)
  178. (fuel-markup--print (car (cddr e))))
  179. (defun fuel-markup--heading (e)
  180. (fuel-markup--insert-heading (cadr e)))
  181. (defun fuel-markup--subheading (e)
  182. (fuel-markup--insert-heading (cadr e)))
  183. (defun fuel-markup--subsection (e)
  184. (fuel-markup--insert-nl-if-nb)
  185. (insert " - ")
  186. (fuel-markup--link (cons '$link (cdr e)))
  187. (fuel-markup--maybe-nl))
  188. (defun fuel-markup--subsections (e)
  189. (dolist (link (cdr e))
  190. (fuel-markup--insert-nl-if-nb)
  191. (insert " - ")
  192. (fuel-markup--link (list '$link link))
  193. (fuel-markup--maybe-nl)))
  194. (defun fuel-markup--vocab-subsection (e)
  195. (fuel-markup--insert-nl-if-nb)
  196. (insert " - ")
  197. (fuel-markup--vocab-link (cons '$vocab-link (cdr e)))
  198. (fuel-markup--maybe-nl))
  199. (defun fuel-markup--newline (e)
  200. (fuel-markup--insert-newline)
  201. (newline))
  202. (defun fuel-markup--doc-path (e)
  203. (fuel-markup--insert-heading "Related topics")
  204. (insert " ")
  205. (dolist (art (cdr e))
  206. (fuel-markup--insert-button (car art) (cadr art) 'article)
  207. (insert ", "))
  208. (delete-backward-char 2)
  209. (fuel-markup--insert-newline 'left))
  210. (defun fuel-markup--emphasis (e)
  211. (when (stringp (cadr e))
  212. (fuel-markup--put-face (cadr e) 'fuel-font-lock-markup-emphasis)
  213. (insert (cadr e))))
  214. (defun fuel-markup--strong (e)
  215. (when (stringp (cadr e))
  216. (fuel-markup--put-face (cadr e) 'fuel-font-lock-markup-strong)
  217. (insert (cadr e))))
  218. (defun fuel-markup--snippet (e)
  219. (insert (mapconcat '(lambda (s)
  220. (if (stringp s)
  221. (fuel-font-lock--factor-str s)
  222. (fuel-markup--print-str s)))
  223. (cdr e)
  224. " ")))
  225. (defun fuel-markup--code (e)
  226. (fuel-markup--insert-nl-if-nb)
  227. (newline)
  228. (dolist (snip (cdr e))
  229. (if (stringp snip)
  230. (insert (fuel-font-lock--factor-str snip))
  231. (fuel-markup--print snip))
  232. (newline))
  233. (newline))
  234. (defun fuel-markup--command (e)
  235. (fuel-markup--snippet (list '$snippet (nth 3 e))))
  236. (defun fuel-markup--syntax (e)
  237. (fuel-markup--insert-heading "Syntax")
  238. (fuel-markup--print (cons '$code (cdr e)))
  239. (newline))
  240. (defun fuel-markup--example (e)
  241. (fuel-markup--insert-newline)
  242. (dolist (s (cdr e))
  243. (fuel-markup--snippet (list '$snippet s))
  244. (newline))
  245. (newline))
  246. (defun fuel-markup--markup-example (e)
  247. (fuel-markup--insert-newline)
  248. (fuel-markup--snippet (cons '$snippet (cdr e))))
  249. (defun fuel-markup--link (e)
  250. (let* ((link (or (nth 1 e) 'f))
  251. (type (or (nth 3 e) (if (symbolp link) 'word 'article)))
  252. (label (or (nth 2 e)
  253. (and (eq type 'article)
  254. (fuel-markup--article-title link))
  255. link)))
  256. (fuel-markup--insert-button label link type)))
  257. (defun fuel-markup--links (e)
  258. (dolist (link (cdr e))
  259. (fuel-markup--link (list '$link link))
  260. (insert ", "))
  261. (delete-backward-char 2))
  262. (defun fuel-markup--index-quotation (q)
  263. (cond ((null q) null)
  264. ((listp q) (vconcat (mapcar 'fuel-markup--index-quotation q)))
  265. (t q)))
  266. (defun fuel-markup--index (e)
  267. (let* ((q (fuel-markup--index-quotation (cadr e)))
  268. (cmd `(:fuel* ((,q fuel-index)) "fuel"
  269. ("builtins" "help" "help.topics" "classes"
  270. "classes.builtin" "classes.tuple"
  271. "classes.singleton" "classes.union"
  272. "classes.intersection" "classes.predicate")))
  273. (subs (fuel-eval--retort-result (fuel-eval--send/wait cmd 200))))
  274. (when subs
  275. (let ((start (point))
  276. (sort-fold-case nil))
  277. (fuel-markup--print subs)
  278. (sort-lines nil start (point))))))
  279. (defun fuel-markup--vocab-link (e)
  280. (fuel-markup--insert-button (cadr e) (or (car (cddr e)) (cadr e)) 'vocab))
  281. (defun fuel-markup--vocab-links (e)
  282. (dolist (link (cdr e))
  283. (insert " ")
  284. (fuel-markup--vocab-link (list '$vocab-link link))
  285. (insert " ")))
  286. (defun fuel-markup--vocab-list (e)
  287. (let ((rows (mapcar '(lambda (elem)
  288. (list (list '$vocab-link (car elem))
  289. (cadr elem)))
  290. (cdr e))))
  291. (fuel-markup--table (cons '$table rows))))
  292. (defun fuel-markup--describe-vocab (e)
  293. (fuel-markup--insert-nl-if-nb)
  294. (let* ((cmd `(:fuel* ((,(cadr e) fuel-vocab-help)) "fuel" t))
  295. (res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
  296. (when res (fuel-markup--print res))))
  297. (defun fuel-markup--vocabulary (e)
  298. (fuel-markup--insert-heading "Vocabulary: " t)
  299. (fuel-markup--vocab-link (cons '$vocab-link (cdr e)))
  300. (newline))
  301. (defun fuel-markup--parse-classes ()
  302. (let ((elems))
  303. (while (looking-at ".+ classes$")
  304. (let ((heading `($heading ,(match-string-no-properties 0)))
  305. (rows))
  306. (forward-line)
  307. (when (looking-at "Class *.+$")
  308. (push (split-string (match-string-no-properties 0) nil t) rows)
  309. (forward-line))
  310. (while (not (looking-at "$"))
  311. (let* ((objs (split-string (thing-at-point 'line) nil t))
  312. (class (list '$link (car objs) (car objs) 'word))
  313. (super (and (cadr objs)
  314. (list (list '$link (cadr objs) (cadr objs) 'word))))
  315. (slots (when (cddr objs)
  316. (list (mapcar '(lambda (s) (list s " ")) (cddr objs))))))
  317. (push `(,class ,@super ,@slots) rows))
  318. (forward-line))
  319. (push `(,heading ($table ,@(reverse rows))) elems))
  320. (forward-line))
  321. (reverse elems)))
  322. (defun fuel-markup--parse-words ()
  323. (let ((elems))
  324. (while (looking-at ".+ words\\|Primitives$")
  325. (let ((heading `($heading ,(match-string-no-properties 0)))
  326. (rows))
  327. (forward-line)
  328. (when (looking-at "Word *\\(Stack effect\\|Syntax\\)$")
  329. (push (list "Word" (match-string-no-properties 1)) rows)
  330. (forward-line))
  331. (while (looking-at " ?\\(.+?\\)\\( +\\(.+\\)\\)?$")
  332. (let ((word `($link ,(match-string-no-properties 1)
  333. ,(match-string-no-properties 1)
  334. word))
  335. (se (and (match-string-no-properties 3)
  336. `(($snippet ,(match-string-no-properties 3))))))
  337. (push `(,word ,@se) rows))
  338. (forward-line))
  339. (push `(,heading ($table ,@(reverse rows))) elems))
  340. (forward-line))
  341. (reverse elems)))
  342. (defun fuel-markup--parse-words-desc (desc)
  343. (with-temp-buffer
  344. (insert desc)
  345. (goto-char (point-min))
  346. (when (re-search-forward "^Words$" nil t)
  347. (forward-line 2)
  348. (let ((elems '(($heading "Words"))))
  349. (push (fuel-markup--parse-classes) elems)
  350. (push (fuel-markup--parse-words) elems)
  351. (reverse elems)))))
  352. (defun fuel-markup--describe-words (e)
  353. (when (cadr e)
  354. (fuel-markup--print (fuel-markup--parse-words-desc (cadr e)))))
  355. (defun fuel-markup--tag (e)
  356. (fuel-markup--link (list '$link (cadr e) (cadr e) 'tag)))
  357. (defun fuel-markup--tags (e)
  358. (when (cdr e)
  359. (fuel-markup--insert-heading "Tags: " t)
  360. (dolist (tag (cdr e))
  361. (fuel-markup--tag (list '$tag tag))
  362. (insert ", "))
  363. (delete-backward-char 2)
  364. (fuel-markup--insert-newline)))
  365. (defun fuel-markup--all-tags (e)
  366. (let* ((cmd `(:fuel* (all-tags :get) "fuel" t))
  367. (tags (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
  368. (fuel-markup--list
  369. (cons '$list (mapcar (lambda (tag) (list '$link tag tag 'tag)) tags)))))
  370. (defun fuel-markup--author (e)
  371. (fuel-markup--link (list '$link (cadr e) (cadr e) 'author)))
  372. (defun fuel-markup--authors (e)
  373. (when (cdr e)
  374. (fuel-markup--insert-heading "Authors: " t)
  375. (dolist (a (cdr e))
  376. (fuel-markup--author (list '$author a))
  377. (insert ", "))
  378. (delete-backward-char 2)
  379. (fuel-markup--insert-newline)))
  380. (defun fuel-markup--all-authors (e)
  381. (let* ((cmd `(:fuel* (all-authors :get) "fuel" t))
  382. (authors (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
  383. (fuel-markup--list
  384. (cons '$list (mapcar (lambda (a) (list '$link a a 'author)) authors)))))
  385. (defun fuel-markup--list (e)
  386. (fuel-markup--insert-nl-if-nb)
  387. (dolist (elt (cdr e))
  388. (insert " - ")
  389. (fuel-markup--print elt)
  390. (fuel-markup--insert-newline)))
  391. (defun fuel-markup--table (e)
  392. (fuel-markup--insert-newline)
  393. (delete-blank-lines)
  394. (newline)
  395. (fuel-table--insert
  396. (mapcar '(lambda (row) (mapcar 'fuel-markup--print-str row)) (cdr e)))
  397. (newline))
  398. (defun fuel-markup--instance (e)
  399. (insert " an instance of ")
  400. (fuel-markup--print (cadr e)))
  401. (defun fuel-markup--maybe (e)
  402. (fuel-markup--instance (cons '$instance (cdr e)))
  403. (insert " or f "))
  404. (defun fuel-markup--or (e)
  405. (let ((fst (car (cdr e)))
  406. (mid (butlast (cddr e)))
  407. (lst (car (last (cdr e)))))
  408. (insert (format "%s" fst))
  409. (dolist (m mid) (insert (format ", %s" m)))
  410. (insert (format " or %s" lst))))
  411. (defun fuel-markup--values (e)
  412. (fuel-markup--insert-heading "Inputs and outputs")
  413. (dolist (val (cdr e))
  414. (insert " " (car val) " - ")
  415. (fuel-markup--print (cdr val))
  416. (newline)))
  417. (defun fuel-markup--predicate (e)
  418. (fuel-markup--values '($values ("object" object) ("?" "a boolean")))
  419. (let ((word (make-symbol (substring (format "%s" (cadr e)) 0 -1))))
  420. (fuel-markup--description
  421. `($description "Tests if the object is an instance of the "
  422. ($link ,word) " class."))))
  423. (defun fuel-markup--side-effects (e)
  424. (fuel-markup--insert-heading "Side effects")
  425. (insert "Modifies ")
  426. (fuel-markup--print (cdr e))
  427. (fuel-markup--insert-newline))
  428. (defun fuel-markup--definition (e)
  429. (fuel-markup--insert-heading "Definition")
  430. (fuel-markup--code (cons '$code (cdr e))))
  431. (defun fuel-markup--methods (e)
  432. (fuel-markup--insert-heading "Methods")
  433. (fuel-markup--code (cons '$code (cdr e))))
  434. (defun fuel-markup--value (e)
  435. (fuel-markup--insert-heading "Variable value")
  436. (insert "Current value in global namespace: ")
  437. (fuel-markup--snippet (cons '$snippet (cdr e)))
  438. (newline))
  439. (defun fuel-markup--values-x/y (e)
  440. (fuel-markup--values '($values ("x" "number") ("y" "number"))))
  441. (defun fuel-markup--curious (e)
  442. (fuel-markup--insert-heading "For the curious...")
  443. (fuel-markup--print (cdr e)))
  444. (defun fuel-markup--references (e)
  445. (fuel-markup--insert-heading "References")
  446. (dolist (ref (cdr e))
  447. (if (listp ref)
  448. (fuel-markup--print ref)
  449. (fuel-markup--subsection (list '$subsection ref)))))
  450. (defun fuel-markup--see-also (e)
  451. (fuel-markup--insert-heading "See also")
  452. (fuel-markup--links (cons '$links (cdr e))))
  453. (defun fuel-markup--related (e)
  454. (fuel-markup--insert-heading "See also")
  455. (fuel-markup--links (cons '$links (cadr e))))
  456. (defun fuel-markup--shuffle (e)
  457. (insert "\nShuffle word. Re-arranges the stack "
  458. "according to the stack effect pattern.")
  459. (fuel-markup--insert-newline))
  460. (defun fuel-markup--low-level-note (e)
  461. (fuel-markup--print '($notes "Calling this word directly is not necessary "
  462. "in most cases. "
  463. "Higher-level words call it automatically.")))
  464. (defun fuel-markup--parsing-note (e)
  465. (fuel-markup--insert-nl-if-nb)
  466. (insert "This word should only be called from parsing words.")
  467. (fuel-markup--insert-newline))
  468. (defun fuel-markup--io-error (e)
  469. (fuel-markup--errors '($errors "Throws an error if the I/O operation fails.")))
  470. (defun fuel-markup--prettyprinting-note (e)
  471. (fuel-markup--print '($notes ("This word should only be called within the "
  472. ($link with-pprint) " combinator."))))
  473. (defun fuel-markup--elem-with-heading (elem heading)
  474. (fuel-markup--insert-heading heading)
  475. (fuel-markup--print (cdr elem))
  476. (fuel-markup--insert-newline))
  477. (defun fuel-markup--quotation (e)
  478. (insert "a ")
  479. (fuel-markup--link (list '$link 'quotation 'quotation 'word))
  480. (insert " with stack effect ")
  481. (fuel-markup--snippet (list '$snippet (nth 1 e))))
  482. (defun fuel-markup--warning (e)
  483. (fuel-markup--elem-with-heading e "Warning"))
  484. (defun fuel-markup--description (e)
  485. (fuel-markup--elem-with-heading e "Word description"))
  486. (defun fuel-markup--class-description (e)
  487. (fuel-markup--elem-with-heading e "Class description"))
  488. (defun fuel-markup--error-description (e)
  489. (fuel-markup--elem-with-heading e "Error description"))
  490. (defun fuel-markup--var-description (e)
  491. (fuel-markup--elem-with-heading e "Variable description"))
  492. (defun fuel-markup--contract (e)
  493. (fuel-markup--elem-with-heading e "Generic word contract"))
  494. (defun fuel-markup--errors (e)
  495. (fuel-markup--elem-with-heading e "Errors"))
  496. (defun fuel-markup--examples (e)
  497. (fuel-markup--elem-with-heading e "Examples"))
  498. (defun fuel-markup--notes (e)
  499. (fuel-markup--elem-with-heading e "Notes"))
  500. (defun fuel-markup--word-info (e s)
  501. (let* ((word (nth 1 e))
  502. (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) ,s) "fuel")))
  503. (ret (and cmd (fuel-eval--send/wait cmd)))
  504. (res (and (not (fuel-eval--retort-error ret))
  505. (fuel-eval--retort-output ret))))
  506. (if res
  507. (fuel-markup--code (list '$code res))
  508. (fuel-markup--snippet (list '$snippet " " word)))))
  509. (defun fuel-markup--see (e)
  510. (fuel-markup--word-info e 'see))
  511. (defun fuel-markup--synopsis (e)
  512. (fuel-markup--word-info e 'synopsis))
  513. (defun fuel-markup--null (e))
  514. (provide 'fuel-markup)
  515. ;;; fuel-markup.el ends here