changeset 87315:34b619baa980

Replace all instances of string-to-int with string-to-number, insert-string with insert, and read-input with read-string. (top-level): No need to require imenu, reporter, dinotrace, vc, font-lock when compiling. Always require compile. Relegate remaining compatibility cruft to XEmacs. Don't require font-lock. (verilog-version): Remove superfluous concat. (dinotrace-unannotate-all, zmacs-activate-region) (customize-apropos): No need to define. (verilog-regexp-opt): On Emacs, just make it an alias for regexp-opt. (verilog-font-lock-keywords, verilog-font-lock-keywords-1) (verilog-font-lock-keywords-2, verilog-font-lock-keywords-3) (verilog-startup-message-displayed): These are variables, not constants. (verilog-batch-execute-func, verilog-auto-inst) (verilog-auto-inst-param): Use mapc rather than mapcar. (sigs-in, sigs-inout, sigs-out): Define for compiler rather than actually defining. (verilog-modi-get-decls, verilog-modi-get-sub-decls) (verilog-modi-get-outputs, verilog-modi-get-inouts) (verilog-modi-get-inputs, verilog-modi-get-wires) (verilog-modi-get-regs, verilog-modi-get-assigns) (verilog-modi-get-consts, verilog-modi-get-gparams) (verilog-modi-get-sub-outputs, verilog-modi-get-sub-inouts) (verilog-modi-get-sub-inputs): Move inline functions earlier in the file. (sigs-in, sigs-out): Don't declare multiple times. (got-sig, got-rvalue, uses-delayed): Define for compiler with just `defvar'. (verilog-auto): Call dinotrace-unannotate-all only if bound. (verilog-module-inside-filename-p): No need to wrap fboundp test in condition-case. (reporter-submit-bug-report): Autoload it. (verilog-mark-defun): Call zmacs-activate-region only if bound. (verilog-font-customize): Call customize-apropos only if bound. (verilog-getopt-flags, verilog-auto-reeval-locals): Use make-local-variable rather than make-variable-buffer-local. (verilog-company, verilog-project, verilog-modi-cache-list): Move make-variable-buffer-local calls to top-level. (font-lock-defaults-alist): Don't define it. (verilog-need-fld): Remove. (verilog-font-lock-init): Don't set font-lock-defaults-alist. (verilog-mode): Only call make-local-hook on XEmacs. Set font-lock-defaults rather than using verilog-font-lock-init.
author Glenn Morris <rgm@gnu.org>
date Tue, 18 Dec 2007 02:32:29 +0000
parents 238289d30e93
children 3038b17c409e
files lisp/progmodes/verilog-mode.el
diffstat 1 files changed, 245 insertions(+), 279 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/verilog-mode.el	Tue Dec 18 02:32:04 2007 +0000
+++ b/lisp/progmodes/verilog-mode.el	Tue Dec 18 02:32:29 2007 +0000
@@ -115,164 +115,135 @@
 (defun verilog-version ()
   "Inform caller of the version of this file."
   (interactive)
-  (message (concat "Using verilog-mode version " verilog-mode-version) ))
+  (message "Using verilog-mode version %s" verilog-mode-version))
+
+(require 'compile)
 
 ;; Insure we have certain packages, and deal with it if we don't
 (eval-when-compile
-  (condition-case nil
-      (require 'imenu)
-    (error nil))
-  (condition-case nil
-      (require 'reporter)
-    (error nil))
-  (condition-case nil
-      (require 'easymenu)
-    (error nil))
-  (condition-case nil
-      (require 'regexp-opt)
-    (error nil))
-  (condition-case nil
-      (load "skeleton") ;; bug in 19.28 through 19.30 skeleton.el, not provided.
-    (error nil))
-  (condition-case nil
-      (require 'vc)
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'when)
-	  nil ;; fab
-	(defmacro when (cond &rest body)
-	  (list 'if cond (cons 'progn body))))
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'unless)
-	  nil ;; fab
-	(defmacro unless (cond &rest body)
-	  (cons 'if (cons cond (cons nil body)))))
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'store-match-data)
-	  nil ;; fab
-	(defmacro store-match-data (&rest args) nil))
-    (error nil))
-  (if (featurep 'xemacs)
-      (condition-case nil
-	  (if (boundp 'current-menubar)
-	      nil ;; great
-	    (progn
-	      (defmacro add-submenu (&rest args) nil))
-	    )
-	(error nil)))
-  (condition-case nil
-      (if (fboundp 'zmacs-activate-region)
-	  nil ;; great
-	(defmacro zmacs-activate-region (&rest args) nil))
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'char-before)
-	  nil ;; great
-	(defmacro char-before (&rest body)
-	  (char-after (1- (point)))))
-    (error nil))
-  ;; Requires to define variables that would be "free" warnings
-  (condition-case nil
-      (require 'font-lock)
-    (error nil))
-  (condition-case nil
-      (require 'compile)
-    (error nil))
-  (condition-case nil
-      (require 'custom)
-    (error nil))
-  (condition-case nil
-      (require 'dinotrace)
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'dinotrace-unannotate-all)
-	  nil ;; great
-	(defun dinotrace-unannotate-all (&rest args) nil))
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'customize-apropos)
-	  nil ;; great
-	(defun customize-apropos (&rest args) nil))
-    (error nil))
-  (condition-case nil
-      (if (fboundp 'match-string-no-properties)
-	  nil ;; great
-	(defsubst match-string-no-properties (num &optional string)
-	  "Return string of text matched by last search, without text properties.
+  (when (featurep 'xemacs)
+    (condition-case nil
+        (require 'easymenu)
+      (error nil))
+    (condition-case nil
+        (require 'regexp-opt)
+      (error nil))
+    ;; Bug in 19.28 through 19.30 skeleton.el, not provided.
+    (condition-case nil
+        (load "skeleton")
+      (error nil))
+    (condition-case nil
+        (if (fboundp 'when)
+            nil ;; fab
+          (defmacro when (cond &rest body)
+            (list 'if cond (cons 'progn body))))
+      (error nil))
+    (condition-case nil
+        (if (fboundp 'unless)
+            nil ;; fab
+          (defmacro unless (cond &rest body)
+            (cons 'if (cons cond (cons nil body)))))
+      (error nil))
+    (condition-case nil
+        (if (fboundp 'store-match-data)
+            nil ;; fab
+          (defmacro store-match-data (&rest args) nil))
+      (error nil))
+    (condition-case nil
+        (if (boundp 'current-menubar)
+            nil ;; great
+          (progn
+            (defmacro add-submenu (&rest args) nil))
+          )
+      (error nil))
+    (condition-case nil
+        (if (fboundp 'char-before)
+            nil ;; great
+          (defmacro char-before (&rest body)
+            (char-after (1- (point)))))
+      (error nil))
+    (condition-case nil
+        (require 'custom)
+      (error nil))
+    (condition-case nil
+        (if (fboundp 'match-string-no-properties)
+            nil ;; great
+          (defsubst match-string-no-properties (num &optional string)
+            "Return string of text matched by last search, without text properties.
 NUM specifies which parenthesized expression in the last regexp.
  Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
 Zero means the entire text matched by the whole regexp or whole string.
 STRING should be given if the last search was by `string-match' on STRING."
