Function: vhdl-indent-line
vhdl-indent-line is an interactive and byte-compiled function defined
in vhdl-mode.el.gz.
Signature
(vhdl-indent-line)
Documentation
Indent the current line as VHDL code.
Return the amount of indentation change.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-indent-line ()
"Indent the current line as VHDL code.
Return the amount of indentation change."
(interactive)
(let* ((syntax (and vhdl-indent-syntax-based (vhdl-get-syntactic-context)))
(pos (- (point-max) (point)))
(is-comment nil)
(indent
(if syntax
;; indent syntax-based
(if (and (eq (caar syntax) 'comment)
(>= (vhdl-get-offset (car syntax)) comment-column))
;; special case: comments at or right of comment-column
(vhdl-get-offset (car syntax))
;; align comments like following code line
(when vhdl-indent-comment-like-next-code-line
(save-excursion
(while (eq (caar syntax) 'comment)
(setq is-comment t)
(beginning-of-line 2)
(setq syntax (vhdl-get-syntactic-context)))))
(when is-comment
(push (cons 'comment nil) syntax))
(apply #'+ (mapcar #'vhdl-get-offset syntax)))
;; indent like previous nonblank line
(save-excursion (beginning-of-line)
(re-search-backward "^[^\n]" nil t)
(current-indentation))))
(shift-amt (- indent (current-indentation))))
(and vhdl-echo-syntactic-information-p
(message "syntax: %s, indent= %d" syntax indent))
(let ((has-formfeed
(save-excursion (beginning-of-line) (looking-at "\\s-*\f"))))
(when (or (not (zerop shift-amt)) has-formfeed)
(delete-region (vhdl-point 'bol) (vhdl-point 'boi))
(beginning-of-line)
(when has-formfeed (insert "\f"))
(indent-to indent)))
(if (< (point) (vhdl-point 'boi))
(back-to-indentation)
;; If initial point was within line's indentation, position after
;; the indentation. Else stay at same point in text.
(when (> (- (point-max) pos) (point))
(goto-char (- (point-max) pos))))
(run-hooks 'vhdl-special-indent-hook)
(when vhdl--progress-reporter
(progress-reporter-update vhdl--progress-reporter (point)))
shift-amt))