On Sun, Nov 27, 2022 at 2:54 AM Dmitry Gutov wrote: > It seems like > > (setq add-log-current-defun-function nil) > > should suffice. That does not stop add-log-current-defun for working, in absence of an a-l-c-d-function it just uses the regexp, which is what is returning the spurious name. Either adding a custom add-log-current-defun-function, or setting add-log-current-defun-header-regexp to a buffer-local value so it recognizes filenames would work. (Buffer-locally, because the variable is in fact customizable so we can't be sure what its global value will be.) This works, for example: (defun xref--add-log-current-defun () (if-let (item (xref--item-at-point)) (xref-file-location-file (xref-match-item-location item)) (xref--imenu-extract-index-name))) (setq-local add-log-current-defun-function #'xref--add-log-current-defun) > Is that the intended behavior, to report the absence of the current defun? The final intended behavior, IIUC, is that the filenames in the xref--xref-buffer-mode get passed to which-function as "defun" names.