]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: indenting the code examples in fuel looks cool
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 4 Jul 2017 16:08:26 +0000 (18:08 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 4 Jul 2017 16:08:26 +0000 (18:08 +0200)
misc/fuel/fuel-help.el
misc/fuel/fuel-markup.el

index 7dc628d701e787a60f5099c1dd56a3ef85e28ca7..de653c7182519d3d29415399725e74ad6220baa9 100644 (file)
@@ -26,7 +26,6 @@
 
 (require 'button)
 
-\f
 ;;; Customization:
 
 ;;;###autoload
@@ -49,7 +48,6 @@
   :type 'list
   :group 'fuel-help)
 
-\f
 ;;; Help browser 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))
 
-\f
 ;;; IN: support
 
 (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)
              (match-string-no-properties 1)))))
 
-\f
 ;;; Help mode definition:
 
 ;;;###autoload
@@ -370,6 +366,5 @@ With prefix, the current page is deleted from history."
   (setq factor-current-vocab-function 'fuel-help--find-in)
   (setq fuel-markup--follow-link-function 'fuel-help--follow-link))
 
-\f
 (provide 'fuel-help)
 ;;; fuel-help.el ends here
index 088ce1127395f0ceaf9e02164289456957a8893b..be2e1c4c55cfc2ac7f36ed6438e104ddb183d09f 100644 (file)
     ($author . fuel-markup--author)
     ($authors . fuel-markup--authors)
     ($class-description . fuel-markup--class-description)
-    ($code . fuel-markup--code)
+    ($code . (lambda (e) (fuel-markup--code e t)))
     ($command . fuel-markup--command)
     ($command-map . fuel-markup--null)
     ($complex-shuffle . fuel-markup--complex-shuffle)
     ($emphasis . fuel-markup--emphasis)
     ($error-description . fuel-markup--error-description)
     ($errors . fuel-markup--errors)
-    ($example . fuel-markup--example)
+    ($example . (lambda (e) (fuel-markup--code e t)))
     ($examples . fuel-markup--examples)
     ($fuel-nav-crumbs . fuel-markup--nav-crumbs)
     ($heading . fuel-markup--heading)
     ($table . fuel-markup--table)
     ($tag . fuel-markup--tag)
     ($tags . fuel-markup--tags)
-    ($unchecked-example . fuel-markup--example)
+    ($unchecked-example . (lambda (e) (fuel-markup--code e t)))
     ($url . fuel-markup--url)
     ($value . fuel-markup--value)
     ($values . fuel-markup--values)
                      (cdr e)
                      " ")))
 
-(defun fuel-markup--code (e)
+(defun fuel-markup--code (e indent)
   (fuel-markup--insert-nl-if-nb)
   (newline)
   (dolist (snip (cdr e))
+    (when indent (insert "    "))
     (if (stringp snip)
         (insert (factor-font-lock-string snip))
       (fuel-markup--print snip))
   (fuel-markup--print (cons '$code (cdr e)))
   (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)
   (fuel-markup--insert-newline)
   (fuel-markup--snippet (cons '$snippet (cdr e))))
@@ -563,11 +557,11 @@ the 'words.' word emits."
 
 (defun fuel-markup--definition (e)
   (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)
   (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)
   (fuel-markup--insert-heading "Variable value")
@@ -675,7 +669,7 @@ the 'words.' word emits."
          (res (and (not (fuel-eval--retort-error ret))
                    (fuel-eval--retort-output ret))))
     (if res
-        (fuel-markup--code (list '$code res))
+        (fuel-markup--code (list '$code res) nil)
       (fuel-markup--snippet (list '$snippet " " word)))))
 
 (defun fuel-markup--see (e)