Function: vhdl-get-block-state
vhdl-get-block-state is a byte-compiled function defined in
vhdl-mode.el.gz.
Signature
(vhdl-get-block-state &optional LIM)
Documentation
Find and records all the closest opens.
LIM is the furthest back we need to search (it should be the previous libunit keyword).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-get-block-state (&optional lim)
"Find and records all the closest opens.
LIM is the furthest back we need to search (it should be the
previous libunit keyword)."
(let ((here (point))
(lim (or lim (point-min)))
keyword sexp-start sexp-mid sexp-end
preceding-sexp containing-sexp
containing-begin containing-mid containing-paren)
(save-excursion
;; Find the containing-paren, and use that as the limit
(if (setq containing-paren
(save-restriction
(narrow-to-region lim (point))
(vhdl-safe (scan-lists (point) -1 1))))
(setq lim containing-paren))
;; Look backwards for "begin" and "end" keywords.
(while (and (> (point) lim)
(not containing-sexp))
(setq keyword (vhdl-backward-to-block lim))
(cond
((eq keyword 'begin)
;; Found a "begin" keyword
(setq sexp-start (point))
(setq sexp-mid (vhdl-corresponding-mid lim))
(setq sexp-end (vhdl-safe
(save-excursion
(vhdl-forward-sexp 1 lim) (point))))
(if (and sexp-end (<= sexp-end here))
;; we want to record this sexp, but we only want to
;; record the last-most of any of them before here
(or preceding-sexp
(setq preceding-sexp sexp-start))
;; we're contained in this sexp so put sexp-start on
;; front of list
(setq containing-sexp sexp-start)
(setq containing-mid sexp-mid)
(setq containing-begin t)))
((eq keyword 'end)
;; Found an "end" keyword
(forward-sexp)
(setq sexp-end (point))
(setq sexp-mid nil)
(setq sexp-start
(or (vhdl-safe (vhdl-backward-sexp 1 lim) (point))
(progn (backward-sexp) (point))))
;; we want to record this sexp, but we only want to
;; record the last-most of any of them before here
(or preceding-sexp
(setq preceding-sexp sexp-start)))
)))
;; Check if the containing-paren should be the containing-sexp
(if (and containing-paren
(or (null containing-sexp)
(< containing-sexp containing-paren)))
(setq containing-sexp containing-paren
preceding-sexp nil
containing-begin nil
containing-mid nil))
(vector containing-sexp preceding-sexp containing-begin containing-mid)
))