I'm editing some Python code with rather long functions and decided it would be useful to quickly get the function name without scrolling up. I put this bit of code together to do it. Is there something built in to emacs in general, or the standard python mode in particular, which I can use instead?
(defun python-show-function-name()
"Message the name of the function the point is in"
(interactive)
(save-excursion
(beginning-of-defun)
(message (format "%s" (thing-at-point 'line)))))
Did you try py-beginning-of-def-or-class
?
(defun python-show-function-name()
"Message the name of the function the point is in"
(interactive)
(save-excursion
(py-beginning-of-def-or-class)
(message (format "%s" (thing-at-point 'line)))))
I find it gives me better results than your beginning-of-defun
, but if that's not the problem you're having, then maybe I'm just seeing another symptom of the cause of the wonkiness in my other answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With