[PATCH] Treat top-level forms as outline headings
Export this patch
Fennel mode users can use the Outline minor mode to cycle between seeing
(1) all content and
(2) section titles as per the ';;;;' comments.
With this patch, they can cycle further to see
(3) section titles *along with* the first line of
the top-level forms within each section.
The change is inspired by the built-in Emacs Lisp mode.
Good idea.
Unfortunately there seems to be an issue with the tests when I run them
here, both on 28.2 and the latest build from git.
---
fennel-mode.el | 2 + -
test/fennel-mode-test.el | 77 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/fennel-mode.el b/fennel-mode.el
index 8c47694..76cfde8 100644
--- a/fennel-mode.el
+++ b/fennel-mode.el
@@ -348,7 +348,7 @@ ENDP and DELIM."
(setq-local normal-auto-fill-function #'do-auto-fill)
(setq-local open-paren-in-column-0-is-defun-start nil)
(setq-local outline-level 'lisp-outline-level)
- (setq-local outline-regexp ";;;;* ")
+ (setq-local outline-regexp ";;;;* [^ \t\n]\\|(")
(setq-local paragraph-ignore-fill-prefix t)
(setq-local parse-sexp-ignore-comments t)
(setq-local inferior-lisp-program fennel-program)
diff --git a/test/fennel-mode-test.el b/test/fennel-mode-test.el
index be229fc..1ed4f35 100644
--- a/test/fennel-mode-test.el
+++ b/test/fennel-mode-test.el
@@ -151,3 +151,80 @@
(should (indent-region (point-min) (point-max)))
(should (equal (string-trim expected)
(string-trim (buffer-substring-no-properties (point-min) (point-max)))))))))
+
+ (ert-deftest fennel-mode-outline-level-1-test ()
+ (with-temp-buffer
+ (insert "
+ ;;; Heading A
+
+ (local x 1)
+
+ (fn f []
+ (and 1 ; Any long body.
+ 2
+ 3
+ 4
+ 5))
+
+ ;;; Heading B
+
+ (local y 1)
+
+ (fn g []
+ (and 1 ; Any long body.
+ 2
+ 3
+ 4
+ 5))")
+ (fennel-mode)
+ (outline-cycle-buffer)
+ (outline-headers-as-kill (point-min) (point-max))
+ (should (equal (current-kill 0)
+ ";;; Heading A
+
+ ;;; Heading B
+
+ "))))
+
+ (ert-deftest fennel-mode-outline-level-2-test ()
+ (with-temp-buffer
+ (insert "
+ ;;; Heading A
+
+ (local x 1)
+
+ (fn f []
+ (and 1 ; Any long body.
+ 2
+ 3
+ 4
+ 5))
+
+ ;;; Heading B
+
+ (local y 1)
+
+ (fn g []
+ (and 1 ; Any long body.
+ 2
+ 3
+ 4
+ 5))")
+ (fennel-mode)
+ (outline-cycle-buffer)
+ (outline-cycle-buffer)
+ (outline-headers-as-kill (point-min) (point-max))
+ (should (equal (current-kill 0)
+ ";;; Heading A
+
+ (local x 1)
+
+ (fn f []
+
+ ;;; Heading B
+
+ (local y 1)
+
+ (fn g []
+
+ "))))
--
2.44.0
Rudolf Adamkovič <rudolf@adamkovic.org> writes:
Any idea what could cause that?
-Phil