[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 5a08c82adb 111/153: Improve word movement comma
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 5a08c82adb 111/153: Improve word movement commands inside symbols. |
Date: |
Sat, 29 Jan 2022 08:02:23 -0500 (EST) |
branch: elpa/forth-mode
commit 5a08c82adb7de711c530a63dcac269cd6b593341
Author: Helmut Eller <helmut@msibook>
Commit: Helmut Eller <eller.helmut@gmail.com>
Improve word movement commands inside symbols.
In particular keep "symbol" and "word" distinct so that
M-DEL etc. works like in other modes.
* forth-syntax.el (forth-syntax--set-word-syntax): New helper.
(forth-syntax--state-normal, forth-syntax--state-parsing-word): Use it.
---
forth-syntax.el | 19 +++++++++++++++++--
test/tests.el | 9 +++------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/forth-syntax.el b/forth-syntax.el
index 39133fd6d5..4c6e02a25b 100644
--- a/forth-syntax.el
+++ b/forth-syntax.el
@@ -27,6 +27,21 @@
SYNTAX must be a valid argument for `string-to-syntax'."
`(put-text-property ,start ,end 'syntax-table ',(string-to-syntax syntax)))
+;; Set the syntax in the region START/END to "word" or "symbol". Do
+;; nothing for characters that already have the correct syntax so that
+;; word movement commands work "naturally".
+(defun forth-syntax--set-word-syntax (start end)
+ (save-excursion
+ (goto-char start)
+ (while (progn
+ (skip-syntax-forward "w_" end)
+ (cond ((< (point) end)
+ (let ((start (point)))
+ (skip-syntax-forward "^w_" end)
+ (forth-syntax--set-syntax start (point) "_")
+ t))
+ (t nil))))))
+
;;; State functions
@@ -77,7 +92,7 @@ SYNTAX must be a valid argument for `string-to-syntax'."
(skip-chars-forward forth-syntax--non-whitespace)
(cond ((= start (point)) #'forth-syntax--state-eob)
(t
- (forth-syntax--set-syntax start (point) "w")
+ (forth-syntax--set-word-syntax start (point))
#'forth-syntax--state-normal))))
(defun forth-syntax--parse-comment (backward-regexp forward-regexp)
@@ -143,7 +158,7 @@ SYNTAX must be a valid argument for `string-to-syntax'."
(skip-chars-forward forth-syntax--non-whitespace)
(cond ((= start (point)) #'forth-syntax--state-eob)
(t
- (forth-syntax--set-syntax start (point) "w")
+ (forth-syntax--set-word-syntax start (point))
(let ((word (buffer-substring-no-properties start (point))))
(cond ((forth-syntax--lookup word))
(t
diff --git a/test/tests.el b/test/tests.el
index 5b3ce27302..3822334861 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -191,11 +191,8 @@ The whitespace before and including \"|\" on each line is
removed."
(forth-assert-forward-sexp " :noname foo bar ; \ x" 2 19)
(forth-assert-forward-sexp " if drop exit else 1+ then bar " 2 27))
-;; IDEA 1: in words like foo-bar give the "-" a "word constituent"
-;; syntax so that word movement works like in Lisp mode (which
-;; everybody is used to :-).
-;;
-;; IDEA 2: give the filename in "include filename" string syntax.
+;; IDEA: give the filename in "include filename" string syntax.
(ert-deftest forth-word-movements ()
(forth-assert-forward-word "include /tmp/foo.fth \ bar" 1 8)
- (forth-assert-forward-word "include /tmp/foo.fth \ bar" 8 21))
+ (forth-assert-forward-word "include /tmp/foo.fth \ bar" 8 13)
+ (forth-assert-forward-word "foo-bar" 1 4))
- [nongnu] elpa/forth-mode 9812d1decd 114/153: Use /interperter to setup terminal personalty, (continued)
- [nongnu] elpa/forth-mode 9812d1decd 114/153: Use /interperter to setup terminal personalty, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5aa3a700b0 016/153: Improve killing an interactive Forth session., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2869bc25e4 085/153: Create a terminal personality for SwiftForth., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 8d1d8ea795 099/153: Re-add test for 'syntax-propertize-function., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 55de74bb4f 033/153: Query Forth session about defined words., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 44dd013096 059/153: Remove terminal escape sequences from strings returned from Forth., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 399fd00921 055/153: Fix killing interactive Forth., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 56bbc06a16 079/153: Error out if byte compilation fails in Emacs 23., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 531c9e11e2 023/153: Add autoload cookie to extension configuration, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 847481f866 061/153: Tweak window handling., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5a08c82adb 111/153: Improve word movement commands inside symbols.,
ELPA Syncer <=
- [nongnu] elpa/forth-mode 50a7eb4bf1 094/153: Handle indentation of : and with smie instead of syntax-table., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 45f3f20f18 104/153: Make indentation case-insensitive, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b8024ac331 088/153: Loading a Forth file provides some feedback., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9eb3550cdc 045/153: Add imenu items to autocomplete candidates., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 350638bb0c 106/153: Make indentation case-insensitive, ELPA Syncer, 2022/01/29
- [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