[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 3fa933d556 123/153: Test comment-region
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 3fa933d556 123/153: Test comment-region |
Date: |
Sat, 29 Jan 2022 08:02:25 -0500 (EST) |
branch: elpa/forth-mode
commit 3fa933d556d7b09f5940af9b66724581b4ce6acd
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>
Test comment-region
* forth-mode.el (forth-comment-region): New. Use \ for commenting
regions. ( also worked, but it seems nicer to \ for "block comments"
and ( ) for stack comments.
(forth-mode-syntax-table): Change syntax table again so that comments
work a bit better in Emacs23.
(forth-mode): Setup comment-region-function.
Also fix comment-start-skip. (Allthough it's not clear why
we need to set this at all.)
* test/tests.el (forth-comment-dwim): Add tests with active region.
(forth-should-region-before/after): New helper.
(forth-paren-comment-font-lock): Fixing comment-start-skip changed
the faces back again.
* forth-syntax.el (forth-syntax--parse-comment): Use "!" (i.e. generic
comment) here so that the syntax table can use "<" and ">".
---
forth-mode.el | 16 +++++++++++-----
forth-syntax.el | 4 ++--
test/tests.el | 45 +++++++++++++++++++++++++++++++++++++++++----
3 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/forth-mode.el b/forth-mode.el
index 82e98f2035..0799f96b79 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -40,9 +40,9 @@
(defvar forth-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?\\ "<" table)
- (modify-syntax-entry ?\n " " table)
- (modify-syntax-entry ?\( "!" table)
- (modify-syntax-entry ?\) "_" table)
+ (modify-syntax-entry ?\n ">" table)
+ (modify-syntax-entry ?\( "<1b" table)
+ (modify-syntax-entry ?\) ">4b" table)
(modify-syntax-entry ?* "_23n" table)
(modify-syntax-entry ?\{ "_" table)
(modify-syntax-entry ?\} "_" table)
@@ -112,10 +112,15 @@
(defun forth-fill-paragraph (&rest args)
(let ((fill-paragraph-function nil)
(fill-paragraph-handle-comment t)
- (comment-start "\ ")
+ (comment-start "\\ ")
(comment-end ""))
(apply #'fill-paragraph args)))
+(defun forth-comment-region (&rest args)
+ (let ((comment-start "\\ ")
+ (comment-end ""))
+ (apply #'comment-region-default args)))
+
(defun forth-beginning-of-defun (arg)
(and (re-search-backward "^\\s *: \\_<" nil t (or arg 1))
(beginning-of-line)))
@@ -141,9 +146,10 @@
(forth-smie-setup)
(setq-local fill-paragraph-function #'forth-fill-paragraph)
(setq-local beginning-of-defun-function #'forth-beginning-of-defun)
- (setq-local comment-start-skip "\\(?:(\\*\\|\\\\\\) *")
+ (setq-local comment-start-skip "\\(?:([*]?\\|\\\\\\) *")
(setq-local comment-start "(")
(setq-local comment-end ")")
+ (setq-local comment-region-function #'forth-comment-region)
(setq imenu-generic-expression
'(("Words"
"^\\s-*\\(:\\|code\\|defer\\)\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 2)
diff --git a/forth-syntax.el b/forth-syntax.el
index d88068ec93..f77ca819dc 100644
--- a/forth-syntax.el
+++ b/forth-syntax.el
@@ -139,10 +139,10 @@ SYNTAX must be a valid argument for `string-to-syntax'."
(defun forth-syntax--parse-comment (backward-regexp forward-regexp)
(let ((pos (point)))
(re-search-backward backward-regexp)
- (forth-syntax--set-syntax (point) (1+ (point)) "<")
+ (forth-syntax--set-syntax (point) (1+ (point)) "!")
(goto-char pos)
(cond ((re-search-forward forward-regexp nil t)
- (forth-syntax--set-syntax (1- (point)) (point) ">")
+ (forth-syntax--set-syntax (1- (point)) (point) "!")
#'forth-syntax--state-normal)
(t
(goto-char (point-max))
diff --git a/test/tests.el b/test/tests.el
index 0b6015e7da..db6b49638e 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -88,13 +88,24 @@ The whitespace before and including \"|\" on each line is
removed."
(should (string= after (substring-no-properties (buffer-string))))
(should (= (point) point-after))))))
+(defun forth-should-region-before/after (before after fun)
+ (destructuring-bind (before start1 end1) (forth-strip-|-and-¹² before)
+ (destructuring-bind (after point-after) (forth-strip-|-and-→ after)
+ (forth-with-temp-buffer before
+ (set-mark start1)
+ (goto-char end1)
+ (activate-mark)
+ (funcall fun)
+ (should (string= after (substring-no-properties (buffer-string))))
+ (should (= (point) point-after))))))
+
(ert-deftest forth-paren-comment-font-lock ()
- (forth-assert-face "→( )" font-lock-comment-face)
+ (forth-assert-face "→( )" font-lock-comment-delimiter-face)
(forth-assert-face "→.( )" font-lock-comment-face)
(forth-assert-face "( →)" font-lock-comment-delimiter-face)
- (forth-assert-face " →( )" font-lock-comment-face)
- (forth-assert-face "\t→( )" font-lock-comment-face)
- (forth-assert-face "→(\t)" font-lock-comment-face)
+ (forth-assert-face " →( )" font-lock-comment-delimiter-face)
+ (forth-assert-face "\t→( )" font-lock-comment-delimiter-face)
+ (forth-assert-face "→(\t)" font-lock-comment-delimiter-face)
(forth-assert-face "(fo→o) " nil)
(forth-assert-face "(fo→o)" nil)
(forth-assert-face "(→) " nil)
@@ -279,5 +290,31 @@ The whitespace before and including \"|\" on each line is
removed."
| begin ( x y )
| swap (→)
| again ;"
+ (lambda ()
+ (call-interactively #'comment-dwim)))
+ (forth-should-region-before/after
+ "²: frob
+ | begin ( x y )
+ | swap
+ | again ;
+ |¹"
+ "→\\ : frob
+ |\\ begin ( x y )
+ |\\ swap
+ |\\ again ;
+ |"
+ (lambda ()
+ (call-interactively #'comment-dwim)))
+ (forth-should-region-before/after
+ "¹\\ : frob
+ |\\ begin ( x y )
+ |\\ swap
+ |\\ again ;
+ |²"
+ ": frob
+ | begin ( x y )
+ | swap
+ | again ;
+ |→"
(lambda ()
(call-interactively #'comment-dwim))))
- [nongnu] elpa/forth-mode ccb14b4a47 136/153: Indentation rule for :noname, (continued)
- [nongnu] elpa/forth-mode ccb14b4a47 136/153: Indentation rule for :noname, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d711fd5200 130/153: Remove tabs in wercker.yml, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode dd450e6a01 120/153: Remove debugging code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b3c1e62e5a 151/153: The Emacs 25 package can't coexist with Emacs-snapshot., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 157c14b18e 092/153: Include tab (\t) as whitespace delimiter for comments., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 93c90ebf97 129/153: Install gforth in wercker, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode eaeac02b6d 082/153: Disable warning about cl., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 3ef42c825a 101/153: Emacs 23: indenting doesn't work well., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9440f2a5af 121/153: Add test for comment-dwim, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 66f7a2dc97 060/153: Add tests for various Forth block and non-block files., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 3fa933d556 123/153: Test comment-region,
ELPA Syncer <=
- [nongnu] elpa/forth-mode 17e58ab993 102/153: Test with Emacs snapshot., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 885407ebc5 047/153: Automated build., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9f9b5cdf86 089/153: Don't send output as input, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2e65a80a3b 110/153: Fontify buffer before testing word movement commands., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode f44fa6481f 152/153: Forth 200x core.html is no longer there., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5502816e37 134/153: Make it easier to emulate Open Firmware indentation style, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5076a08abc 057/153: Make C-c C-k work in all Forth modes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 7cbb60f1d7 143/153: Highlight +field and friends, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5c1c928490 132/153: Make completion case insensitive, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 37da497572 144/153: Switch back from interaction mode to source buffer., ELPA Syncer, 2022/01/29