Subject: bug#50187: 28.0.50; tramp is called from calendar

From: Gregory Heytings <[email-masked]>
Date: Fri, 16 Sep 2022 15:02:04 +0000

>
> calendar is far from being the only problem.
>

That wasn't clear from the bug title and the discussion.

>
> I run this:
>
> (dolist (b (buffer-list))
>  (with-current-buffer b
>    (when (and (null buffer-file-name)
>               (not (eq major-mode 'dired-mode))
>               (not (string-match " ?\\*.*\\(tramp\\|vc\\|diff\\)" (buffer-name)))
>               (find-file-name-handler default-directory 'file-remote-p))
>      (message "Reset 'default-directory' in %s(%s) from %s"
>               b (or buffer-file-name list-buffers-directory) default-directory)
>      (setq default-directory (default-value 'default-directory))
>      )))
>
> every now and then.
>

I think you can achieve a similar effect automatically, by adding a 
function in buffer-list-update-hook that does the above on the first 
element of buffer-list.  But as Michael said you should probably not use 
nil.