emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 910a7b30dfd: Fix beginning/end-of-defun with tree-sitter


From: Eli Zaretskii
Subject: emacs-29 910a7b30dfd: Fix beginning/end-of-defun with tree-sitter
Date: Sun, 7 May 2023 02:13:19 -0400 (EDT)

branch: emacs-29
commit 910a7b30dfd185eda78caf48e6f634a6a6e086f1
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix beginning/end-of-defun with tree-sitter
    
    * lisp/treesit.el (treesit-beginning-of-defun)
    (treesit-end-of-defun): Push mark, as other beginning/end-of-defun
    functions do.
---
 lisp/treesit.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 1d4749c8cd2..147b052d287 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -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.
 



reply via email to

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