Function: vhdl-compose-place-component
vhdl-compose-place-component is an interactive and byte-compiled
function defined in vhdl-mode.el.gz.
Signature
(vhdl-compose-place-component)
Documentation
Place new component by pasting current port as component declaration and component instantiation.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-compose-place-component ()
"Place new component by pasting current port as component declaration and
component instantiation."
(interactive)
(if (not vhdl-port-list)
(error "ERROR: No port has been read")
(save-excursion
(vhdl-prepare-search-2
(unless (or (re-search-backward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
(re-search-forward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t))
(error "ERROR: No architecture found"))
(let* ((ent-name (match-string 1))
(ent-file-name
(concat (vhdl-replace-string vhdl-entity-file-name ent-name t)
"." (file-name-extension (buffer-file-name))))
(orig-buffer (current-buffer)))
(message "Placing component \"%s\"..." (nth 0 vhdl-port-list))
;; place component declaration
(unless (or vhdl-use-components-package
(vhdl-use-direct-instantiation)
(save-excursion
(re-search-forward
(concat "^\\s-*component\\s-+"
(car vhdl-port-list) "\\>") nil t)))
(re-search-forward "^begin\\>" nil)
(beginning-of-line)
(skip-chars-backward " \t\n\r\f")
(insert "\n\n") (indent-to vhdl-basic-offset)
(vhdl-port-paste-component t))
;; place component instantiation
(re-search-forward "^end\\>" nil)
(beginning-of-line)
(skip-chars-backward " \t\n\r\f")
(insert "\n\n") (indent-to vhdl-basic-offset)
(vhdl-port-paste-instance nil t t)
;; place use clause for used packages
(when (nth 3 vhdl-port-list)
;; open entity file
(when (file-exists-p ent-file-name)
(find-file ent-file-name))
(goto-char (point-min))
(unless (re-search-forward (concat "^entity[ \t\n\r\f]+" ent-name "[ \t\n\r\f]+is\\>") nil t)
(error "ERROR: Entity not found: \"%s\"" ent-name))
(goto-char (match-beginning 0))
(if (and (save-excursion
(re-search-backward "^\\(library\\|use\\)\\|end\\>" nil t))
(match-string 1))
(progn (goto-char (match-end 0))
(beginning-of-line 2))
(insert "\n")
(backward-char))
(vhdl-port-paste-context-clause)
(switch-to-buffer orig-buffer))
(message "Placing component \"%s\"...done" (nth 0 vhdl-port-list)))))))