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

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

[elpa] externals/csharp-mode 1c2b9cb 442/459: Add more nodes to beginnin


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 1c2b9cb 442/459: Add more nodes to beginning/end-of-defun
Date: Sun, 22 Aug 2021 14:00:18 -0400 (EDT)

branch: externals/csharp-mode
commit 1c2b9cb51b6ecc8bf52d3f040b6c02639310a153
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Theodor Thornhill <theo@thornhill.no>

    Add more nodes to beginning/end-of-defun
    
    I did not yet extract that list of declarations into a customizable 
variable,
    but I think that is a reasonable thing to do at some point.
    
    Not completely sure how this should behave.  Now tree-sitter defines things 
as a
    tree (obviously...), so we need to be able to jump to siblings as well.
    Add more nodes to beginning/end-of-defun
    
    I did not yet extract that list of declarations into a customizable 
variable,
    but I think that is a reasonable thing to do at some point.
    
    Not completely sure how this should behave.  Now tree-sitter defines things 
as a
    tree (obviously...), so we need to be able to jump to siblings as well.
---
 csharp-tree-sitter.el | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/csharp-tree-sitter.el b/csharp-tree-sitter.el
index 3518f8d..976519f 100644
--- a/csharp-tree-sitter.el
+++ b/csharp-tree-sitter.el
@@ -26,6 +26,7 @@
 
 ;;; Code:
 (require 'cl-lib)
+(require 'cl-extra)
 (require 'seq)
 
 (require 'tree-sitter)
@@ -317,14 +318,26 @@
 (defun csharp-beginning-of-defun ()
   "Replacement-function for `beginning-of-defun' for 
`csharp-tree-sitter-mode'."
   (interactive)
-  (when-let ((method (tree-sitter-node-at-point 'method_declaration)))
-    (goto-char (tsc-node-start-position method))))
+  (when-let ((declaration
+              (cl-some (lambda (decl)
+                         (tree-sitter-node-at-point decl))
+                       '(method_declaration
+                         constructor_declaration
+                         class_declaration
+                         namespace_declaration))))
+    (goto-char (tsc-node-start-position declaration))))
 
 (defun csharp-end-of-defun ()
   "Replacement-function for `end-of-defun' for `csharp-tree-sitter-mode'."
   (interactive)
-  (when-let ((method (tree-sitter-node-at-point 'method_declaration)))
-    (goto-char (tsc-node-end-position method))))
+  (when-let ((declaration
+              (cl-some (lambda (decl)
+                         (tree-sitter-node-at-point decl))
+                       '(method_declaration
+                         constructor_declaration
+                         class_declaration
+                         namespace_declaration))))
+    (goto-char (tsc-node-end-position declaration))))
 
 (defun csharp-delete-method-at-point ()
   "Deletes the method at point."



reply via email to

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