Function: vhdl-fix-statement-region
vhdl-fix-statement-region is an interactive and byte-compiled function
defined in vhdl-mode.el.gz.
Signature
(vhdl-fix-statement-region BEG END &optional ARG)
Documentation
Force statements in region on separate line except when on same line
with end keyword (necessary for correct indentation).
Currently supported keywords: begin, if.
Probably introduced at or before Emacs version 24.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fix statements
;; - force each statement to be on a separate line except when on same line
;; with 'end' keyword
(defun vhdl-fix-statement-region (beg end &optional _arg)
"Force statements in region on separate line except when on same line
with `end' keyword (necessary for correct indentation).
Currently supported keywords: `begin', `if'."
(interactive "r")
(vhdl-prepare-search-2
(let (point)
(save-excursion
(goto-char end)
(setq end (point-marker))
(goto-char beg)
;; `begin' keyword
(while (re-search-forward
"^\\s-*[^ \t\n].*?\\(\\<begin\\>\\)\\(.*\\<end\\>\\)?" end t)
(goto-char (match-end 0))
(setq point (point-marker))
(when (and (match-string 1)
(or (not (match-string 2))
(save-excursion (goto-char (match-end 2))
(vhdl-in-literal)))
(not (save-excursion (goto-char (match-beginning 1))
(vhdl-in-literal))))
(goto-char (match-beginning 1))
(insert "\n")
(indent-according-to-mode))
(goto-char point))
(goto-char beg)
;; `for', `if' keywords
(while (re-search-forward "\\<\\(for\\|if\\)\\>" end t)
(goto-char (match-end 1))
(setq point (point-marker))
;; exception: in literal or preceded by `end', `wait' or label
(when (and (not (save-excursion (goto-char (match-beginning 1))
(vhdl-in-literal)))
(save-excursion
(beginning-of-line 1)
(save-match-data
(and (re-search-forward "^\\s-*\\([^ \t\n].*\\)"
(match-beginning 1) t)
(not (string-match
"\\(\\<end\\>\\|\\<wait .*\\|\\w+\\s-*:\\)\\s-*$"
(match-string 1)))))))
(goto-char (match-beginning 1))
(insert "\n")
(indent-according-to-mode))
(goto-char point))))))