0

I have the following in my init file

(defun message-buffer-file-name-or-nothing ()
  "Mode line proxy."
  (if buffer-file-name
      (message "[%s] %s"
           (format-time-string "%H:%M:%S")
           (buffer-file-name)))
  )
(add-hook 'focus-in-hook 'message-buffer-file-name-or-nothing)

and it worked great, until recently when it started echoing NOT the file-name of the buffer I was switching to but instead the file-name of the bufer I was switching FROM. I have no idea what happened since I didn't tamper with anything and I can't recall updating emacs recently either (25.3.1).

Output of C-h v focus-in-hook is message-buffer-file-name-or-nothing, nothing else hooks it. I guess this gets executed before buffer-file-name gets updated? But this is weird since it didn't work like this previously. Anyone have any ideas on how to troubleshoot this?

3
  • Do you see the same problem if you start Emacs using emacs -Q? If not, bisect your init file to find the culprit.
    – Drew
    Nov 28, 2017 at 14:54
  • With emacs -Q and the snippet from op in the scratch buffer, this behaviour is reproduced. This has got to qualify as a bug, right? Nov 28, 2017 at 20:30
  • Although only when using the WMs switch-focus functions. Using other-frame and similar emacs native functions, it works as expected... Nov 28, 2017 at 20:58

1 Answer 1

0

No idea what's causing this so I don't have a robust solution. Only a workaround...

(defadvice handle-switch-frame (around switch-frame-message-name)
  (message-buffer-file-name-or-nothing)
  ad-do-it
  (message-buffer-file-name-or-nothing))
(ad-activate 'handle-switch-frame)

Works for me on i3/emacs 25.3.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.