From: Yuan Fu Date: Fri, 16 Dec 2022 05:23:20 +0000 (-0800) Subject: ; Handle nil ARG in treesit-beginning/end-of-defun X-Git-Tag: emacs-29.0.90~1114 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3d348c46e78;p=emacs.git ; Handle nil ARG in treesit-beginning/end-of-defun * lisp/treesit.el (treesit-beginning-of-defun) (treesit-end-of-defun): Handle nil ARG. --- 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))))