From 3d348c46e78b09493265620c96afeafad747a96e Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 15 Dec 2022 21:23:20 -0800 Subject: [PATCH] ; Handle nil ARG in treesit-beginning/end-of-defun * lisp/treesit.el (treesit-beginning-of-defun) (treesit-end-of-defun): Handle nil ARG. --- lisp/treesit.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 74476f18619..a5eda436c89 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1635,7 +1635,8 @@ 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") - (when-let ((dest (treesit--navigate-defun (point) (- arg) 'beg))) + (when-let* ((arg (or arg 1)) + (dest (treesit--navigate-defun (point) (- arg) 'beg))) (goto-char dest) (when treesit-defun-skipper (funcall treesit-defun-skipper)) @@ -1651,7 +1652,8 @@ This is a tree-sitter equivalent of `end-of-defun'. Behavior of this function depends on `treesit-defun-type-regexp' and `treesit-defun-skipper'." (interactive "^p\nd") - (when-let ((dest (treesit--navigate-defun (point) arg 'end))) + (when-let* ((arg (or arg 1)) + (dest (treesit--navigate-defun (point) arg 'end))) (goto-char dest) (when treesit-defun-skipper (funcall treesit-defun-skipper)))) -- 2.39.2