Function: vhdl-align-region

vhdl-align-region is an interactive and byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-align-region BEG END &optional SPACING)

Documentation

Align region, treat blocks with same indent and argument lists separately.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-align-region (beg end &optional spacing)
  "Align region, treat blocks with same indent and argument lists separately."
  (interactive "r\nP")
  (if (not vhdl-align-same-indent)
      ;; align entire region
      (vhdl-align-region-groups beg end spacing)
    ;; align blocks with same indent and argument lists
    (save-excursion
      (let ((cur-beg beg)
	    indent cur-end
	    (vhdl--progress-reporter
	     (when vhdl-progress-interval
	       (make-progress-reporter "Aligning..." beg (copy-marker end)))))
	(goto-char end)
	(setq end (point-marker))
	(goto-char cur-beg)
	(while (< (point) end)
	  ;; is argument list opening?
	  (if (setq cur-beg (nth 1 (save-excursion (parse-partial-sexp
						    (point) (vhdl-point 'eol)))))
	      ;; determine region for argument list
	      (progn (goto-char cur-beg)
		     (forward-sexp)
		     (setq cur-end (point))
		     (beginning-of-line 2))
	    ;; determine region with same indent
	    (setq indent (current-indentation))
	    (setq cur-beg (point))
	    (setq cur-end (vhdl-point 'bonl))
	    (beginning-of-line 2)
	    (while (and (< (point) end)
			(or (looking-at "^\\s-*\\(--.*\\)?$")
			    (= (current-indentation) indent))
			(<= (save-excursion
			      (nth 0 (parse-partial-sexp
				      (point) (vhdl-point 'eol))))
			    0))
	      (unless (looking-at "^\\s-*$")
		(setq cur-end (vhdl-point 'bonl)))
	      (beginning-of-line 2)))
	  ;; align region
	  (vhdl-align-region-groups cur-beg cur-end spacing t t))
	(vhdl-align-inline-comment-region beg end spacing noninteractive)
	(when vhdl--progress-reporter
	  (progress-reporter-done vhdl--progress-reporter))))))