Subject: bug#66719: mark-defun doesn't like function literals / the need for treesit-mark-defun

From: Eli Zaretskii <[email-masked]>
Date: Tue, 24 Oct 2023 13:56:39 +0300

> From: Dominik Honnef <[email-masked]>
> Date: Mon, 23 Oct 2023 22:59:35 +0200
> 
> treesit.el currently defines treesit-beginning-of-defun and
> treesit-end-of-defun, and binds C-M-a and C-M-e to them in addition to
> setting beginning-of-defun-function and end-of-defun-function.
> 
> That way, C-M-a and C-M-e work well even for function literals, which do
> not necessarily start and end on their own, dedicated lines. This
> differs from beginning-of-defun, which always goes to the beginning
> of the line.
> 
> The problem is that there is no treesit-mark-defun, and mark-defun calls
> beginning-of-defun, via beginning-of-defun-comments.

mark-defun is defined for Lisp and Lisp-like languages, it is not a
function that's supposed to support any major mode.  If we want a
PL-independent mark-defun function, we need first to refactor
mark-defun to allow mode-specific behavior.