Function: vhdl-subprog-paste-specification

vhdl-subprog-paste-specification is a byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-subprog-paste-specification KIND)

Documentation

Paste as a subprogram specification.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-subprog-paste-specification (kind)
  "Paste as a subprogram specification."
  (indent-according-to-mode)
  (let ((margin (current-column))
	(param-list (nth 2 vhdl-subprog-list))
	list-margin start names param)
    ;; paste keyword and name
    (vhdl-insert-keyword
     (if (eq (nth 1 vhdl-subprog-list) 'procedure) "PROCEDURE " "FUNCTION "))
    (insert (nth 0 vhdl-subprog-list))
    (if (not param-list)
	(if (eq kind 'decl) (insert ";") (vhdl-insert-keyword " is"))
      (setq start (point))
      ;; paste parameter list
      (insert " (")
      (unless vhdl-argument-list-indent
	(insert "\n") (indent-to (+ margin vhdl-basic-offset)))
      (setq list-margin (current-column))
      (while param-list
	(setq param (car param-list))
	;; paste group comment and spacing
	(when (memq vhdl-include-group-comments (list kind 'always))
	  (vhdl-paste-group-comment (nth 6 param) list-margin))
	;; paste object
	(when (nth 1 param) (insert (nth 1 param) " "))
	;; paste names
	(setq names (nth 0 param))
	(while names
	  (insert (car names))
	  (setq names (cdr names))
	  (when names (insert ", ")))
	;; paste direction
	(insert " : ")
	(when (nth 2 param) (insert (nth 2 param) " "))
	;; paste type
	(insert (nth 3 param))
	;; paste initialization
	(when (nth 4 param) (insert " := " (nth 4 param)))
	;; terminate line
	(if (cdr param-list)
	    (insert ";")
	  (insert ")")
	  (when (null (nth 3 vhdl-subprog-list))
	    (if (eq kind 'decl) (insert ";") (vhdl-insert-keyword " is"))))
	;; paste comment
	(when (and vhdl-include-port-comments (nth 5 param))
	  (vhdl-comment-insert-inline (nth 5 param) t))
	(setq param-list (cdr param-list))
	(when param-list (insert "\n") (indent-to list-margin)))
      (when (nth 3 vhdl-subprog-list)
	(insert "\n") (indent-to list-margin)
	;; paste group comment and spacing
	(when (memq vhdl-include-group-comments (list kind 'always))
	  (vhdl-paste-group-comment (nth 5 vhdl-subprog-list) list-margin))
	;; paste return type
	(insert "return " (nth 3 vhdl-subprog-list))
	(if (eq kind 'decl) (insert ";") (vhdl-insert-keyword " is"))
	(when (and vhdl-include-port-comments (nth 4 vhdl-subprog-list))
	  (vhdl-comment-insert-inline (nth 4 vhdl-subprog-list) t)))
      ;; align parameter list
      (when vhdl-auto-align (vhdl-align-region-groups start (point) 1 t)))
    ;; paste body
    (when (eq kind 'body)
      (insert "\n")
      (vhdl-template-begin-end
       (unless (vhdl-standard-p '87)
	 (if (eq (nth 1 vhdl-subprog-list) 'procedure) "PROCEDURE" "FUNCTION"))
       (nth 0 vhdl-subprog-list) margin))))