FUEL: indenting the code examples in fuel looks cool

modern-harvey2
Björn Lindqvist 2017-07-04 18:08:26 +02:00
parent 2ffb7a2669
commit 1eed7e7f5b
2 changed files with 8 additions and 19 deletions

View File

@ -26,7 +26,6 @@
(require 'button) (require 'button)
;;; Customization: ;;; Customization:
;;;###autoload ;;;###autoload
@ -49,7 +48,6 @@
:type 'list :type 'list
:group 'fuel-help) :group 'fuel-help)
;;; Help browser history: ;;; Help browser history:
(defun fuel-help--make-history () (defun fuel-help--make-history ()
@ -343,7 +341,6 @@ With prefix, the current page is deleted from history."
-- --
("Switch to listener" "\C-c\C-z" run-factor)) ("Switch to listener" "\C-c\C-z" run-factor))
;;; IN: support ;;; IN: support
(defun fuel-help--find-in-buffer-link () (defun fuel-help--find-in-buffer-link ()
@ -359,7 +356,6 @@ With prefix, the current page is deleted from history."
(re-search-forward "Vocabulary: \\(.+\\)$" nil t) (re-search-forward "Vocabulary: \\(.+\\)$" nil t)
(match-string-no-properties 1))))) (match-string-no-properties 1)))))
;;; Help mode definition: ;;; Help mode definition:
;;;###autoload ;;;###autoload
@ -370,6 +366,5 @@ With prefix, the current page is deleted from history."
(setq factor-current-vocab-function 'fuel-help--find-in) (setq factor-current-vocab-function 'fuel-help--find-in)
(setq fuel-markup--follow-link-function 'fuel-help--follow-link)) (setq fuel-markup--follow-link-function 'fuel-help--follow-link))
(provide 'fuel-help) (provide 'fuel-help)
;;; fuel-help.el ends here ;;; fuel-help.el ends here

View File

@ -106,7 +106,7 @@
($author . fuel-markup--author) ($author . fuel-markup--author)
($authors . fuel-markup--authors) ($authors . fuel-markup--authors)
($class-description . fuel-markup--class-description) ($class-description . fuel-markup--class-description)
($code . fuel-markup--code) ($code . (lambda (e) (fuel-markup--code e t)))
($command . fuel-markup--command) ($command . fuel-markup--command)
($command-map . fuel-markup--null) ($command-map . fuel-markup--null)
($complex-shuffle . fuel-markup--complex-shuffle) ($complex-shuffle . fuel-markup--complex-shuffle)
@ -118,7 +118,7 @@
($emphasis . fuel-markup--emphasis) ($emphasis . fuel-markup--emphasis)
($error-description . fuel-markup--error-description) ($error-description . fuel-markup--error-description)
($errors . fuel-markup--errors) ($errors . fuel-markup--errors)
($example . fuel-markup--example) ($example . (lambda (e) (fuel-markup--code e t)))
($examples . fuel-markup--examples) ($examples . fuel-markup--examples)
($fuel-nav-crumbs . fuel-markup--nav-crumbs) ($fuel-nav-crumbs . fuel-markup--nav-crumbs)
($heading . fuel-markup--heading) ($heading . fuel-markup--heading)
@ -160,7 +160,7 @@
($table . fuel-markup--table) ($table . fuel-markup--table)
($tag . fuel-markup--tag) ($tag . fuel-markup--tag)
($tags . fuel-markup--tags) ($tags . fuel-markup--tags)
($unchecked-example . fuel-markup--example) ($unchecked-example . (lambda (e) (fuel-markup--code e t)))
($url . fuel-markup--url) ($url . fuel-markup--url)
($value . fuel-markup--value) ($value . fuel-markup--value)
($values . fuel-markup--values) ($values . fuel-markup--values)
@ -303,10 +303,11 @@
(cdr e) (cdr e)
" "))) " ")))
(defun fuel-markup--code (e) (defun fuel-markup--code (e indent)
(fuel-markup--insert-nl-if-nb) (fuel-markup--insert-nl-if-nb)
(newline) (newline)
(dolist (snip (cdr e)) (dolist (snip (cdr e))
(when indent (insert " "))
(if (stringp snip) (if (stringp snip)
(insert (factor-font-lock-string snip)) (insert (factor-font-lock-string snip))
(fuel-markup--print snip)) (fuel-markup--print snip))
@ -321,13 +322,6 @@
(fuel-markup--print (cons '$code (cdr e))) (fuel-markup--print (cons '$code (cdr e)))
(newline)) (newline))
(defun fuel-markup--example (e)
(fuel-markup--insert-newline)
(dolist (s (cdr e))
(fuel-markup--snippet (list '$snippet s))
(newline))
(newline))
(defun fuel-markup--markup-example (e) (defun fuel-markup--markup-example (e)
(fuel-markup--insert-newline) (fuel-markup--insert-newline)
(fuel-markup--snippet (cons '$snippet (cdr e)))) (fuel-markup--snippet (cons '$snippet (cdr e))))
@ -563,11 +557,11 @@ the 'words.' word emits."
(defun fuel-markup--definition (e) (defun fuel-markup--definition (e)
(fuel-markup--insert-heading "Definition") (fuel-markup--insert-heading "Definition")
(fuel-markup--code (cons '$code (cdr e)))) (fuel-markup--code (cons '$code (cdr e)) nil))
(defun fuel-markup--methods (e) (defun fuel-markup--methods (e)
(fuel-markup--insert-heading "Methods") (fuel-markup--insert-heading "Methods")
(fuel-markup--code (cons '$code (cdr e)))) (fuel-markup--code (cons '$code (cdr e)) nil))
(defun fuel-markup--value (e) (defun fuel-markup--value (e)
(fuel-markup--insert-heading "Variable value") (fuel-markup--insert-heading "Variable value")
@ -675,7 +669,7 @@ the 'words.' word emits."
(res (and (not (fuel-eval--retort-error ret)) (res (and (not (fuel-eval--retort-error ret))
(fuel-eval--retort-output ret)))) (fuel-eval--retort-output ret))))
(if res (if res
(fuel-markup--code (list '$code res)) (fuel-markup--code (list '$code res) nil)
(fuel-markup--snippet (list '$snippet " " word))))) (fuel-markup--snippet (list '$snippet " " word)))))
(defun fuel-markup--see (e) (defun fuel-markup--see (e)