diff options
| author | Wilson Snyder | 2017-09-07 23:24:28 -0400 |
|---|---|---|
| committer | Wilson Snyder | 2017-09-07 23:24:28 -0400 |
| commit | 442fe111436264e1a610fbf5686ccf1314407d4a (patch) | |
| tree | 4e802e7e8afc66397aa667d523d0f8f963cf2a3c | |
| parent | 9546e1eba584a0c86002ba87c65dd88eff5290ab (diff) | |
| download | emacs-442fe111436264e1a610fbf5686ccf1314407d4a.tar.gz emacs-442fe111436264e1a610fbf5686ccf1314407d4a.zip | |
Fix various verilog-mode.el issues.
* lisp/progmodes/verilog-mode.el (verilog-expand-dirnames): Fix expanding
"*/*", msg2284. Reported by Jonathan Ferguson.
(ignore-errors): Fix ignore-errors error on Emacs 22.3, bug1177. Reported
by Victor Lau.
(verilog-getopt, verilog-getopt-file) (verilog-library-flags,
verilog-substitute-file-name-path): Support -F in verilog getopt files,
bug1171. Reported by George Cuan.
(verilog-do-indent): Fix misindenting symbols starting with t,
bug1169. Reported by Hoai Tran.
(verilog-read-auto-template-middle): Fix slow template matching on
AUTOINST. Reported by Jeffrey Huynh.
(verilog-pretty-expr): The extra whitespace addition before "=" operators
is now done only if the whole assignment block contains the 2-character
"<=" operator. Remove the unused argument _myre. Use `unless',
`save-excursion' and `when' functions where possible. Internal variables
refactored for clarity. Follow elisp convention for closing parentheses.
By Kaushal Modi.
(verilog-get-lineup-indent-2): Update docstring. Internal variables
refactored for clarity. Earlier EDPOS argument was expected to be a
marker; it is now renamed to END and is now expected to be a position.
Use `when' instead of `if'. By Kaushal Modi.
(electric-verilog-terminate-line): Remove the unused second argument from
`verilog-pretty-expr' call. By Kaushal Modi.
(verilog-calc-1): Fix indentation of a virtual class definition after a
typedef class, bug1080. By Kaushal Modi.
| -rw-r--r-- | lisp/progmodes/verilog-mode.el | 364 |
1 files changed, 191 insertions, 173 deletions
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 2760c4d276e..6e79b1a63df 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Michael McNamara <mac@verilog.com> | 5 | ;; Author: Michael McNamara <mac@verilog.com> |
| 6 | ;; Wilson Snyder <wsnyder@wsnyder.org> | 6 | ;; Wilson Snyder <wsnyder@wsnyder.org> |
| 7 | ;; X-URL: http://www.verilog.com | ||
| 8 | ;; X-URL: http://www.veripool.org | 7 | ;; X-URL: http://www.veripool.org |
| 9 | ;; Created: 3 Jan 1996 | 8 | ;; Created: 3 Jan 1996 |
| 10 | ;; Keywords: languages | 9 | ;; Keywords: languages |
| @@ -70,7 +69,7 @@ | |||
| 70 | ;; default. | 69 | ;; default. |
| 71 | 70 | ||
| 72 | ;; You can get step by step help in installing this file by going to | 71 | ;; You can get step by step help in installing this file by going to |
| 73 | ;; <http://www.verilog.com/emacs_install.html> | 72 | ;; <http://www.veripool.com/verilog-mode> |
| 74 | 73 | ||
| 75 | ;; The short list of installation instructions are: To set up | 74 | ;; The short list of installation instructions are: To set up |
| 76 | ;; automatic Verilog mode, put this file in your load path, and put | 75 | ;; automatic Verilog mode, put this file in your load path, and put |
| @@ -123,7 +122,7 @@ | |||
| 123 | ;; | 122 | ;; |
| 124 | 123 | ||
| 125 | ;; This variable will always hold the version number of the mode | 124 | ;; This variable will always hold the version number of the mode |
| 126 | (defconst verilog-mode-version "2017-05-08-b240c8f-vpo-GNU" | 125 | (defconst verilog-mode-version "2017-08-07-c085e50-vpo-GNU" |
| 127 | "Version of this Verilog mode.") | 126 | "Version of this Verilog mode.") |
| 128 | (defconst verilog-mode-release-emacs t | 127 | (defconst verilog-mode-release-emacs t |
| 129 | "If non-nil, this version of Verilog mode was released with Emacs itself.") | 128 | "If non-nil, this version of Verilog mode was released with Emacs itself.") |
| @@ -345,6 +344,12 @@ wherever possible, since it is slow." | |||
| 345 | (unless (fboundp 'buffer-chars-modified-tick) ; Emacs 22 added | 344 | (unless (fboundp 'buffer-chars-modified-tick) ; Emacs 22 added |
| 346 | (defmacro buffer-chars-modified-tick () (buffer-modified-tick))) | 345 | (defmacro buffer-chars-modified-tick () (buffer-modified-tick))) |
| 347 | (error nil)) | 346 | (error nil)) |
| 347 | ;; Added in Emacs 23.1 | ||
| 348 | (condition-case nil | ||
| 349 | (unless (fboundp 'ignore-errors) | ||
| 350 | (defmacro ignore-errors (&rest body) | ||
| 351 | (declare (debug t) (indent 0)) | ||
| 352 | `(condition-case nil (progn ,@body) (error nil))))) | ||
| 348 | ;; Added in Emacs 24.1 | 353 | ;; Added in Emacs 24.1 |
| 349 | (condition-case nil | 354 | (condition-case nil |
| 350 | (unless (fboundp 'prog-mode) | 355 | (unless (fboundp 'prog-mode) |
| @@ -961,7 +966,8 @@ Only used in XEmacs; GNU Emacs uses `verilog-error-regexp-emacs-alist'.") | |||
| 961 | These arguments are used to find files for `verilog-auto', and match | 966 | These arguments are used to find files for `verilog-auto', and match |
| 962 | the flags accepted by a standard Verilog-XL simulator. | 967 | the flags accepted by a standard Verilog-XL simulator. |
| 963 | 968 | ||
| 964 | -f filename Reads more `verilog-library-flags' from the filename. | 969 | -f filename Reads absolute `verilog-library-flags' from the filename. |
| 970 | -F filename Reads relative `verilog-library-flags' from the filename. | ||
| 965 | +incdir+dir Adds the directory to `verilog-library-directories'. | 971 | +incdir+dir Adds the directory to `verilog-library-directories'. |
| 966 | -Idir Adds the directory to `verilog-library-directories'. | 972 | -Idir Adds the directory to `verilog-library-directories'. |
| 967 | -y dir Adds the directory to `verilog-library-directories'. | 973 | -y dir Adds the directory to `verilog-library-directories'. |
| @@ -4034,7 +4040,7 @@ With optional ARG, remove existing end of line comments." | |||
| 4034 | (progn | 4040 | (progn |
| 4035 | (if (or (eq 'all verilog-auto-lineup) | 4041 | (if (or (eq 'all verilog-auto-lineup) |
| 4036 | (eq 'assignments verilog-auto-lineup)) | 4042 | (eq 'assignments verilog-auto-lineup)) |
| 4037 | (verilog-pretty-expr t "\\(<\\|:\\)?=" )) | 4043 | (verilog-pretty-expr :quiet)) |
| 4038 | (newline)) | 4044 | (newline)) |
| 4039 | (forward-line 1)) | 4045 | (forward-line 1)) |
| 4040 | ;; Indent next line | 4046 | ;; Indent next line |
| @@ -5790,11 +5796,9 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5790 | (goto-char here) ; or is clocking, starts a new block | 5796 | (goto-char here) ; or is clocking, starts a new block |
| 5791 | (throw 'nesting 'block))))) | 5797 | (throw 'nesting 'block))))) |
| 5792 | 5798 | ||
| 5793 | ;; need to consider typedef struct here... | ||
| 5794 | ((looking-at "\\<class\\|struct\\|function\\|task\\>") | 5799 | ((looking-at "\\<class\\|struct\\|function\\|task\\>") |
| 5795 | ;; *sigh* These words have an optional prefix: | 5800 | ;; *sigh* These words have an optional prefix: |
| 5796 | ;; extern {virtual|protected}? function a(); | 5801 | ;; extern {virtual|protected}? function a(); |
| 5797 | ;; typedef class foo; | ||
| 5798 | ;; and we don't want to confuse this with | 5802 | ;; and we don't want to confuse this with |
| 5799 | ;; function a(); | 5803 | ;; function a(); |
| 5800 | ;; property | 5804 | ;; property |
| @@ -5804,7 +5808,11 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5804 | (cond | 5808 | (cond |
| 5805 | ((looking-at verilog-dpi-import-export-re) | 5809 | ((looking-at verilog-dpi-import-export-re) |
| 5806 | (throw 'continue 'foo)) | 5810 | (throw 'continue 'foo)) |
| 5807 | ((looking-at "\\<pure\\>\\s-+\\<virtual\\>\\s-+\\(?:\\<\\(local\\|protected\\|static\\)\\>\\s-+\\)?\\<\\(function\\|task\\)\\>\\s-+") | 5811 | ((or |
| 5812 | (looking-at "\\<pure\\>\\s-+\\<virtual\\>\\s-+\\(?:\\<\\(local\\|protected\\|static\\)\\>\\s-+\\)?\\<\\(function\\|task\\)\\>\\s-+") | ||
| 5813 | ;; Do not throw 'defun for class typedefs like | ||
| 5814 | ;; typedef class foo; | ||
| 5815 | (looking-at "\\<typedef\\>\\s-+\\(?:\\<virtual\\>\\s-+\\)?\\<class\\>\\s-+")) | ||
| 5808 | (throw 'nesting 'statement)) | 5816 | (throw 'nesting 'statement)) |
| 5809 | ((looking-at verilog-beg-block-re-ordered) | 5817 | ((looking-at verilog-beg-block-re-ordered) |
| 5810 | (throw 'nesting 'block)) | 5818 | (throw 'nesting 'block)) |
| @@ -6660,7 +6668,7 @@ Only look at a few lines to determine indent level." | |||
| 6660 | (let ((val)) | 6668 | (let ((val)) |
| 6661 | (verilog-beg-of-statement-1) | 6669 | (verilog-beg-of-statement-1) |
| 6662 | (if (and (< (point) here) | 6670 | (if (and (< (point) here) |
| 6663 | (verilog-re-search-forward "=[ \\t]*" here 'move) | 6671 | (verilog-re-search-forward "=[ \t]*" here 'move) |
| 6664 | ;; not at a |=>, #=#, or [=n] operator | 6672 | ;; not at a |=>, #=#, or [=n] operator |
| 6665 | (not (string-match "\\[=.\\|#=#\\||=>" | 6673 | (not (string-match "\\[=.\\|#=#\\||=>" |
| 6666 | (or (buffer-substring (- (point) 2) (1+ (point))) | 6674 | (or (buffer-substring (- (point) 2) (1+ (point))) |
| @@ -6974,106 +6982,97 @@ Be verbose about progress unless optional QUIET set." | |||
| 6974 | (forward-line 1)) | 6982 | (forward-line 1)) |
| 6975 | (unless quiet (message ""))))))) | 6983 | (unless quiet (message ""))))))) |
| 6976 | 6984 | ||
| 6977 | (defun verilog-pretty-expr (&optional quiet _myre) | 6985 | (defun verilog-pretty-expr (&optional quiet) |
| 6978 | "Line up expressions around point, optionally QUIET with regexp _MYRE ignored." | 6986 | "Line up expressions around point. |
| 6987 | If QUIET is non-nil, do not print messages showing the progress of line-up." | ||
| 6979 | (interactive) | 6988 | (interactive) |
| 6980 | (if (not (verilog-in-comment-or-string-p)) | 6989 | (unless (verilog-in-comment-or-string-p) |
| 6981 | (save-excursion | 6990 | (save-excursion |
| 6982 | (let ( (rexp (concat "^\\s-*" verilog-complete-reg)) | 6991 | (let ((regexp (concat "^\\s-*" verilog-complete-reg)) |
| 6983 | (rexp1 (concat "^\\s-*" verilog-basic-complete-re))) | 6992 | (regexp1 (concat "^\\s-*" verilog-basic-complete-re))) |
| 6984 | (beginning-of-line) | 6993 | (beginning-of-line) |
| 6985 | (if (and (not (looking-at rexp )) | 6994 | (when (and (not (looking-at regexp)) |
| 6986 | (looking-at verilog-assignment-operation-re) | 6995 | (looking-at verilog-assignment-operation-re) |
| 6987 | (save-excursion | 6996 | (save-excursion |
| 6988 | (goto-char (match-end 2)) | 6997 | (goto-char (match-end 2)) |
| 6989 | (and (not (verilog-in-attribute-p)) | 6998 | (and (not (verilog-in-attribute-p)) |
| 6990 | (not (verilog-in-parameter-p)) | 6999 | (not (verilog-in-parameter-p)) |
| 6991 | (not (verilog-in-comment-or-string-p))))) | 7000 | (not (verilog-in-comment-or-string-p))))) |
| 6992 | (let* ((here (point)) | 7001 | (let* ((start (save-excursion ; BOL of the first line of the assignment block |
| 6993 | (e) (r) | ||
| 6994 | (start | ||
| 6995 | (progn | ||
| 6996 | (beginning-of-line) | ||
| 6997 | (setq e (point)) | ||
| 6998 | (verilog-backward-syntactic-ws) | ||
| 6999 | (beginning-of-line) | ||
| 7000 | (while (and (not (looking-at rexp1)) | ||
| 7001 | (looking-at verilog-assignment-operation-re) | ||
| 7002 | (not (bobp)) | ||
| 7003 | ) | ||
| 7004 | (setq e (point)) | ||
| 7005 | (verilog-backward-syntactic-ws) | ||
| 7006 | (beginning-of-line) | 7002 | (beginning-of-line) |
| 7007 | ) ;Ack, need to grok `define | 7003 | (let ((pt (point))) |
| 7008 | e)) | 7004 | (verilog-backward-syntactic-ws) |
| 7009 | (end | 7005 | (beginning-of-line) |
| 7010 | (progn | 7006 | (while (and (not (looking-at regexp1)) |
| 7011 | (goto-char here) | 7007 | (looking-at verilog-assignment-operation-re) |
| 7008 | (not (bobp))) | ||
| 7009 | (setq pt (point)) | ||
| 7010 | (verilog-backward-syntactic-ws) | ||
| 7011 | (beginning-of-line)) ; Ack, need to grok `define | ||
| 7012 | pt))) | ||
| 7013 | (end (save-excursion ; EOL of the last line of the assignment block | ||
| 7012 | (end-of-line) | 7014 | (end-of-line) |
| 7013 | (setq e (point)) ;Might be on last line | 7015 | (let ((pt (point))) ; Might be on last line |
| 7014 | (verilog-forward-syntactic-ws) | ||
| 7015 | (beginning-of-line) | ||
| 7016 | (while (and | ||
| 7017 | (not (looking-at rexp1 )) | ||
| 7018 | (looking-at verilog-assignment-operation-re) | ||
| 7019 | (progn | ||
| 7020 | (end-of-line) | ||
| 7021 | (not (eq e (point))))) | ||
| 7022 | (setq e (point)) | ||
| 7023 | (verilog-forward-syntactic-ws) | 7016 | (verilog-forward-syntactic-ws) |
| 7024 | (beginning-of-line) | 7017 | (beginning-of-line) |
| 7025 | ) | 7018 | (while (and |
| 7026 | e)) | 7019 | (not (looking-at regexp1)) |
| 7027 | (endpos (set-marker (make-marker) end)) | 7020 | (looking-at verilog-assignment-operation-re) |
| 7028 | (ind) | 7021 | (progn |
| 7029 | ) | 7022 | (end-of-line) |
| 7030 | (goto-char start) | 7023 | (not (eq pt (point))))) |
| 7031 | (verilog-do-indent (verilog-calculate-indent)) | 7024 | (setq pt (point)) |
| 7032 | (if (and (not quiet) | 7025 | (verilog-forward-syntactic-ws) |
| 7033 | (> (- end start) 100)) | 7026 | (beginning-of-line)) |
| 7034 | (message "Lining up expressions..(please stand by)")) | 7027 | pt))) |
| 7035 | 7028 | (contains-2-char-operator (string-match "<=" (buffer-substring-no-properties start end))) | |
| 7036 | ;; Set indent to minimum throughout region | 7029 | (endmark (set-marker (make-marker) end))) |
| 7037 | (while (< (point) (marker-position endpos)) | 7030 | (goto-char start) |
| 7038 | (beginning-of-line) | 7031 | (verilog-do-indent (verilog-calculate-indent)) |
| 7039 | (verilog-just-one-space verilog-assignment-operation-re) | 7032 | (when (and (not quiet) |
| 7040 | (beginning-of-line) | 7033 | (> (- end start) 100)) |
| 7041 | (verilog-do-indent (verilog-calculate-indent)) | 7034 | (message "Lining up expressions.. (please stand by)")) |
| 7042 | (end-of-line) | 7035 | |
| 7043 | (verilog-forward-syntactic-ws) | 7036 | ;; Set indent to minimum throughout region |
| 7044 | ) | 7037 | ;; Rely on mark rather than on point as the indentation changes can |
| 7045 | 7038 | ;; make the older point reference obsolete | |
| 7046 | ;; Now find biggest prefix | 7039 | (while (< (point) (marker-position endmark)) |
| 7047 | (setq ind (verilog-get-lineup-indent-2 verilog-assignment-operation-re start endpos)) | 7040 | (beginning-of-line) |
| 7048 | 7041 | (save-excursion | |
| 7049 | ;; Now indent each line. | 7042 | (verilog-just-one-space verilog-assignment-operation-re)) |
| 7050 | (goto-char start) | 7043 | (verilog-do-indent (verilog-calculate-indent)) |
| 7051 | (while (progn (setq e (marker-position endpos)) | 7044 | (end-of-line) |
| 7052 | (setq r (- e (point))) | 7045 | (verilog-forward-syntactic-ws)) |
| 7053 | (> r 0)) | 7046 | |
| 7054 | (setq e (point)) | 7047 | (let ((ind (verilog-get-lineup-indent-2 verilog-assignment-operation-re start (marker-position endmark))) ; Find the biggest prefix |
| 7055 | (if (not quiet) (message "%d" r)) | 7048 | e) |
| 7056 | (cond | 7049 | ;; Now indent each line. |
| 7057 | ((looking-at verilog-assignment-operation-re) | 7050 | (goto-char start) |
| 7058 | (goto-char (match-beginning 2)) | 7051 | (while (progn |
| 7059 | (if (not (or (verilog-in-parenthesis-p) ; leave attributes and comparisons alone | 7052 | (setq e (marker-position endmark)) |
| 7060 | (verilog-in-coverage-p))) | 7053 | (> e (point))) |
| 7061 | (if (eq (char-after) ?=) | 7054 | (unless quiet |
| 7062 | (indent-to (1+ ind)) ; line up the = of the <= with surrounding = | 7055 | (message " verilog-pretty-expr: %d" (- e (point)))) |
| 7063 | (indent-to ind) | 7056 | (setq e (point)) |
| 7064 | )) | 7057 | (cond |
| 7065 | ) | 7058 | ((looking-at verilog-assignment-operation-re) |
| 7066 | ((verilog-continued-line-1 start) | 7059 | (goto-char (match-beginning 2)) |
| 7067 | (goto-char e) | 7060 | (unless (or (verilog-in-parenthesis-p) ; Leave attributes and comparisons alone |
| 7068 | (indent-line-to ind)) | 7061 | (verilog-in-coverage-p)) |
| 7069 | (t ; Must be comment or white space | 7062 | (if (and contains-2-char-operator |
| 7070 | (goto-char e) | 7063 | (eq (char-after) ?=)) |
| 7071 | (verilog-forward-ws&directives) | 7064 | (indent-to (1+ ind)) ; Line up the = of the <= with surrounding = |
| 7072 | (forward-line -1)) | 7065 | (indent-to ind)))) |
| 7073 | ) | 7066 | ((verilog-continued-line-1 start) |
| 7074 | (forward-line 1)) | 7067 | (goto-char e) |
| 7075 | (unless quiet (message "")) | 7068 | (indent-line-to ind)) |
| 7076 | )))))) | 7069 | (t ; Must be comment or white space |
| 7070 | (goto-char e) | ||
| 7071 | (verilog-forward-ws&directives) | ||
| 7072 | (forward-line -1))) | ||
| 7073 | (forward-line 1)) | ||
| 7074 | (unless quiet | ||
| 7075 | (message ""))))))))) | ||
| 7077 | 7076 | ||
| 7078 | (defun verilog-just-one-space (myre) | 7077 | (defun verilog-just-one-space (myre) |
| 7079 | "Remove extra spaces around regular expression MYRE." | 7078 | "Remove extra spaces around regular expression MYRE." |
| @@ -7180,30 +7179,30 @@ Region is defined by B and EDPOS." | |||
| 7180 | ;;(skip-chars-backward " \t") | 7179 | ;;(skip-chars-backward " \t") |
| 7181 | (1+ (current-column)))))) | 7180 | (1+ (current-column)))))) |
| 7182 | 7181 | ||
| 7183 | (defun verilog-get-lineup-indent-2 (myre b edpos) | 7182 | (defun verilog-get-lineup-indent-2 (regexp beg end) |
| 7184 | "Return the indent level that will line up several lines within the region." | 7183 | "Return the indent level that will line up several lines. |
| 7184 | The lineup string is searched using REGEXP within the region between points | ||
| 7185 | BEG and END." | ||
| 7185 | (save-excursion | 7186 | (save-excursion |
| 7186 | (let ((ind 0) e) | 7187 | (let ((ind 0)) |
| 7187 | (goto-char b) | 7188 | (goto-char beg) |
| 7188 | ;; Get rightmost position | 7189 | ;; Get rightmost position |
| 7189 | (while (progn (setq e (marker-position edpos)) | 7190 | (while (< (point) end) |
| 7190 | (< (point) e)) | 7191 | (when (and (verilog-re-search-forward regexp end 'move) |
| 7191 | (if (and (verilog-re-search-forward myre e 'move) | 7192 | (not (verilog-in-attribute-p))) ; skip attribute exprs |
| 7192 | (not (verilog-in-attribute-p))) ; skip attribute exprs | 7193 | (goto-char (match-beginning 2)) |
| 7193 | (progn | 7194 | (verilog-backward-syntactic-ws) |
| 7194 | (goto-char (match-beginning 2)) | 7195 | (if (> (current-column) ind) |
| 7195 | (verilog-backward-syntactic-ws) | 7196 | (setq ind (current-column))) |
| 7196 | (if (> (current-column) ind) | 7197 | (goto-char (match-end 0)))) |
| 7197 | (setq ind (current-column))) | 7198 | (setq ind (if (> ind 0) |
| 7198 | (goto-char (match-end 0))) | 7199 | (1+ ind) |
| 7199 | )) | 7200 | ;; No lineup-string found |
| 7200 | (if (> ind 0) | 7201 | (goto-char beg) |
| 7201 | (1+ ind) | 7202 | (end-of-line) |
| 7202 | ;; No lineup-string found | 7203 | (skip-chars-backward " \t") |
| 7203 | (goto-char b) | 7204 | (1+ (current-column)))) |
| 7204 | (end-of-line) | 7205 | ind))) |
| 7205 | (skip-chars-backward " \t") | ||
| 7206 | (1+ (current-column)))))) | ||
| 7207 | 7206 | ||
| 7208 | (defun verilog-comment-depth (type val) | 7207 | (defun verilog-comment-depth (type val) |
| 7209 | "A useful mode debugging aide. TYPE and VAL are comments for insertion." | 7208 | "A useful mode debugging aide. TYPE and VAL are comments for insertion." |
| @@ -9344,7 +9343,7 @@ Returns REGEXP and list of ( (signal_name connection_name)... )." | |||
| 9344 | ;; Regexp form?? | 9343 | ;; Regexp form?? |
| 9345 | ((looking-at | 9344 | ((looking-at |
| 9346 | ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last | 9345 | ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last |
| 9347 | "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | 9346 | "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") |
| 9348 | (setq rep (match-string-no-properties 3)) | 9347 | (setq rep (match-string-no-properties 3)) |
| 9349 | (goto-char (match-end 0)) | 9348 | (goto-char (match-end 0)) |
| 9350 | (setq tpl-wild-list | 9349 | (setq tpl-wild-list |
| @@ -9619,8 +9618,9 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9619 | ;; Argument file parsing | 9618 | ;; Argument file parsing |
| 9620 | ;; | 9619 | ;; |
| 9621 | 9620 | ||
| 9622 | (defun verilog-getopt (arglist) | 9621 | (defun verilog-getopt (arglist &optional default-dir) |
| 9623 | "Parse -f, -v etc arguments in ARGLIST list or string." | 9622 | "Parse -f, -v etc arguments in ARGLIST list or string. |
| 9623 | Use DEFAULT-DIR to anchor paths if non-nil." | ||
| 9624 | (unless (listp arglist) (setq arglist (list arglist))) | 9624 | (unless (listp arglist) (setq arglist (list arglist))) |
| 9625 | (let ((space-args '()) | 9625 | (let ((space-args '()) |
| 9626 | arg next-param) | 9626 | arg next-param) |
| @@ -9638,6 +9638,8 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9638 | space-args (cdr space-args)) | 9638 | space-args (cdr space-args)) |
| 9639 | (cond | 9639 | (cond |
| 9640 | ;; Need another arg | 9640 | ;; Need another arg |
| 9641 | ((equal arg "-F") | ||
| 9642 | (setq next-param arg)) | ||
| 9641 | ((equal arg "-f") | 9643 | ((equal arg "-f") |
| 9642 | (setq next-param arg)) | 9644 | (setq next-param arg)) |
| 9643 | ((equal arg "-v") | 9645 | ((equal arg "-v") |
| @@ -9661,32 +9663,37 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9661 | ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ; +incdir+dir | 9663 | ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ; +incdir+dir |
| 9662 | (string-match "^-I\\(.*\\)" arg)) ; -Idir | 9664 | (string-match "^-I\\(.*\\)" arg)) ; -Idir |
| 9663 | (verilog-add-list-unique `verilog-library-directories | 9665 | (verilog-add-list-unique `verilog-library-directories |
| 9664 | (match-string 1 (substitute-in-file-name arg)))) | 9666 | (substitute-in-file-name (match-string 1 arg)))) |
| 9665 | ;; Ignore | 9667 | ;; Ignore |
| 9666 | ((equal "+librescan" arg)) | 9668 | ((equal "+librescan" arg)) |
| 9667 | ((string-match "^-U\\(.*\\)" arg)) ; -Udefine | 9669 | ((string-match "^-U\\(.*\\)" arg)) ; -Udefine |
| 9668 | ;; Second parameters | 9670 | ;; Second parameters |
| 9671 | ((equal next-param "-F") | ||
| 9672 | (setq next-param nil) | ||
| 9673 | (verilog-getopt-file (verilog-substitute-file-name-path arg default-dir) | ||
| 9674 | (file-name-directory (verilog-substitute-file-name-path arg default-dir)))) | ||
| 9669 | ((equal next-param "-f") | 9675 | ((equal next-param "-f") |
| 9670 | (setq next-param nil) | 9676 | (setq next-param nil) |
| 9671 | (verilog-getopt-file (substitute-in-file-name arg))) | 9677 | (verilog-getopt-file (verilog-substitute-file-name-path arg default-dir) nil)) |
| 9672 | ((equal next-param "-v") | 9678 | ((equal next-param "-v") |
| 9673 | (setq next-param nil) | 9679 | (setq next-param nil) |
| 9674 | (verilog-add-list-unique `verilog-library-files | 9680 | (verilog-add-list-unique `verilog-library-files |
| 9675 | (substitute-in-file-name arg))) | 9681 | (verilog-substitute-file-name-path arg default-dir))) |
| 9676 | ((equal next-param "-y") | 9682 | ((equal next-param "-y") |
| 9677 | (setq next-param nil) | 9683 | (setq next-param nil) |
| 9678 | (verilog-add-list-unique `verilog-library-directories | 9684 | (verilog-add-list-unique `verilog-library-directories |
| 9679 | (substitute-in-file-name arg))) | 9685 | (verilog-substitute-file-name-path arg default-dir))) |
| 9680 | ;; Filename | 9686 | ;; Filename |
| 9681 | ((string-match "^[^-+]" arg) | 9687 | ((string-match "^[^-+]" arg) |
| 9682 | (verilog-add-list-unique `verilog-library-files | 9688 | (verilog-add-list-unique `verilog-library-files |
| 9683 | (substitute-in-file-name arg))) | 9689 | (verilog-substitute-file-name-path arg default-dir))) |
| 9684 | ;; Default - ignore; no warning | 9690 | ;; Default - ignore; no warning |
| 9685 | )))) | 9691 | )))) |
| 9686 | ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) | 9692 | ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
| 9687 | 9693 | ||
| 9688 | (defun verilog-getopt-file (filename) | 9694 | (defun verilog-getopt-file (filename &optional default-dir) |
| 9689 | "Read Verilog options from the specified FILENAME." | 9695 | "Read Verilog options from the specified FILENAME. |
| 9696 | Use DEFAULT-DIR to anchor paths if non-nil." | ||
| 9690 | (save-excursion | 9697 | (save-excursion |
| 9691 | (let ((fns (verilog-library-filenames filename (buffer-file-name))) | 9698 | (let ((fns (verilog-library-filenames filename (buffer-file-name))) |
| 9692 | (orig-buffer (current-buffer)) | 9699 | (orig-buffer (current-buffer)) |
| @@ -9702,7 +9709,7 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9702 | (when (string-match "//" line) | 9709 | (when (string-match "//" line) |
| 9703 | (setq line (substring line 0 (match-beginning 0)))) | 9710 | (setq line (substring line 0 (match-beginning 0)))) |
| 9704 | (with-current-buffer orig-buffer ; Variables are buffer-local, so need right context. | 9711 | (with-current-buffer orig-buffer ; Variables are buffer-local, so need right context. |
| 9705 | (verilog-getopt line)))))) | 9712 | (verilog-getopt line default-dir)))))) |
| 9706 | 9713 | ||
| 9707 | (defun verilog-getopt-flags () | 9714 | (defun verilog-getopt-flags () |
| 9708 | "Convert `verilog-library-flags' into standard library variables." | 9715 | "Convert `verilog-library-flags' into standard library variables." |
| @@ -9719,6 +9726,13 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9719 | ;; Allow user to customize | 9726 | ;; Allow user to customize |
| 9720 | (verilog-run-hooks 'verilog-getopt-flags-hook)) | 9727 | (verilog-run-hooks 'verilog-getopt-flags-hook)) |
| 9721 | 9728 | ||
| 9729 | (defun verilog-substitute-file-name-path (filename default-dir) | ||
| 9730 | "Return FILENAME with environment variables substituted. | ||
| 9731 | Use DEFAULT-DIR to anchor paths if non-nil." | ||
| 9732 | (if default-dir | ||
| 9733 | (expand-file-name (substitute-in-file-name filename) default-dir) | ||
| 9734 | (substitute-in-file-name filename))) | ||
| 9735 | |||
| 9722 | (defun verilog-add-list-unique (varref object) | 9736 | (defun verilog-add-list-unique (varref object) |
| 9723 | "Append to VARREF list the given OBJECT, | 9737 | "Append to VARREF list the given OBJECT, |
| 9724 | unless it is already a member of the variable's list." | 9738 | unless it is already a member of the variable's list." |
| @@ -9898,42 +9912,44 @@ Or, just the existing dirnames themselves if there are no wildcards." | |||
| 9898 | (interactive) | 9912 | (interactive) |
| 9899 | (unless dirnames | 9913 | (unless dirnames |
| 9900 | (error "`verilog-library-directories' should include at least `.'")) | 9914 | (error "`verilog-library-directories' should include at least `.'")) |
| 9901 | (setq dirnames (reverse dirnames)) ; not nreverse | 9915 | (save-match-data |
| 9902 | (let ((dirlist nil) | 9916 | (setq dirnames (reverse dirnames)) ; not nreverse |
| 9903 | pattern dirfile dirfiles dirname root filename rest basefile) | 9917 | (let ((dirlist nil) |
| 9904 | (while dirnames | 9918 | pattern dirfile dirfiles dirname root filename rest basefile) |
| 9905 | (setq dirname (substitute-in-file-name (car dirnames)) | 9919 | (setq dirnames (mapcar 'substitute-in-file-name dirnames)) |
| 9906 | dirnames (cdr dirnames)) | 9920 | (while dirnames |
| 9907 | (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ; root | 9921 | (setq dirname (car dirnames) |
| 9908 | "\\([^/\\]*[*?][^/\\]*\\)" ; filename with *? | 9922 | dirnames (cdr dirnames)) |
| 9909 | "\\(.*\\)") ; rest | 9923 | (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ; root |
| 9910 | dirname) | 9924 | "\\([^/\\]*[*?][^/\\]*\\)" ; filename with *? |
| 9911 | (setq root (match-string 1 dirname) | 9925 | "\\(.*\\)") ; rest |
| 9912 | filename (match-string 2 dirname) | 9926 | dirname) |
| 9913 | rest (match-string 3 dirname) | 9927 | (setq root (match-string 1 dirname) |
| 9914 | pattern filename) | 9928 | filename (match-string 2 dirname) |
| 9915 | ;; now replace those * and ? with .+ and . | 9929 | rest (match-string 3 dirname) |
| 9916 | ;; use ^ and /> to get only whole file names | 9930 | pattern filename) |
| 9917 | (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) | 9931 | ;; now replace those * and ? with .+ and . |
| 9918 | pattern (verilog-string-replace-matches "[?]" "." nil nil pattern) | 9932 | ;; use ^ and /> to get only whole file names |
| 9919 | pattern (concat "^" pattern "$") | 9933 | (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) |
| 9920 | dirfiles (verilog-dir-files root)) | 9934 | pattern (verilog-string-replace-matches "[?]" "." nil nil pattern) |
| 9921 | (while dirfiles | 9935 | pattern (concat "^" pattern "$") |
| 9922 | (setq basefile (car dirfiles) | 9936 | dirfiles (verilog-dir-files root)) |
| 9923 | dirfile (expand-file-name (concat root basefile rest)) | 9937 | (while dirfiles |
| 9924 | dirfiles (cdr dirfiles)) | 9938 | (setq basefile (car dirfiles) |
| 9925 | (if (and (string-match pattern basefile) | 9939 | dirfile (expand-file-name (concat root basefile rest)) |
| 9926 | ;; Don't allow abc/*/rtl to match abc/rtl via .. | 9940 | dirfiles (cdr dirfiles)) |
| 9927 | (not (equal basefile ".")) | 9941 | (when (and (string-match pattern basefile) |
| 9928 | (not (equal basefile "..")) | 9942 | ;; Don't allow abc/*/rtl to match abc/rtl via .. |
| 9929 | (file-directory-p dirfile)) | 9943 | (not (equal basefile ".")) |
| 9930 | (setq dirlist (cons dirfile dirlist))))) | 9944 | (not (equal basefile ".."))) |
| 9931 | ;; Defaults | 9945 | ;; Might have more wildcards, so process again |
| 9932 | (t | 9946 | (setq dirnames (cons dirfile dirnames))))) |
| 9933 | (if (file-directory-p dirname) | 9947 | ;; Defaults |
| 9934 | (setq dirlist (cons dirname dirlist)))))) | 9948 | (t |
| 9935 | dirlist)) | 9949 | (if (file-directory-p dirname) |
| 9936 | ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | 9950 | (setq dirlist (cons dirname dirlist)))))) |
| 9951 | dirlist))) | ||
| 9952 | ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v" "../*/*")) | ||
| 9937 | 9953 | ||
| 9938 | (defun verilog-library-filenames (filename &optional current check-ext) | 9954 | (defun verilog-library-filenames (filename &optional current check-ext) |
| 9939 | "Return a search path to find the given FILENAME or module name. | 9955 | "Return a search path to find the given FILENAME or module name. |
| @@ -12074,7 +12090,7 @@ This is currently equivalent to: | |||
| 12074 | with the below at the bottom of the file | 12090 | with the below at the bottom of the file |
| 12075 | 12091 | ||
| 12076 | // Local Variables: | 12092 | // Local Variables: |
| 12077 | // verilog-auto-logic-type:\"logic\" | 12093 | // verilog-auto-wire-type:\"logic\" |
| 12078 | // End: | 12094 | // End: |
| 12079 | 12095 | ||
| 12080 | In the future AUTOLOGIC may declare additional identifiers, | 12096 | In the future AUTOLOGIC may declare additional identifiers, |
| @@ -13223,10 +13239,12 @@ Typing \\[verilog-auto] will make this into: | |||
| 13223 | Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | 13239 | Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output |
| 13224 | signals to deasserted. | 13240 | signals to deasserted. |
| 13225 | 13241 | ||
| 13226 | /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same | 13242 | /*AUTOTIEOFF*/ is used to make stub modules; modules that have |
| 13227 | input/output list as another module, but no internals. Specifically, it | 13243 | the same input/output list as another module, but no internals. |
| 13228 | finds all outputs in the module, and if that input is not otherwise declared | 13244 | Specifically, it finds all outputs in the module, and if that |
| 13229 | as a register or wire, creates a tieoff. | 13245 | input is not otherwise declared as a register or wire, nor comes |
| 13246 | from a AUTOINST submodule's output, creates a tieoff. AUTOTIEOFF | ||
| 13247 | does not examine assignments to determine what is already driven. | ||
| 13230 | 13248 | ||
| 13231 | AUTORESET ties signals to deasserted, which is presumed to be zero. | 13249 | AUTORESET ties signals to deasserted, which is presumed to be zero. |
| 13232 | Signals that match `verilog-active-low-regexp' will be deasserted by tying | 13250 | Signals that match `verilog-active-low-regexp' will be deasserted by tying |
| @@ -14420,7 +14438,7 @@ Files are checked based on `verilog-library-flags'." | |||
| 14420 | (with-output-to-temp-buffer "*verilog-mode help*" | 14438 | (with-output-to-temp-buffer "*verilog-mode help*" |
| 14421 | (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) | 14439 | (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) |
| 14422 | (princ "\n") | 14440 | (princ "\n") |
| 14423 | (princ "For new releases, see http://www.verilog.com\n") | 14441 | (princ "For new releases, see http://www.veripool.com/verilog-mode\n") |
| 14424 | (princ "\n") | 14442 | (princ "\n") |
| 14425 | (princ "For frequently asked questions, see http://www.veripool.org/verilog-mode-faq.html\n") | 14443 | (princ "For frequently asked questions, see http://www.veripool.org/verilog-mode-faq.html\n") |
| 14426 | (princ "\n") | 14444 | (princ "\n") |