fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Chmouel Boudjnah

Something I do often in is to have to copy the current function name to my clipboard (usually for running my e2e test or other grep)

here is a little function that uses treesitter to grab the function and copy it to your kil-ring

(defun my-copy-function-name-with-ts()
(interactive)
(let ((funcname
(substring-no-properties
(treesit-node-text
(treesit-node-child-by-field-name (treesit-defun-at-point) "name")))))
(kill-new funcname)
(message "Copied name: %s" funcname)))

@chmouel Interesting. I haven't tried treesitter in #emacs yet, but calling (which-function) will return the name. Not sure if treesitter modifies its implementation.

I don't think it exists, but an embark command on the defun target to return or copy-as-kill the defun name would be useful too.