Function: vhdl-comment-insert
vhdl-comment-insert is an interactive and byte-compiled function
defined in vhdl-mode.el.gz.
Signature
(vhdl-comment-insert)
Documentation
Start a comment at the end of the line.
If on line with code, indent at least comment-column.
If starting after end-comment-column, start a new line.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-comment-insert ()
"Start a comment at the end of the line.
If on line with code, indent at least `comment-column'.
If starting after end-comment-column, start a new line."
(interactive)
(when (> (current-column) end-comment-column) (newline-and-indent))
(if (or (looking-at "\\s-*$") ; end of line
(and (not unread-command-events) ; called with key binding or menu
(not (end-of-line))))
(let (margin)
(while (= (preceding-char) ?-) (delete-char -1))
(setq margin (current-column))
(delete-horizontal-space)
(if (bolp)
(progn (indent-to margin) (insert "--"))
(insert " ")
(indent-to comment-column)
(insert "--"))
(if (not unread-command-events) (insert " ")))
;; else code following current point implies commenting out code
(let (next-input code)
(while (= (preceding-char) ?-) (delete-char -2))
(while (= (setq next-input (read-char)) 13) ; CR
(insert "--") ; or have a space after it?
(forward-char -2)
(forward-line 1)
(message "Enter CR if commenting out a line of code.")
(setq code t))
(unless code
(insert "--")) ; hardwire to 1 space or use vhdl-basic-offset?
(push (vhdl-character-to-event next-input) ; pushback the char
unread-command-events))))