add-log-current-defun doesn't know how Go code is formatted. Fortunately, there's a variable add-log-current-defun-function, which can be used to integrate with Go mode:
(defun go-current-def-name ()
"Return the name of the function at point, or nil."
(save-excursion
(go-goto-function-name)
;; get the next word
(buffer-substring-no-properties (point)
(progn (forward-sexp 1)
(point)))))
(add-hook 'go-mode-hook (lambda ()
(setq add-log-current-defun-function #'go-current-def-name)))
It'd be great to have this (or something slightly smarter) added to Go mode.
Interesting. It does look like most progmodes set the add-log-current-defun-function. Are you depending on this behavior for (add-change-log-entry) or for something else?
add-log-current-defun
doesn't know how Go code is formatted. Fortunately, there's a variableadd-log-current-defun-function
, which can be used to integrate with Go mode:It'd be great to have this (or something slightly smarter) added to Go mode.