-	  (if (match-beginning num)
-	      (if string
-		  (let ((result
-			 (substring string (match-beginning num) (match-end num))))
-		    (set-text-properties 0 (length result) nil result)
-		    result)
-		(buffer-substring-no-properties (match-beginning num)
-						(match-end num)
-						(current-buffer)
-						)))))
-    (error nil))
-  (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
-      nil ;; We've got what we needed
-    ;; We have the old custom-library, hack around it!
-    (defmacro defgroup (&rest args)  nil)
-    (defmacro customize (&rest args)
-      (message "Sorry, Customize is not available with this version of emacs"))
-    (defmacro defcustom (var value doc &rest args)
-      `(defvar ,var ,value ,doc))
-    )
-  (if (fboundp 'defface)
-      nil				; great!
-    (defmacro defface (var values doc &rest args)
-      `(make-face ,var))
-    )
-
-  (if (and (featurep 'custom) (fboundp 'customize-group))
-      nil ;; We've got what we needed
-    ;; We have an intermediate custom-library, hack around it!
-    (defmacro customize-group (var &rest args)
-      `(customize ,var))
-    )
-
-  )
+            (if (match-beginning num)
+                (if string
+                    (let ((result
+                           (substring string (match-beginning num) (match-end num))))
+                      (set-text-properties 0 (length result) nil result)
+                      result)
+                  (buffer-substring-no-properties (match-beginning num)
+                                                  (match-end num)
+                                                  (current-buffer)
+                                                  )))))
+      (error nil))
+    (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
+        nil ;; We've got what we needed
+      ;; We have the old custom-library, hack around it!
+      (defmacro defgroup (&rest args)  nil)
+      (defmacro customize (&rest args)
+        (message "Sorry, Customize is not available with this version of emacs"))
+      (defmacro defcustom (var value doc &rest args)
+        `(defvar ,var ,value ,doc))
+      )
+    (if (fboundp 'defface)
+        nil				; great!
+      (defmacro defface (var values doc &rest args)
+        `(make-face ,var))
+      )
+
+    (if (and (featurep 'custom) (fboundp 'customize-group))
+        nil ;; We've got what we needed
+      ;; We have an intermediate custom-library, hack around it!
+      (defmacro customize-group (var &rest args)
+        `(customize ,var))
+      )))
+
 ;; Provide a regular expression optimization routine, using regexp-opt
 ;; if provided by the user's elisp libraries
 (eval-and-compile
-  (if (fboundp 'regexp-opt)
-      ;; regexp-opt is defined, does it take 3 or 2 arguments?
-      (if (fboundp 'function-max-args)
-	  (let ((args (function-max-args `regexp-opt)))
-	    (cond 
-	     ((eq args 3) ;; It takes 3
-	      (condition-case nil	; Hide this defun from emacses
+  (if (featurep 'xemacs)
+      (if (fboundp 'regexp-opt)
+          ;; regexp-opt is defined, does it take 3 or 2 arguments?
+          (if (fboundp 'function-max-args)
+              (let ((args (function-max-args `regexp-opt)))
+                (cond
+                 ((eq args 3) ;; It takes 3
+                  (condition-case nil	; Hide this defun from emacses
 					;with just a two input regexp
-		  (defun verilog-regexp-opt (a b)
-		    "Deal with differing number of required arguments for  `regexp-opt'.
+                      (defun verilog-regexp-opt (a b)
+                        "Deal with differing number of required arguments for  `regexp-opt'.
          Call 'regexp-opt' on A and B."
-		    (regexp-opt a b 't)
-		    )
-		(error nil))
-	      )
-	      ((eq args 2) ;; It takes 2
-	      (defun verilog-regexp-opt (a b)
-		"Call 'regexp-opt' on A and B."
-		(regexp-opt a b))
-	      )
-	      (t nil)))
-	;; We can't tell; assume it takes 2
-	(defun verilog-regexp-opt (a b)
-	  "Call 'regexp-opt' on A and B."
-	  (regexp-opt a b))
-	)
-    ;; There is no regexp-opt, provide our own
-    (defun verilog-regexp-opt (strings &optional paren shy)
-      (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
-	(concat open (mapconcat 'regexp-quote strings "\\|") close)))
-    ))
+                        (regexp-opt a b 't)
+                        )
+                    (error nil))
+                  )
+                 ((eq args 2) ;; It takes 2
+                  (defun verilog-regexp-opt (a b)
+                    "Call 'regexp-opt' on A and B."
+                    (regexp-opt a b))
+                  )
+                 (t nil)))
+            ;; We can't tell; assume it takes 2
+            (defun verilog-regexp-opt (a b)
+              "Call 'regexp-opt' on A and B."
+              (regexp-opt a b))
+            )
+        ;; There is no regexp-opt, provide our own
+        (defun verilog-regexp-opt (strings &optional paren shy)
+          (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
+            (concat open (mapconcat 'regexp-quote strings "\\|") close)))
+        )
+    ;; Emacs.
+    (defalias 'verilog-regexp-opt 'regexp-opt)))
 
 (eval-when-compile
   (defun verilog-regexp-words (a)
@@ -287,7 +258,8 @@
 (defun verilog-font-customize ()
   "Link to customize fonts used for Verilog."
   (interactive)
-  (customize-apropos "font-lock-*" 'faces))
+  (if (fboundp 'customize-apropos)
+      (customize-apropos "font-lock-*" 'faces)))
 
 (defgroup verilog-mode nil
   "Facilitates easy editing of Verilog source text"
@@ -872,10 +844,14 @@
   "*Default name of Company for verilog header.
 If set will become buffer local.")
 
+(make-variable-buffer-local 'verilog-company)
+
 (defvar verilog-project nil
   "*Default name of Project for verilog header.
 If set will become buffer local.")
 
+(make-variable-buffer-local 'verilog-project)
+
 (defvar verilog-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map ";"        'electric-verilog-semi)
@@ -1685,10 +1661,10 @@
     ;; figure out version numbers if not already discovered
     (and (or (not major) (not minor))
 	 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
-	 (setq major (string-to-int (substring emacs-version
+	 (setq major (string-to-number (substring emacs-version
 					       (match-beginning 1)
 					       (match-end 1)))
-	       minor (string-to-int (substring emacs-version
+	       minor (string-to-number (substring emacs-version
 					       (match-beginning 2)
 					       (match-end 2)))))
     (if (not (and major minor))
@@ -1827,17 +1803,17 @@
 (defvar verilog-mode-syntax-table nil
   "Syntax table used in `verilog-mode' buffers.")
 
-(defconst verilog-font-lock-keywords nil
+(defvar verilog-font-lock-keywords nil
   "Default highlighting for Verilog mode.")
 
-(defconst verilog-font-lock-keywords-1 nil
+(defvar verilog-font-lock-keywords-1 nil
   "Subdued level highlighting for Verilog mode.")
 
-(defconst verilog-font-lock-keywords-2 nil
+(defvar verilog-font-lock-keywords-2 nil
   "Medium level highlighting for Verilog mode.
 See also `verilog-font-lock-extra-types'.")
 
-(defconst verilog-font-lock-keywords-3 nil
+(defvar verilog-font-lock-keywords-3 nil
   "Gaudy level highlighting for Verilog mode.
 See also `verilog-font-lock-extra-types'.")
 (defvar  verilog-font-lock-translate-off-face
@@ -2244,10 +2220,6 @@
 (defun verilog-declaration-beg ()
   (verilog-re-search-backward verilog-declaration-re (bobp) t))
 
-(require 'font-lock)
-(defvar verilog-need-fld 1)
-(defvar font-lock-defaults-alist nil)	;In case we are XEmacs
-
 (defun verilog-font-lock-init ()
   "Initialize fontification."
   ;; highlight keywords and standardized types, attributes, enumeration
@@ -2257,38 +2229,19 @@
 		(when verilog-highlight-translate-off
 		  (list
 		   ;; Fontify things in translate off regions
-		   '(verilog-match-translate-off (0 'verilog-font-lock-translate-off-face prepend))
-		   ))
-	)
-  )
+		   '(verilog-match-translate-off
+                     (0 'verilog-font-lock-translate-off-face prepend))
+		   ))))
   (put 'verilog-mode 'font-lock-defaults
        '((verilog-font-lock-keywords
 	  verilog-font-lock-keywords-1
 	  verilog-font-lock-keywords-2
-	  verilog-font-lock-keywords-3
-	  )
-	 nil ;; nil means highlight strings & comments as well as keywords
-	 nil ;; nil means keywords must match case
-	 nil ;; syntax table handled elsewhere
-	 verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight
-	 ))
-  (if verilog-need-fld
-      (let ((verilog-mode-defaults
-	     '((verilog-font-lock-keywords
-		verilog-font-lock-keywords-1
-		verilog-font-lock-keywords-2
-		verilog-font-lock-keywords-3
-		)
-	       nil ;; nil means highlight strings & comments as well as keywords
-	       nil ;; nil means keywords must match case
-	       nil ;; syntax table handled elsewhere
-	       verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight
-	       )))
-	(setq font-lock-defaults-alist
-	      (append
-	       font-lock-defaults-alist
-	       (list (cons 'verilog-mode  verilog-mode-defaults))))
-	(setq verilog-need-fld 0))))
+	  verilog-font-lock-keywords-3)
+	 nil ; nil means highlight strings & comments as well as keywords
+	 nil ; nil means keywords must match case
+	 nil ; syntax table handled elsewhere
+         ;; Function to move to beginning of reasonable region to highlight
+	 verilog-beg-of-defun)))
 
 ;; initialize fontification for Verilog Mode
 (verilog-font-lock-init)
@@ -2297,7 +2250,7 @@
   '("Please use \\[verilog-submit-bug-report] to report bugs."
     "Visit http://www.verilog.com to check for updates"
     ))
-(defconst verilog-startup-message-displayed t)
+(defvar verilog-startup-message-displayed t)
 (defun verilog-display-startup-message ()
   (if (not verilog-startup-message-displayed)
       (if (sit-for 5)
@@ -2486,15 +2439,20 @@
       (add-submenu nil verilog-stmt-menu)
       ))
   ;; Stuff for GNU emacs
-  (make-local-variable 'font-lock-defaults)
+  (set (make-local-variable 'font-lock-defaults)
+       '((verilog-font-lock-keywords verilog-font-lock-keywords-1
+                                     verilog-font-lock-keywords-2
+                                     verilog-font-lock-keywords-3)
+         nil nil nil verilog-beg-of-defun))
   ;;------------------------------------------------------------
   ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el)
   ;; all buffer local:
-  (make-local-hook 'font-lock-mode-hook)
-  (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
+  (when (featurep 'xemacs)
+    (make-local-hook 'font-lock-mode-hook)
+    (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
+    (make-local-hook 'after-change-functions))
   (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
   (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20
-  (make-local-hook 'after-change-functions)
   (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
 
   ;; Tell imenu how to handle verilog.
@@ -2535,7 +2493,7 @@
 	    (newline))
 	(progn
 	  (newline)
-	  (insert-string "// ")
+	  (insert "// ")
 	  (beginning-of-line)))
       (verilog-indent-line))
      ((nth 4 state)			; Inside any comment (hence /**/)
@@ -2785,7 +2743,8 @@
   (verilog-end-of-defun)
   (push-mark (point))
   (verilog-beg-of-defun)
-  (zmacs-activate-region))
+  (if (fboundp 'zmacs-activate-region)
+      (zmacs-activate-region)))
 
 (defun verilog-comment-region (start end)
   ; checkdoc-params: (start end)
@@ -3634,13 +3593,13 @@
 				(regexp-quote ket)
 				"\\(.*\\)$") signal-string)
 	  (let* ((sig-head (match-string 1 signal-string))
-		 (vec-start (string-to-int (match-string 2 signal-string)))
+		 (vec-start (string-to-number (match-string 2 signal-string)))
 		 (vec-end (if (= (match-beginning 3) (match-end 3))
 			      vec-start
-			    (string-to-int (substring signal-string (1+ (match-beginning 3)) (match-end 3)))))
+			    (string-to-number (substring signal-string (1+ (match-beginning 3)) (match-end 3)))))
 		 (vec-range (if (= (match-beginning 4) (match-end 4))
 				1
-			      (string-to-int (substring signal-string (+ 2 (match-beginning 4)) (match-end 4)))))
+			      (string-to-number (substring signal-string (+ 2 (match-beginning 4)) (match-end 4)))))
 		 (sig-tail (match-string 5 signal-string))
 		 vec)
 	    ;; Decode vectors
@@ -3777,15 +3736,15 @@
 	      (let ((lim (save-excursion (end-of-line) (point))))
 		(if (re-search-forward code lim 'move)
 		    (throw 'already t)
-		  (insert-string (concat " " code)))))
+		  (insert (concat " " code)))))
 	     (t
 	      )))
 	   ((verilog-in-star-comment-p)
 	    (re-search-backward "/\*")
-	    (insert-string (format " // surefire lint_off_line %6s" code ))
+	    (insert (format " // surefire lint_off_line %6s" code ))
 	    )
 	   (t
-	    (insert-string (format " // surefire lint_off_line %6s" code ))
+	    (insert (format " // surefire lint_off_line %6s" code ))
 	    )))))))
 
 (defun verilog-verilint-off ()
@@ -3839,12 +3798,12 @@
    ;; Make sure any sub-files we read get proper mode
    (setq default-major-mode `verilog-mode)
    ;; Ditto files already read in
-   (mapcar '(lambda (buf)
-	      (when (buffer-file-name buf)
-		(save-excursion
-		  (set-buffer buf)
-		  (verilog-mode))))
-	   (buffer-list))
+   (mapc (lambda (buf)
+           (when (buffer-file-name buf)
+             (save-excursion
+               (set-buffer buf)
+               (verilog-mode))))
+         (buffer-list))
    ;; Process the files
    (mapcar '(lambda (buf)
 	      (when (buffer-file-name buf)
@@ -5861,12 +5820,10 @@
       (search-forward "<title>")
       (replace-match string t t)
       (setq string (read-string "project: " verilog-project))
-      (make-variable-buffer-local 'verilog-project)
       (setq verilog-project string)
       (search-forward "<project>")
       (replace-match string t t)
       (setq string (read-string "Company: " verilog-company))
-      (make-variable-buffer-local 'verilog-company)
       (setq verilog-company string)
       (search-forward "<company>")
       (replace-match string t t)
@@ -6021,10 +5978,10 @@
       (setq bus (verilog-sig-bits sig))
       (cond ((and bus
 		  (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus)
-			   (setq highbit (string-to-int (match-string 1 bus))
-				 lowbit  (string-to-int (match-string 2 bus))))
+			   (setq highbit (string-to-number (match-string 1 bus))
+				 lowbit  (string-to-number (match-string 2 bus))))
 		      (and (string-match "\\[\\([0-9]+\\)\\]" bus)
-			   (setq highbit (string-to-int (match-string 1 bus))
+			   (setq highbit (string-to-number (match-string 1 bus))
 				 lowbit  highbit))))
 	     ;; Combine bits in bus
 	     (if sv-highbit
@@ -6292,9 +6249,44 @@
 	      (nreverse sigs-gparam)
 	      ))))
 
-(defvar sigs-in nil) ; Prevent compile warning
-(defvar sigs-inout nil) ; Prevent compile warning
-(defvar sigs-out nil) ; Prevent compile warning
+(defvar sigs-in)                        ; Prevent compile warning
+(defvar sigs-inout)                     ; Prevent compile warning
+(defvar sigs-out)                       ; Prevent compile warning
+
+
+(defsubst verilog-modi-get-decls (modi)
+  (verilog-modi-cache-results modi 'verilog-read-decls))
+
+(defsubst verilog-modi-get-sub-decls (modi)
+  (verilog-modi-cache-results modi 'verilog-read-sub-decls))
+
+
+;; Signal reading for given module
+;; Note these all take modi's - as returned from the
+;; verilog-modi-current function.
+(defsubst verilog-modi-get-outputs (modi)
+  (aref (verilog-modi-get-decls modi) 0))
+(defsubst verilog-modi-get-inouts (modi)
+  (aref (verilog-modi-get-decls modi) 1))
+(defsubst verilog-modi-get-inputs (modi)
+  (aref (verilog-modi-get-decls modi) 2))
+(defsubst verilog-modi-get-wires (modi)
+  (aref (verilog-modi-get-decls modi) 3))
+(defsubst verilog-modi-get-regs (modi)
+  (aref (verilog-modi-get-decls modi) 4))
+(defsubst verilog-modi-get-assigns (modi)
+  (aref (verilog-modi-get-decls modi) 5))
+(defsubst verilog-modi-get-consts (modi)
+  (aref (verilog-modi-get-decls modi) 6))
+(defsubst verilog-modi-get-gparams (modi)
+  (aref (verilog-modi-get-decls modi) 7))
+(defsubst verilog-modi-get-sub-outputs (modi)
+  (aref (verilog-modi-get-sub-decls modi) 0))
+(defsubst verilog-modi-get-sub-inouts (modi)
+  (aref (verilog-modi-get-sub-decls modi) 1))
+(defsubst verilog-modi-get-sub-inputs (modi)
+  (aref (verilog-modi-get-sub-decls modi) 2))
+
 
 (defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim)
   "For verilog-read-sub-decls-line, add a signal."
@@ -6506,11 +6498,10 @@
 	     (end-pt (point)))
 	(eval-region beg-pt end-pt nil)))))
 
-(eval-when-compile
-  ;; These are passed in a let, not global
-  (if (not (boundp 'sigs-in))
-      (defvar sigs-in nil) (defvar sigs-out nil)
-      (defvar got-sig nil) (defvar got-rvalue nil) (defvar uses-delayed nil)))
+;; These are passed in a let, not global
+(defvar got-sig)
+(defvar got-rvalue)
+(defvar uses-delayed)
 
 (defun verilog-read-always-signals-recurse
   (exit-keywd rvalue ignore-next)
@@ -7033,10 +7024,10 @@
   "Convert `verilog-library-flags' into standard library variables."
   ;; If the flags are local, then all the outputs should be local also
   (when (local-variable-p `verilog-library-flags (current-buffer))
-    (make-variable-buffer-local 'verilog-library-extensions)
-    (make-variable-buffer-local 'verilog-library-directories)
-    (make-variable-buffer-local 'verilog-library-files)
-    (make-variable-buffer-local 'verilog-library-flags))
+    (mapc 'make-local-variable '(verilog-library-extensions
+                                 verilog-library-directories
+                                 verilog-library-files
+                                 verilog-library-flags)))
   ;; Allow user to customize
   (run-hooks 'verilog-before-getopt-flags-hook)
   ;; Process arguments
@@ -7061,11 +7052,8 @@
   "Return point if MODULE is specified inside FILENAME, else nil.
 Allows version control to check out the file if need be."
   (and (or (file-exists-p filename)
-	   (and
-	    (condition-case nil
-		(fboundp 'vc-backend)
-	      (error nil))
-	    (vc-backend filename)))
+	   (and (fboundp 'vc-backend)
+		(vc-backend filename)))
        (let (pt)
 	 (save-excursion
 	   (set-buffer (find-file-noselect filename))
@@ -7224,6 +7212,8 @@
 For speeding up verilog-modi-get-* commands.
 Buffer-local.")
 
+(make-variable-buffer-local 'verilog-modi-cache-list)
+
 (defvar verilog-modi-cache-preserve-tick nil
   "Modification tick after which the cache is still considered valid.
 Use verilog-preserve-cache's to set")
@@ -7349,7 +7339,6 @@
 	       (setq func-returns (funcall function))
 	       (when fontlocked (font-lock-mode t)))
 	     ;; Cache for next time
-	     (make-variable-buffer-local 'verilog-modi-cache-list)
 	     (setq verilog-modi-cache-list
 		   (cons (list (list (verilog-modi-name modi) function)
 			       (buffer-modified-tick)
@@ -7384,37 +7373,6 @@
 	 (verilog-modi-cache-preserve-buffer (current-buffer)))
      (progn ,@body)))
 
-(defsubst verilog-modi-get-decls (modi)
-  (verilog-modi-cache-results modi 'verilog-read-decls))
-
-(defsubst verilog-modi-get-sub-decls (modi)
-  (verilog-modi-cache-results modi 'verilog-read-sub-decls))
-
-;; Signal reading for given module
-;; Note these all take modi's - as returned from the verilog-modi-current function
-(defsubst verilog-modi-get-outputs (modi)
-  (aref (verilog-modi-get-decls modi) 0))
-(defsubst verilog-modi-get-inouts (modi)
-  (aref (verilog-modi-get-decls modi) 1))
-(defsubst verilog-modi-get-inputs (modi)
-  (aref (verilog-modi-get-decls modi) 2))
-(defsubst verilog-modi-get-wires (modi)
-  (aref (verilog-modi-get-decls modi) 3))
-(defsubst verilog-modi-get-regs (modi)
-  (aref (verilog-modi-get-decls modi) 4))
-(defsubst verilog-modi-get-assigns (modi)
-  (aref (verilog-modi-get-decls modi) 5))
-(defsubst verilog-modi-get-consts (modi)
-  (aref (verilog-modi-get-decls modi) 6))
-(defsubst verilog-modi-get-gparams (modi)
-  (aref (verilog-modi-get-decls modi) 7))
-(defsubst verilog-modi-get-sub-outputs (modi)
-  (aref (verilog-modi-get-sub-decls modi) 0))
-(defsubst verilog-modi-get-sub-inouts (modi)
-  (aref (verilog-modi-get-sub-decls modi) 1))
-(defsubst verilog-modi-get-sub-inputs (modi)
-  (aref (verilog-modi-get-sub-decls modi) 2))
-
 
 (defun verilog-signals-matching-enum (in-list enum)
   "Return all signals in IN-LIST matching the given ENUM."
@@ -7604,8 +7562,8 @@
 	 (cond ((not range-exp)
 		"1")
 	       ((string-match "^\\s *\\([0-9]+\\)\\s *:\\s *\\([0-9]+\\)\\s *$" range-exp)
-		(int-to-string (1+ (abs (- (string-to-int (match-string 1 range-exp))
-					   (string-to-int (match-string 2 range-exp)))))))
+		(int-to-string (1+ (abs (- (string-to-number (match-string 1 range-exp))
+					   (string-to-number (match-string 2 range-exp)))))))
 	       ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp)
 		(concat "(1+(" (match-string 1 range-exp)
 			")"
@@ -7928,7 +7886,7 @@
 (defun verilog-auto-reeval-locals (&optional force)
   "Read file local variable segment at bottom of file if it has changed.
 If FORCE, always reread it."
-  (make-variable-buffer-local 'verilog-auto-last-file-locals)
+  (make-local-variable 'verilog-auto-last-file-locals)
   (let ((curlocal (verilog-auto-read-locals)))
     (when (or force (not (equal verilog-auto-last-file-locals curlocal)))
       (setq verilog-auto-last-file-locals curlocal)
@@ -8435,10 +8393,12 @@
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
 	    (indent-to indent-pt)
-	    (insert "// Outputs\n")	;; Note these are searched for in verilog-read-sub-decls
-	    (mapcar (function (lambda (port)
-				(verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
-		    sig-list)))
+            ;; Note these are searched for in verilog-read-sub-decls.
+	    (insert "// Outputs\n")
+	    (mapc (lambda (port)
+                    (verilog-auto-inst-port port indent-pt
+                                            tpl-list tpl-num for-star))
+                  sig-list)))
 	(let ((sig-list (verilog-signals-not-in
 			 (verilog-modi-get-inouts submodi)
 			 skip-pins))
@@ -8447,9 +8407,10 @@
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
 	    (indent-to indent-pt)
 	    (insert "// Inouts\n")
-	    (mapcar (function (lambda (port)
-				(verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
-		    sig-list)))
+	    (mapc (lambda (port)
+                    (verilog-auto-inst-port port indent-pt
+                                            tpl-list tpl-num for-star))
+                  sig-list)))
 	(let ((sig-list (verilog-signals-not-in
 			 (verilog-modi-get-inputs submodi)
 			 skip-pins))
@@ -8458,9 +8419,10 @@
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
 	    (indent-to indent-pt)
 	    (insert "// Inputs\n")
-	    (mapcar (function (lambda (port)
-				(verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
-		    sig-list)))
+	    (mapc (lambda (port)
+                    (verilog-auto-inst-port port indent-pt
+                                            tpl-list tpl-num for-star))
+                  sig-list)))
 	;; Kill extra semi
 	(save-excursion
 	  (cond (did-first
@@ -8561,10 +8523,12 @@
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
 	    (indent-to indent-pt)
-	    (insert "// Parameters\n")	;; Note these are searched for in verilog-read-sub-decls
-	    (mapcar (function (lambda (port)
-				(verilog-auto-inst-port port indent-pt tpl-list tpl-num nil)))
-		    sig-list)))
+            ;; Note these are searched for in verilog-read-sub-decls.
+	    (insert "// Parameters\n")
+	    (mapc (lambda (port)
+                    (verilog-auto-inst-port port indent-pt
+                                            tpl-list tpl-num nil))
+                  sig-list)))
 	;; Kill extra semi
 	(save-excursion
 	  (cond (did-first
@@ -9569,9 +9533,9 @@
     (goto-char (point-min))
     (while (re-search-forward " Templated T\\([0-9]+\\) L\\([0-9]+\\)" nil t)
       (replace-match (concat " Templated "
-			     (int-to-string (+ (nth (string-to-int (match-string 1))
+			     (int-to-string (+ (nth (string-to-number (match-string 1))
 						    template-line)
-					       (string-to-int (match-string 2)))))
+					       (string-to-number (match-string 2)))))
 		     t t))))
 
 
@@ -9636,7 +9600,7 @@
 Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com."
   (interactive)
   (unless noninteractive (message "Updating AUTOs..."))
-  (if (featurep 'dinotrace)
+  (if (fboundp 'dinotrace-unannotate-all)
       (dinotrace-unannotate-all))
   (let ((oldbuf (if (not (buffer-modified-p))
 		    (buffer-string)))
@@ -9790,7 +9754,7 @@
 (defvar verilog-sk-reset nil)
 (defun verilog-sk-prompt-reset ()
   "Prompt for the name of a state machine reset."
-  (setq verilog-sk-reset (read-input "name of reset: " "rst")))
+  (setq verilog-sk-reset (read-string "name of reset: " "rst")))
 
 
 (define-skeleton verilog-sk-prompt-state-selector
@@ -10235,6 +10199,8 @@
     (princ "To submit a bug, use M-x verilog-submit-bug-report\n")
     (princ "\n")))
 
+(autoload 'reporter-submit-bug-report "reporter")
+
 (defun verilog-submit-bug-report ()
   "Submit via mail a bug report on verilog-mode.el."
   (interactive)