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))
	(lim (save-excursion
	       ;; (verilog-re-search-backward verilog-declaration-opener nil 'move)
              (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<\\(connect\\)?module\\>\\)\\|\\(\\<task\\>\\)" nil 'move)
	       (point)))
	(ind)
	(val)
	(m1 (make-marker)))
    (setq val
	  (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
    (indent-line-to val)

    ;; Use previous declaration (in this module) as template.
    (if (or (eq 'all verilog-auto-lineup)
	    (eq 'declarations verilog-auto-lineup))
	(if (verilog-re-search-backward
	     (or (and verilog-indent-declaration-macros
		      verilog-declaration-re-1-macro)
                verilog-declaration-re-1-no-macro)
            lim t)
	    (progn
	      (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 (and verilog-indent-declaration-macros
		       (looking-at verilog-declaration-re-2-macro))
		  (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)))
		(if (looking-at verilog-declaration-re-2-no-macro)
		    (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)))