This was my approximation, it's a simple function that take care of the main nodes and updates the content when the buffer is save. Explained below
(defun sb/expand-tags ()
"Expand current `sr-speedbar' buffer file."
;; We assume that the speedbar name is the same as the file of the buffer
(let* ((current-buffer-name (file-name-nondirectory (buffer-file-name)))
;; Refresh the current speedbar buffer
(setq file-point (point))
;; This function make the point go backwards so we have to save the location
;; We enter the "expanded" attributes
;; Check if we reach another file, or the end of the buffer.
(and (not (speedbar-line-file))
(not (equal (point) (point-max))))
(push (point) line-list)
;; Once we have the point of the main branches, we iterate
;; and expand his content
(seq-map (lambda (line)
;; Add it to the save-hook
(add-hook 'after-save-hook 'sb/expand-tags)
There is a couple of things that I had to take into account in order to create this function:
- I assume that the important nodes are the main ones just in the first depth.
- When the speedbar buffer is refresh, it will only show the expanded information of the current file
- The speedbar file node has the same name as the current buffer file.
This function can be added to the main file and has no external dependencies (except for sr-speedbar of course)
If it is necessary I can change the above points to fit the requirements.