Function: verilog-indent-declaration

verilog-indent-declaration is an interactive and byte-compiled function defined in verilog-mode.el.gz.

Signature

(verilog-indent-declaration BASEIND)

Documentation

Indent current lines as declaration.

Line up the variable names based on previous declaration's indentation. BASEIND is the base indent to offset everything.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/verilog-mode.el.gz
(defun verilog-indent-declaration (baseind)
  "Indent current lines as declaration.
Line up the variable names based on previous declaration's indentation.
BASEIND is the base indent to offset everything."
  (interactive)
  ;; `ind' is used in expressions stored in `verilog-indent-alist'.
  (verilog--suppressed-warnings ((lexical ind)) (defvar ind))
  (let ((pos (point-marker))
        (m1 (make-marker))
        (in-paren (verilog-parenthesis-depth))
        (val (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
        ind)
    (indent-line-to val)
    ;; Use previous declaration (in this module) as template.
    (when (and (or (eq 'all verilog-auto-lineup)
                   (eq 'declarations verilog-auto-lineup))
               ;; Limit alignment to consecutive statements
               (progn
                 (verilog-backward-syntactic-ws)
                 (backward-char)
                 (looking-at ";"))
               (progn
                 (verilog-beg-of-statement)
                 (looking-at (verilog-get-declaration-re)))
               ;; Make sure that we don't jump to an argument list or parameter block if
               ;; we were in a declaration block (not in argument list)
               (or (and in-paren
                        (verilog-parenthesis-depth))
                   (and (not in-paren)
                        (not (verilog-parenthesis-depth))))
               ;; Skip variable declarations inside functions/tasks
               (skip-chars-backward " \t\f")
               (bolp))
      (goto-char (match-end 0))
      (skip-chars-forward " \t")
      (setq ind (current-column))
      (goto-char pos)
      (setq val
            (+ baseind
               (eval (cdr (assoc 'declaration verilog-indent-alist)))))
      (indent-line-to val)
      (if (looking-at (verilog-get-declaration-re))
          (let ((p (match-end 0)))
            (set-marker m1 p)
            (if (verilog-re-search-forward "[[#`]" p 'move)
                (progn
                  (forward-char -1)
                  (just-one-space)
                  (goto-char (marker-position m1))
                  (delete-horizontal-space)
                  (indent-to ind 1))
              (delete-horizontal-space)
              (indent-to ind 1)))
        (when (looking-at (verilog-get-declaration-re))
          (let ((p (match-end 0)))
            (set-marker m1 p)
            (if (verilog-re-search-forward "[[`#]" p 'move)
                (progn
                  (forward-char -1)
                  (just-one-space)
                  (goto-char (marker-position m1))
                  (delete-horizontal-space)
                  (indent-to ind 1))
              (delete-horizontal-space)
              (indent-to ind 1))))))
    (goto-char pos)))