From 03f0c08de947be9d9ecdd2d8755593c5c1329746 Mon Sep 17 00:00:00 2001 From: Gonzalo Larumbe Date: Sat, 10 Sep 2022 17:35:59 +0200 Subject: [PATCH 1/2] Fix bug in highlighting of vars on func/task arguments. * verilog-mode.el (Line#3434, Line#3435, Line#3438, Line#3439, verilog-declaration-varname-matcher): Fix bug in highlighting of vars on func/task arguments. Signed-off-by: Gonzalo Larumbe --- verilog-mode.el | 50 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/verilog-mode.el b/verilog-mode.el index fa858ee4..f8b78ca8 100644 --- a/verilog-mode.el +++ b/verilog-mode.el @@ -3437,12 +3437,12 @@ See also `verilog-font-lock-extra-types'.") ;; Pre-form for this anchored matcher: ;; First, avoid declaration keywords written in comments, ;; which can also trigger this anchor. - '(if (not (verilog-in-comment-p)) + '(if (and (not (verilog-in-comment-p)) + (not (member (thing-at-point 'symbol) verilog-keywords))) (verilog-single-declaration-end verilog-highlight-max-lookahead) (point)) ;; => current declaration statement is of 0 length nil ;; Post-form: nothing to be done - '(0 font-lock-variable-name-face nil t))) - ))) + '(0 font-lock-variable-name-face)))))) (setq verilog-font-lock-keywords-2 @@ -3743,31 +3743,27 @@ This function moves POINT to the next variable within the same declaration (if it exists). LIMIT is expected to be the pos at which current single-declaration ends, obtained using `verilog-single-declaration-end'." - - (let (found-var old-point) - - ;; Remove starting whitespace - (verilog-forward-ws&directives limit) - - (when (< (point) limit) ;; no matching if this is violated - - ;; Find the variable name (match-data is set here) - (setq found-var (re-search-forward verilog-identifier-sym-re limit t)) - - ;; Walk to this variable's delimiter - (save-match-data - (verilog-forward-ws&directives limit) - (setq old-point nil) - (while (and (< (point) limit) - (not (member (char-after) '(?, ?\) ?\] ?\} ?\;))) - (not (eq old-point (point)))) - (setq old-point (point)) + (when (not (member (thing-at-point 'symbol) verilog-keywords)) + (let (found-var old-point) + ;; Remove starting whitespace + (verilog-forward-ws&directives limit) + (when (< (point) limit) ;; no matching if this is violated + ;; Find the variable name (match-data is set here) + (setq found-var (re-search-forward verilog-identifier-sym-re limit t)) + ;; Walk to this variable's delimiter + (save-match-data (verilog-forward-ws&directives limit) - (forward-sexp) - (verilog-forward-ws&directives limit)) - ;; Only a comma or semicolon expected at this point - (skip-syntax-forward ".")) - found-var))) + (setq old-point nil) + (while (and (< (point) limit) + (not (member (char-after) '(?, ?\) ?\] ?\} ?\;))) + (not (eq old-point (point)))) + (setq old-point (point)) + (verilog-forward-ws&directives limit) + (forward-sexp) + (verilog-forward-ws&directives limit)) + ;; Only a comma or semicolon expected at this point + (skip-syntax-forward ".")) + found-var)))) (defun verilog-point-text (&optional pointnum) "Return text describing where POINTNUM or current point is (for errors). From 75abe7a3a2b4f3e4a597ed38cef6571812b4319e Mon Sep 17 00:00:00 2001 From: Gonzalo Larumbe Date: Sat, 10 Sep 2022 17:39:22 +0200 Subject: [PATCH 2/2] Add option to enable/disable variable fontification. * verilog-mode.el (Line#939, verilog-declaration-varname-matcher, verilog-fontify-variables, verilog-submit-bug-report): Add option to enable/disable variable fontification. Signed-off-by: Gonzalo Larumbe --- verilog-mode.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/verilog-mode.el b/verilog-mode.el index f8b78ca8..1f56bebd 100644 --- a/verilog-mode.el +++ b/verilog-mode.el @@ -932,6 +932,12 @@ always be saved." :type 'boolean) (put 'verilog-auto-star-save 'safe-local-variable #'verilog-booleanp) +(defcustom verilog-fontify-variables t + "Non-nil means fontify declaration variables." + :group 'verilog-mode-actions + :type 'boolean) +(put 'verilog-fontify-variables 'safe-local-variable #'verilog-booleanp) + (defvar verilog-auto-update-tick nil "Modification tick at which autos were last performed.") @@ -3743,7 +3749,8 @@ This function moves POINT to the next variable within the same declaration (if it exists). LIMIT is expected to be the pos at which current single-declaration ends, obtained using `verilog-single-declaration-end'." - (when (not (member (thing-at-point 'symbol) verilog-keywords)) + (when (and verilog-fontify-variables + (not (member (thing-at-point 'symbol) verilog-keywords))) (let (found-var old-point) ;; Remove starting whitespace (verilog-forward-ws&directives limit) @@ -15501,6 +15508,7 @@ Files are checked based on `verilog-library-flags'." verilog-compiler verilog-coverage verilog-delete-auto-hook + verilog-fontify-variables verilog-getopt-flags-hook verilog-highlight-grouping-keywords verilog-highlight-includes