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

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

[nongnu] elpa/clojure-ts-mode 07d9cf75f8 126/210: Make `beginning-of-def


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-ts-mode 07d9cf75f8 126/210: Make `beginning-of-defun` aware of clojure comment form
Date: Thu, 31 Oct 2024 18:59:49 -0400 (EDT)

branch: elpa/clojure-ts-mode
commit 07d9cf75f828e2f07862b4fce6b50af3ab604dab
Author: dan sutton <danielsutton01@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Make `beginning-of-defun` aware of clojure comment form
    
    Remove seq-find usage
    
    Move initialization of beginning-of-defun-function to correct spot
    
    Use new function name in tests
    
    Docstring for checkdoc
---
 clojure-mode-sexp-test.el | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/clojure-mode-sexp-test.el b/clojure-mode-sexp-test.el
index f8c555b84a..1faf1039b4 100644
--- a/clojure-mode-sexp-test.el
+++ b/clojure-mode-sexp-test.el
@@ -22,6 +22,51 @@
 (require 'clojure-mode)
 (require 'ert)
 
+(defmacro clojure-buffer-with-text (text &rest body)
+  "Run body in a temporary clojure buffer with TEXT.
+TEXT is a string with a | indicating where point is. The | will be erased
+and point left there."
+  (declare (indent 2))
+  `(progn
+     (with-temp-buffer
+       (erase-buffer)
+       (clojure-mode)
+       (insert ,text)
+       (goto-char (point-min))
+       (re-search-forward "|")
+       (delete-char -1)
+       ,@body)))
+
+(ert-deftest test-clojure-top-level-form-p ()
+  (clojure-buffer-with-text
+      "(comment
+         (wrong)
+         (rig|ht)
+         (wrong))"
+      ;; make this use the native beginning of defun since this is used to
+      ;; determine whether to use the comment aware version or not.
+      (should (let ((beginning-of-defun-function nil))
+                (clojure-top-level-form-p "comment")))))
+
+(ert-deftest test-clojure-beginning-of-defun-function ()
+  (clojure-buffer-with-text
+      "(comment
+          (wrong)
+          (wrong)
+          (rig|ht)
+          (wrong))"
+      (beginning-of-defun)
+    (should (looking-at-p "(comment")))
+  (clojure-buffer-with-text
+      "(comment
+          (wrong)
+          (wrong)
+          (rig|ht)
+          (wrong))"
+      (let ((clojure-toplevel-inside-comment-form t))
+       (beginning-of-defun))
+    (should (looking-at-p "(right)"))))
+
 (ert-deftest test-sexp-with-commas ()
   (with-temp-buffer
     (insert "[], {}, :a, 2")



reply via email to

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