[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 1bc27cd6b6 115/153: Support paragraph filling i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 1bc27cd6b6 115/153: Support paragraph filling in comments |
Date: |
Sat, 29 Jan 2022 08:02:24 -0500 (EST) |
branch: elpa/forth-mode
commit 1bc27cd6b68cbd76c785eee10f64dc969237cdb0
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>
Support paragraph filling in comments
* forth-mode.el (forth-fill-paragraph): New.
(forth-mode): Initialize fill-paragraph-function.
* test/tests.el (forth-fill-comment): New test.
(forth-strip-|-and-↓, forth-should-before/after): New helpers.
---
forth-mode.el | 10 ++++++++++
test/tests.el | 26 ++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/forth-mode.el b/forth-mode.el
index deff50e903..b546837caa 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -110,6 +110,15 @@
(or (forth-block-with-newlines-p)
(forth-block-without-newlines-p))))
+;; This just calls the standard `fill-paragraph' with adjusted
+;; paramaters.
+(defun forth-fill-paragraph (&rest args)
+ (let ((fill-paragraph-function nil)
+ (fill-paragraph-handle-comment t)
+ (comment-start "\ ")
+ (comment-end ""))
+ (apply #'fill-paragraph args)))
+
(unless (fboundp 'prog-mode)
(defalias 'prog-mode 'fundamental-mode))
@@ -129,6 +138,7 @@
(setq-local syntax-propertize-function #'forth-syntax-propertize))
(setq-local parse-sexp-lookup-properties t)
(forth-smie-setup)
+ (setq-local fill-paragraph-function #'forth-fill-paragraph)
(setq ;; font-lock-defaults
comment-start-skip "\\((\\*?\\|\\\\\\) *"
comment-start "("
diff --git a/test/tests.el b/test/tests.el
index 1bf7e55805..7026be1faa 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -63,6 +63,24 @@ The whitespace before and including \"|\" on each line is
removed."
(forward-word)
(should (= (point) end))))
+(defun forth-strip-|-and-↓ (string)
+ (let* ((s2 (forth-strip-| string))
+ (pos (string-match "↓" s2)))
+ (cons (delete ?↓ s2) pos)))
+
+(defun forth-should-before/after (before after fun)
+ (let* ((before+point (forth-strip-|-and-↓ before))
+ (before (car before+point))
+ (point-before (cdr before+point))
+ (after+point (forth-strip-|-and-↓ after))
+ (after (car after+point))
+ (point-after (cdr after+point)))
+ (forth-with-temp-buffer before
+ (goto-char point-before)
+ (funcall fun)
+ (should (string= after (substring-no-properties (buffer-string))))
+ (should (= (point) point-after)))))
+
(ert-deftest forth-paren-comment-font-lock ()
(forth-assert-face "( )" 1 font-lock-comment-delimiter-face)
(forth-assert-face ".( )" 1 font-lock-comment-face)
@@ -211,3 +229,11 @@ The whitespace before and including \"|\" on each line is
removed."
(equal (forth-spec--build-url "SWAP" 2012)
"http://www.forth200x.org/documents/html/core.html#core:SWAP")))
+(ert-deftest forth-fill-comment ()
+ (forth-should-before/after
+ "\\ foo bar
+ |\\ baz↓
+ |: frob ( x y -- z ) ;"
+ "\\ foo bar baz↓
+ |: frob ( x y -- z ) ;"
+ #'fill-paragraph))
- [nongnu] elpa/forth-mode d09313f19c 035/153: Add forth-eval-region., (continued)
- [nongnu] elpa/forth-mode d09313f19c 035/153: Add forth-eval-region., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 89b9904ceb 119/153: Add some tests for font-lock faces, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d47662b187 037/153: Add some installation and usage instrutions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1cb3071930 117/153: Move the font-locking for defining words to forth-syntax.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 21033fc700 031/153: Improve sending commands to an interactive Forth session., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1c05a009a3 080/153: Fix warning about speedbar-add-supported-extension., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode ef60dcd180 036/153: If forth-executable is nil, query user for file name., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b29a929b78 028/153: Add provide forms., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 992bfb64b4 103/153: Fix warning about font-lock-fontify-buffer non-interactive use., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode efa1f0a336 046/153: Build Emacs Lisp files., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1bc27cd6b6 115/153: Support paragraph filling in comments,
ELPA Syncer <=
- [nongnu] elpa/forth-mode 4868a0ff03 051/153: Fix for imenu integration., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5b42dfac0c 105/153: Merge branch 'master' into case-insensitive-indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode c8103312c3 041/153: Fix typo., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b83ff1274b 054/153: Type C-c C-s to SEE a word., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2f5d87f3c5 126/153: No 64-bit build for pForth in Ubuntu. Try Gforth., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2813a7bf3d 090/153: Introduce a hook to initialize backends, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode c64035c209 073/153: Add backends for Forth implementations., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d1498037a2 107/153: Add simple tests for forward-sexp, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 83a62c82c4 030/153: Move all package metadata to forth-mode.el., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 186bae4853 083/153: Fix set-process-window-size parameter order., ELPA Syncer, 2022/01/29