From 1eed7e7f5b86e5456aa6de313189ed93877e1dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Tue, 4 Jul 2017 18:08:26 +0200 Subject: [PATCH] FUEL: indenting the code examples in fuel looks cool --- misc/fuel/fuel-help.el | 5 ----- misc/fuel/fuel-markup.el | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el index 7dc628d701..de653c7182 100644 --- a/misc/fuel/fuel-help.el +++ b/misc/fuel/fuel-help.el @@ -26,7 +26,6 @@ (require 'button) - ;;; Customization: ;;;###autoload @@ -49,7 +48,6 @@ :type 'list :group 'fuel-help) - ;;; 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)) - ;;; 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))))) - ;;; 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)) - (provide 'fuel-help) ;;; fuel-help.el ends here diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 088ce11273..be2e1c4c55 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -106,7 +106,7 @@ ($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) @@ -118,7 +118,7 @@ ($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) @@ -160,7 +160,7 @@ ($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) @@ -303,10 +303,11 @@ (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)) @@ -321,13 +322,6 @@ (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)