Function: vhdl-speedbar-expand-package
vhdl-speedbar-expand-package is a byte-compiled function defined in
vhdl-mode.el.gz.
Signature
(vhdl-speedbar-expand-package TEXT TOKEN INDENT)
Documentation
Expand/contract the package under the cursor.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-speedbar-expand-package (text token indent)
"Expand/contract the package under the cursor."
(cond
((string-match "\\+" text) ; expand package
(let* ((key (vhdl-speedbar-line-key indent))
(pack-alist (vhdl-aget vhdl-package-alist key))
(pack-entry (vhdl-aget pack-alist token))
(comp-alist (nth 3 pack-entry))
(func-alist (nth 4 pack-entry))
(func-body-alist (nth 8 pack-entry))
(subpack-alist (append (nth 5 pack-entry) (nth 9 pack-entry)))
comp-entry func-entry func-body-entry)
(if (not (or comp-alist func-alist subpack-alist))
(speedbar-change-expand-button-char ??)
(speedbar-change-expand-button-char ?-)
;; add package to `vhdl-speedbar-shown-unit-alist'
(let* ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key)))
(vhdl-aput 'unit-alist token nil)
(vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist))
(speedbar-with-writable
(save-excursion
(end-of-line) (forward-char 1)
;; insert components
(when comp-alist
(vhdl-speedbar-make-title-line "Components:" (1+ indent)))
(while comp-alist
(setq comp-entry (car comp-alist))
(speedbar-make-tag-line
nil nil nil
(cons token (nth 0 comp-entry))
(nth 1 comp-entry) 'vhdl-speedbar-find-file
(cons (nth 2 comp-entry) (nth 3 comp-entry))
'vhdl-speedbar-entity-face (1+ indent))
(setq comp-alist (cdr comp-alist)))
;; insert subprograms
(when func-alist
(vhdl-speedbar-make-title-line "Subprograms:" (1+ indent)))
(while func-alist
(setq func-entry (car func-alist)
func-body-entry (vhdl-aget func-body-alist
(car func-entry)))
(when (nth 2 func-entry)
(vhdl-speedbar-make-subprogram-line
(nth 1 func-entry)
(cons (nth 2 func-entry) (nth 3 func-entry))
(cons (nth 1 func-body-entry) (nth 2 func-body-entry))
(1+ indent)))
(setq func-alist (cdr func-alist)))
;; insert required packages
(vhdl-speedbar-insert-subpackages
subpack-alist (1+ indent) indent)))
(when (memq 'display vhdl-speedbar-save-cache)
(add-to-list 'vhdl-updated-project-list key))
(vhdl-speedbar-update-current-unit t t))))
((string-match "-" text) ; contract package
(speedbar-change-expand-button-char ?+)
;; remove package from `vhdl-speedbar-shown-unit-alist'
(let* ((key (vhdl-speedbar-line-key indent))
(unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key)))
(vhdl-adelete 'unit-alist token)
(if unit-alist
(vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist)
(vhdl-adelete 'vhdl-speedbar-shown-unit-alist key))
(speedbar-delete-subblock indent)
(when (memq 'display vhdl-speedbar-save-cache)
(add-to-list 'vhdl-updated-project-list key))))
(t (error "Nothing to display")))
(when (equal (selected-frame) speedbar-frame)
(speedbar-center-buffer-smartly)))