[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 312f3860aa 124/153: Try to indent (foo)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 312f3860aa 124/153: Try to indent (foo) |
Date: |
Sat, 29 Jan 2022 08:02:25 -0500 (EST) |
branch: elpa/forth-mode
commit 312f3860aa84793bec30b3f5410b786ad3b45f2a
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>
Try to indent (foo)
This is a tricky case because SMIE thinks, depending on
`comment-start-skip` (which indirectly depends on `comment-start`
thru `comment-normalize-vars`), that (foo) is a comment. But since
(foo) is not actually a comment this leads to an endless recursion.
* forth-mode.el (comment-start-skip, comment-start): Choose them
so that SMIE doesn't run into the endless recursion. (Quite brittle.)
* test/tests.el (forth-indent-\(foo\)): New test.
(forth-backslash-comment-font-lock, forth-comment-dwim): Adjust for
new values of comment-start-skip.
* forth-smiel.el (forth-smie--indentation-rules): For clarity, make
default case explicit.
---
forth-mode.el | 6 +++---
forth-smie.el | 3 ++-
test/tests.el | 17 +++++++++++++----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/forth-mode.el b/forth-mode.el
index 0799f96b79..9b014c54e1 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -146,9 +146,9 @@
(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 "(")
- (setq-local comment-end ")")
+ (setq-local comment-start-skip "[(\\][ \t*]+")
+ (setq-local comment-start "( ")
+ (setq-local comment-end " )")
(setq-local comment-region-function #'forth-comment-region)
(setq imenu-generic-expression
'(("Words"
diff --git a/forth-smie.el b/forth-smie.el
index aa6b64a382..ea4a634ae5 100644
--- a/forth-smie.el
+++ b/forth-smie.el
@@ -32,7 +32,8 @@
(pcase (cons kind token)
(`(:elem . basic) forth-smie--basic-indent)
(`(:elem . args) 0)
- (`(:list-intro . ,_) forth-smie--basic-indent)))
+ (`(:list-intro . ,_) forth-smie--basic-indent)
+ (_ nil)))
(defun forth-smie--forward-token ()
(forward-comment (point-max))
diff --git a/test/tests.el b/test/tests.el
index db6b49638e..b954667bcd 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -114,12 +114,12 @@ The whitespace before and including \"|\" on each line is
removed."
→x y )" font-lock-comment-face))
(ert-deftest forth-backslash-comment-font-lock ()
- (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-delimiter-face)
+ (forth-assert-face " →\\" font-lock-comment-face)
(forth-assert-face "\t→\\ " font-lock-comment-delimiter-face)
(forth-assert-face " →\\\t" font-lock-comment-delimiter-face)
- (forth-assert-face " →\\\n" font-lock-comment-delimiter-face)
+ (forth-assert-face " →\\\n" font-lock-comment-face)
(forth-assert-face "a→\\b" nil)
(forth-assert-face "a→\\b " nil))
@@ -242,6 +242,15 @@ The whitespace before and including \"|\" on each line is
removed."
| drop exit
|endcase"))
+;; This is an tricky case because SMIE thinks, depending on
+;; `comment-start-skip` (which indirectly depends on `comment-start`
+;; thru `comment-normalize-vars`), that (foo) is a comment. But since
+;; (foo) is not actually a comment this leads to an endless recursion.
+(ert-deftest forth-indent-\(foo\) ()
+ (forth-should-indent
+ ": foo
+ | (foo) ;"))
+
(ert-deftest forth-sexp-movements ()
(forth-assert-forward-sexp " ¹: foo bar ;² \ x")
(forth-assert-forward-sexp " ¹:noname foo bar ;² \ x")
@@ -288,7 +297,7 @@ The whitespace before and including \"|\" on each line is
removed."
| again ;"
": frob
| begin ( x y )
- | swap (→)
+ | swap ( → )
| again ;"
(lambda ()
(call-interactively #'comment-dwim)))
- [nongnu] elpa/forth-mode 039bf122ee 067/153: Document key bindings in the manual., (continued)
- [nongnu] elpa/forth-mode 039bf122ee 067/153: Document key bindings in the manual., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1a05d27d82 077/153: Fix loading backend file., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b95f1b8a02 146/153: Fix typos in doc, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2e75fb156f 081/153: Fix warning about defvar ignored., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 96c20f03f5 128/153: Make completion-at-point test work with Emacs23, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 867922d61e 112/153: Handle string literals more correctly, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 16f359442e 109/153: Add tests for word movement commands, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 45650c28a2 140/153: Check if forth interactive buffer is live, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode ab790fdac8 091/153: Don't kill *forth* buffer when there's a fatal error., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode be0272be3a 076/153: Inhibut Gforth terminal attribute output., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 312f3860aa 124/153: Try to indent (foo),
ELPA Syncer <=
- [nongnu] elpa/forth-mode 952995d95e 098/153: Add tests for indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 0bbf7992d6 135/153: Workaround pcase bug in Emacs-24.3, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode ee0781f0a8 066/153: Add more functions for evaluating Forth expressions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1ffc174c13 127/153: Pass Makefile variable FORTH as environment variable to build.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9b0982e169 149/153: Fix CI, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 52d84393c0 141/153: Remove newlines to fix markdown formatting., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2d30ca8eaa 142/153: Use add-to-list in installation instructions instead of pushnew., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 8c0e519c57 148/153: Add restart-forth to source window menu, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5e99586c1e 065/153: Remove prompt from Forth output., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 6bc035fd90 040/153: Fix missing argument to define-key., ELPA Syncer, 2022/01/29