Function: vhdl-fix-clause

vhdl-fix-clause is an interactive and byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-fix-clause)

Documentation

Fix closing parenthesis within generic/port clause.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-fix-clause ()
  "Fix closing parenthesis within generic/port clause."
  (interactive)
  (save-excursion
    (vhdl-prepare-search-2
     (let ((pos (point))
	   beg end)
       (end-of-line)
       (if (not (re-search-backward "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(" nil t))
	   (error "ERROR:  Not within a generic/port clause")
	 ;; search for end of clause
	 (goto-char (match-end 0))
	 (setq beg (1- (point)))
	 (vhdl-forward-syntactic-ws)
	 (while (looking-at "\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*[ \t\n\r\f]*:[ \t\n\r\f]*\\w+[^;]*;")
	   (goto-char (1- (match-end 0)))
	   (setq end (point-marker))
	   (forward-char)
	   (vhdl-forward-syntactic-ws))
	 (goto-char end)
         (when (> pos (line-end-position))
	   (error "ERROR:  Not within a generic/port clause"))
	 ;; delete closing parenthesis on separate line (not supported style)
	 (when (save-excursion (beginning-of-line) (looking-at "^\\s-*);"))
	   (vhdl-line-kill)
	   (vhdl-backward-syntactic-ws)
	   (setq end (point-marker))
	   (insert ";"))
	 ;; delete superfluous parentheses
	 (while (progn (goto-char beg)
		       (condition-case () (forward-sexp)
			 (error (goto-char (point-max))))
		       (< (point) end))
	   (delete-char -1))
	 ;; add closing parenthesis
	 (when (> (point) end)
	   (goto-char end)
	   (insert ")")))))))