Subject: bug#67361: 29.1; MH-E: creating a new folder can sometimes fail with a Lisp error

From: Mike Kupfer <[email-masked]>
Date: Fri, 24 Nov 2023 18:31:55 -0800

Mike Kupfer wrote:

> > > From: Chris Siebenmann <[email-masked]>
> > > Date: Tue, 21 Nov 2023 20:45:11 -0500
> > > 
> > > Under some conditions, creating a new (N)MH folder in MH-E can fail with
> > > a Lisp error of 'Wrong type argument: stringp, nil'. This happens if for
> > > some reason you have loaded/required mh-speed.el but have not created a
> > > speedbar.
> 
> This sounds familiar.  I don't use the speedbar, but I sometimes hit
> this issue and find that (boundp 'mh-speed-folder-map) returns t.  I
> thought there was an open bug for this already, but I'm not finding it.
> I'll look some more over the holiday weekend.

I'm sure I've run into this problem in the past, but I can't find any
record of it.  Not in debbugs.gnu.org, not in the SourceForge bug
tracker, not in my email archives.  Hmph.

Still, I agree with Chris's root cause analysis:

> I believe the root cause of this problem is that mh-prompt-for-folder
> calls mh-speed-add-folder if 'mh-speed-folder-map is bound:
> 	(when (boundp 'mh-speed-folder-map)
> 	  (mh-speed-add-folder folder-name))
> 
> However, mh-speed-add-folder requires that speedbar-buffer exists, as it
> starts with:
> 	(with-current-buffer speedbar-buffer
> 	  ....)

The same issue appears in 2 other places:

  - mh-kill-folder, calling mh-speed-invalidate-map
  - mh-index-new-folder, calling mh-speed-add-folder

I'm not entirely sure how I have ended up with mh-speed-folder-map bound
in the past.  It might be from trying to get the help information for
something that's defined in mh-speed.el--that seems to cause mh-speed to
be loaded, which causes mh-speed-folder-map to be initialized.

Using mh-speed-folder-map as the test for whether the speedbar is active
seems broken to me.  Unfortunately, I don't use the speedbar, and I
don't understand the MH-E speedbar code all that well.  So I'm not sure
what the right test is.  There's a function mh-speed-flists-active-p,
but its docstring says

  "Check if speedbar is running with message counts enabled."

Bill, is there a mode where the speedbar is running *without* message
counts enabled?  Or can we just replace 

    (when (boundp 'mh-speed-folder-map)

with

    (if (mh-speed-flists-active-p)

?

mike