emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/forth-mode f3d76c12c1 125/153: Test completion-at-point


From: ELPA Syncer
Subject: [nongnu] elpa/forth-mode f3d76c12c1 125/153: Test completion-at-point
Date: Sat, 29 Jan 2022 08:02:25 -0500 (EST)

branch: elpa/forth-mode
commit f3d76c12c180f98b5cbb73aba0f93bc8d04c9f04
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>

    Test completion-at-point
    
    .travis.yml: Install pforth   Using pForth as that is less likely
    to create conflicts with gforth.el.
    
    * test/tests.el (forth-completion-at-point): New test.
    (forth-with-pforth): New helper.
    
    * forth-mode.el (forth-symbol-start, forth-symbol-end): Don't break
    at beginning/end of buffer.
    
    (forth-interaction-sentinel): Can't use comint-output-filter with
    killed processes.
    
    * forth-syntax.el (forth-syntax-whitespace): Renamed from
      forth-syntax--whitespace
    (forth-syntax-non-whitespace): Idem.
---
 .travis.yml               |  2 +-
 forth-interaction-mode.el |  6 +++++-
 forth-mode.el             |  8 ++++----
 forth-syntax.el           |  8 ++++----
 test/tests.el             | 23 +++++++++++++++++++++++
 5 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 955735c36f..9337a8837b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@ env:
 install:
   - sudo add-apt-repository -y ppa:ubuntu-elisp
   - sudo apt-get update -y
-  - sudo apt-get install emacs23 emacs24 emacs-snapshot
+  - sudo apt-get install emacs23 emacs24 emacs-snapshot pforth
 script: make EMACS=$EMACS
 notifications:
   email: lars@nocrew.org
diff --git a/forth-interaction-mode.el b/forth-interaction-mode.el
index 1368e1c96c..9c5373d258 100644
--- a/forth-interaction-mode.el
+++ b/forth-interaction-mode.el
@@ -59,7 +59,11 @@
 
 (defun forth-interaction-sentinel (proc arg)
   (message "Forth: %s" arg)
-  (comint-output-filter proc (format "\nForth: %s\n" arg)))
+  ;;FIXME: Can't do this because it calls process-mark, which
+  ;; errors out in killed processes.  Still, would be nice to see
+  ;; something in the *forth* buffer.
+  ;;(comint-output-filter proc (format "\nForth: %s\n" arg))
+  )
 
 (defvar forth-executable nil)
 
diff --git a/forth-mode.el b/forth-mode.el
index 9b014c54e1..11e02e18ab 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -65,13 +65,13 @@
 
 (defun forth-symbol-start ()
   (save-excursion
-    (re-search-backward "[^[:graph:]]")
-    (1+ (point))))
+    (skip-chars-backward forth-syntax-non-whitespace)
+    (point)))
 
 (defun forth-symbol-end ()
   (save-excursion
-    (re-search-forward "[^[:graph:]]")
-    (1- (point))))
+    (skip-chars-forward forth-syntax-non-whitespace)
+    (point)))
 
 (defun forth-word-at-point ()
   (buffer-substring (forth-symbol-start) (forth-symbol-end)))
diff --git a/forth-syntax.el b/forth-syntax.el
index f77ca819dc..11f4156d8e 100644
--- a/forth-syntax.el
+++ b/forth-syntax.el
@@ -8,15 +8,15 @@
 
 ;;; Helpers
 
-(defvar forth-syntax--whitespace " \t\n\f\r")
-(defvar forth-syntax--non-whitespace (concat "^" forth-syntax--whitespace))
+(defvar forth-syntax-whitespace " \t\n\f\r")
+(defvar forth-syntax-non-whitespace (concat "^" forth-syntax-whitespace))
 
 ;; Skip forward over whitespace and the following word. Return the
 ;; start position of the word.
 (defun forth-syntax--skip-word ()
-  (skip-chars-forward forth-syntax--whitespace)
+  (skip-chars-forward forth-syntax-whitespace)
   (let ((start (point)))
-    (skip-chars-forward forth-syntax--non-whitespace)
+    (skip-chars-forward forth-syntax-non-whitespace)
     start))
 
 ;; Return the whitespace-delimited word at position POS.
diff --git a/test/tests.el b/test/tests.el
index b954667bcd..0f8bb26427 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -88,6 +88,7 @@ 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)
@@ -99,6 +100,21 @@ The whitespace before and including \"|\" on each line is 
removed."
        (should (string= after (substring-no-properties (buffer-string))))
        (should (= (point) point-after))))))
 
+(defmacro forth-with-gforth (&rest body)
+  (declare (indent 0))
+  `(let* ((proc (get-buffer-process forth-interaction-buffer)))
+     ;; FIXME: there should be a better way to do this. Probably a
+     ;; callback function.
+     (while (not (processp proc))
+       (run-forth)
+       (message "Waiting for pforth to start ...")
+       (accept-process-output nil 0.3)
+       (setq proc (get-buffer-process forth-interaction-buffer)))
+     (unwind-protect
+        (progn . ,body)
+        (kill-process proc))))
+>>>>>>> Test completion-at-point
+
 (ert-deftest forth-paren-comment-font-lock ()
   (forth-assert-face "→( )" font-lock-comment-delimiter-face)
   (forth-assert-face "→.( )" font-lock-comment-face)
@@ -327,3 +343,10 @@ The whitespace before and including \"|\" on each line is 
removed."
    |→"
    (lambda ()
      (call-interactively #'comment-dwim))))
+
+(ert-deftest forth-completion-at-point ()
+  (forth-with-forth
+    (forth-should-before/after
+     "2C→"
+     "2Constant→"
+     #'completion-at-point)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]