Subject: Re: bug#73889: 31.0.50; speedbar-expand-line-descendants produces nested "DEFUN" structures

From: Morgan Willcock <[email-masked]>
Date: Sat, 19 Oct 2024 19:55:29 +0100

Here is an example to demonstrate the specifics of the problem:

  printf "DEFUN () {};\nDEFUN () {};\nDEFUN () {};\n" >/tmp/test.c

  emacs -Q \
        --eval "(require 'speedbar)" \
        --eval "(setq speedbar-tag-regroup-maximum-length 2)" \
        --eval "(setq speedbar-tag-split-minimum-length 2)" \
        --eval "(find-file \"/tmp/test.c\")" \
        --eval "(speedbar)"

Expanding the "test.c" item in the Speedbar will now show a single
"DEFUN" item, but expanding that "DEFUN" item will just insert an
additional "DEFUN" item that also needs to be expanded.  This behaviour
will repeat infinitely.

The problem appears to originate from when the item hierarchy is
modified by speedbar-prefix-group-tag-hierarchy, where exceeding the
limits for both speedbar-tag-regroup-maximum-length and
speedbar-tag-split-minimum-length will return all items with an
additional parent item:

  (speedbar-prefix-group-tag-hierarchy
   '(("DEFUN" . 1)
     ("DEFUN" . 5)
     ("DEFUN" . 10)))

  => (("DEFUN" ("DEFUN" . 1) ("DEFUN" . 5) ("DEFUN" . 10)))

-- 
Morgan Willcock