[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 0d22cedbaf 133/153: Improve indentation of BEGI
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 0d22cedbaf 133/153: Improve indentation of BEGIN-STRUCTURE/END-STRUCTURE |
Date: |
Sat, 29 Jan 2022 08:02:26 -0500 (EST) |
branch: elpa/forth-mode
commit 0d22cedbaf2530386eeb5faff8feef6a7a25ee82
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>
Improve indentation of BEGIN-STRUCTURE/END-STRUCTURE
* forth-smie.el (forth-smie--indentation-rules): More
sophisticated/complicated rule for begin-structure.
* test/tests.el (forth-indent-structure): New test.
* forth-syntax.el (forth-syntax--font-lock-keywords): Include
begin-structure/end-structure.
---
forth-smie.el | 15 +++++++++++++--
forth-syntax.el | 3 ++-
test/tests.el | 7 +++++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/forth-smie.el b/forth-smie.el
index ea4a634ae5..d242ec8035 100644
--- a/forth-smie.el
+++ b/forth-smie.el
@@ -31,8 +31,19 @@
(defun forth-smie--indentation-rules (kind token)
(pcase (cons kind token)
(`(:elem . basic) forth-smie--basic-indent)
- (`(:elem . args) 0)
- (`(:list-intro . ,_) forth-smie--basic-indent)
+ (`(:elem . args)
+ (cond ((smie-rule-prev-p "begin-structure")
+ (- (+ (save-excursion
+ (forth-smie--backward-token)
+ (current-column))
+ forth-smie--basic-indent)
+ (current-column)))
+ (t 0)))
+ (`(:after . "begin-structure")
+ (* 2 forth-smie--basic-indent))
+ (`(:list-intro . "begin-structure")
+ nil)
+ (`(:list-intro . ,_) t)
(_ nil)))
(defun forth-smie--forward-token ()
diff --git a/forth-syntax.el b/forth-syntax.el
index 11f4156d8e..e2b23aec43 100644
--- a/forth-syntax.el
+++ b/forth-syntax.el
@@ -203,7 +203,8 @@ SYNTAX must be a valid argument for `string-to-syntax'."
"case" "of" "endof" "endcase"
":noname" ";" "does>" "immediate"
"is" "to"
- "literal" "2literal" "fliteral" "sliteral"))
+ "literal" "2literal" "fliteral" "sliteral"
+ "begin-structure" "end-structure"))
(dolist (w forth-syntax--parsing-words)
(forth-syntax--define w #'forth-syntax--state-parsing-word))
diff --git a/test/tests.el b/test/tests.el
index 0b747201e7..cb9331b068 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -265,6 +265,13 @@ The whitespace before and including \"|\" on each line is
removed."
": foo
| (foo) ;"))
+(ert-deftest forth-indent-structure ()
+ (forth-should-indent
+ "BEGIN-STRUCTURE point
+ | 1 CELLS +FIELD p.x
+ | 1 CELLS +FIELD p.y
+ |END-STRUCTURE"))
+
(ert-deftest forth-sexp-movements ()
(forth-assert-forward-sexp " ¹: foo bar ;² \ x")
(forth-assert-forward-sexp " ¹:noname foo bar ;² \ x")
- [nongnu] elpa/forth-mode 5076a08abc 057/153: Make C-c C-k work in all Forth modes., (continued)
- [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
- [nongnu] elpa/forth-mode 05e8a02796 139/153: Highlight LEAVE, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1f922f41f4 138/153: Declare forth-smie-basic-indent as safe local-variable., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 74c0e17c45 122/153: Improve beginning-of-defun, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b40ffb3127 078/153: Fix building with Emacs 23., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1d85344467 113/153: Add commands to browse description in Forth standards, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode c5e63e29f1 072/153: Basic indentation of control structures, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 0d22cedbaf 133/153: Improve indentation of BEGIN-STRUCTURE/END-STRUCTURE,
ELPA Syncer <=
- [nongnu] elpa/forth-mode 47f33ea62a 063/153: Move interaction functions to forth-interactive-mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 6fac263222 068/153: Automatic build with Wercker., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9cf3d777ec 064/153: Fix for C-c C-s forth-see., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d90c4a46e0 118/153: Use funny characters (→, ¹ and ²) to mark positions in test strings., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode c99ed046df 074/153: Remove debug message., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 64209f501c 108/153: Merge pull request #35 from ellerh/forward-sexp-tests, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode e6ee5ddf99 069/153: Handle ( ...) comments with syntax-propertize-function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode e966275c2e 100/153: Add tests for indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode dc3f7fabed 131/153: Use -y with apt-get., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode f531a1bcd7 096/153: Print test name in ERT shim., ELPA Syncer, 2022/01/29