]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix beginning/end-of-defun with tree-sitter
authorEli Zaretskii <eliz@gnu.org>
Sun, 7 May 2023 06:13:10 +0000 (09:13 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 7 May 2023 06:13:10 +0000 (09:13 +0300)
* lisp/treesit.el (treesit-beginning-of-defun)
(treesit-end-of-defun): Push mark, as other beginning/end-of-defun
functions do.

lisp/treesit.el

index 1d4749c8cd223e9a0f511f762cf27338368f15f9..147b052d2871117118613a08d8213f3b82c24453 100644 (file)
@@ -1862,6 +1862,10 @@ This is a tree-sitter equivalent of `beginning-of-defun'.
 Behavior of this function depends on `treesit-defun-type-regexp'
 and `treesit-defun-skipper'."
   (interactive "^p")
+  (or (not (eq this-command 'treesit-beginning-of-defun))
+      (eq last-command 'treesit-beginning-of-defun)
+      (and transient-mark-mode mark-active)
+      (push-mark))
   (let ((orig-point (point))
         (success nil))
     (catch 'done
@@ -1892,6 +1896,10 @@ this function depends on `treesit-defun-type-regexp' and
   (interactive "^p\nd")
   (let ((orig-point (point)))
     (if (or (null arg) (= arg 0)) (setq arg 1))
+    (or (not (eq this-command 'treesit-end-of-defun))
+        (eq last-command 'treesit-end-of-defun)
+        (and transient-mark-mode mark-active)
+        (push-mark))
     (catch 'done
       (dotimes (_ 2) ; Not making progress is better than infloop.