dominikh / go-mode.el

Emacs mode for the Go programming language
BSD 3-Clause "New" or "Revised" License
1.38k stars 211 forks source link

add-log-current-defun doesn't work with Go code #253

Open robert-uhl opened 6 years ago

robert-uhl commented 6 years ago

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.

psanford commented 5 years ago

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?