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

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

[nongnu] elpa/idris-mode d08fd3ec78 14/14: Merge pull request #569 from


From: ELPA Syncer
Subject: [nongnu] elpa/idris-mode d08fd3ec78 14/14: Merge pull request #569 from keram/idris2-mode-issues-16
Date: Thu, 1 Dec 2022 08:02:55 -0500 (EST)

branch: elpa/idris-mode
commit d08fd3ec78a09bc0e6c5b1effdef563de08bdaf6
Merge: 0093e0b42c f3a032c194
Author: Jan de Muijnck-Hughes <jfdm@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #569 from keram/idris2-mode-issues-16
    
    Consider `-` as operator in `idris-thing-at-point`
---
 idris-commands.el       |  9 ++++++---
 idris-tests.el          | 23 +++++++++++++++++++++++
 test-data/AddClause.idr |  6 ++++--
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/idris-commands.el b/idris-commands.el
index 3c122775e9..d8ae22a7b1 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -326,14 +326,17 @@ Idris process. This sets the load position to point, if 
there is one."
     (error "Cannot find file for current buffer")))
 
 
+(defun idris-operator-at-position-p (pos)
+  "Return t if syntax lookup is `.' or char after POS is `-'."
+  (or (equal (syntax-after pos) (string-to-syntax "."))
+      (eq (char-after pos) ?-)))
+
 (defun idris-thing-at-point ()
   "Return the line number and name at point as a cons.
 Use this in Idris source buffers."
   (let ((line (idris-get-line-num (point))))
     (cons
-     (if (equal (syntax-after (point))
-                (string-to-syntax "."))
-         ;; We're on an operator.
+     (if (idris-operator-at-position-p (point))
          (save-excursion
            (skip-syntax-backward ".")
            (let ((beg (point)))
diff --git a/idris-tests.el b/idris-tests.el
index bd4113896a..c841472604 100644
--- a/idris-tests.el
+++ b/idris-tests.el
@@ -177,5 +177,28 @@ remain."
       (kill-buffer buffer))
     (idris-quit)))
 
+(ert-deftest idris-test-idris-add-clause ()
+  "Test that `idris-add-clause' generates definition with hole."
+  (let ((buffer (find-file "test-data/AddClause.idr"))
+        (buffer-content (with-temp-buffer
+                          (insert-file-contents "AddClause.idr")
+                          (buffer-string))))
+    (with-current-buffer buffer
+      (goto-char (point-min))
+      (re-search-forward "test :")
+      (goto-char (match-beginning 0))
+      (funcall-interactively 'idris-add-clause nil)
+      (should (looking-at-p "test \\w+ = \\?test_rhs"))
+      (re-search-forward "(-) :")
+      (goto-char (1+ (match-beginning 0)))
+      (funcall-interactively 'idris-add-clause nil)
+      (should (looking-at-p "(-) = \\?\\w+_rhs"))
+      ;; Cleanup
+      (erase-buffer)
+      (insert buffer-content)
+      (save-buffer)
+      (kill-buffer)))
+  (idris-quit))
+
 (provide 'idris-tests)
 ;;; idris-tests.el ends here
diff --git a/test-data/AddClause.idr b/test-data/AddClause.idr
index b66d65fbf3..afbb7465f0 100644
--- a/test-data/AddClause.idr
+++ b/test-data/AddClause.idr
@@ -4,6 +4,8 @@ data Test = A | B
 
 --++++++++++++++++
 test : Test -> Int
-test x = ?test_rhs
-
 
+-- Regression test for:
+-- idris-add-clause doesn't send a message when cursor is on a dash
+-- https://github.com/idris-community/idris2-mode/issues/16
+(-) : Nat



reply via email to

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