all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Robert Pluim <rpluim@gmail.com>
Cc: Reto Zimmermann <reto@gnu.org>, Eli Zaretskii <eliz@gnu.org>,
	"54730@debbugs.gnu.org" <54730@debbugs.gnu.org>,
	Cyril Arnould <cyril.arnould@outlook.com>
Subject: bug#54730: AW: bug#54730: 28.1; vhdl-update-sensitivity-list not working in Windows
Date: Tue, 05 Apr 2022 17:21:35 -0400	[thread overview]
Message-ID: <jwvee2b8d8y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87tub75rmv.fsf@gmail.com> (Robert Pluim's message of "Tue, 05 Apr 2022 20:09:28 +0200")

Robert Pluim [2022-04-05 20:09:28] wrote:

>>>>>> On Tue, 5 Apr 2022 17:53:20 +0000, Cyril Arnould <cyril.arnould@outlook.com> said:
>
>     Cyril> Nice, it’s working! Too bad this didn’t make it into the 28.1
>     Cyril> release, I guess I should have
>     Cyril> tested more. So for now the solution is to keep the vhdl-mode.el
>     Cyril> locally until it finds its
>     Cyril> way into a maintenance release?
>
> Yes. Eli might decide to put it in 28.2
>
> An alternative (shorter) fix would be this. Stefan, is there a
> preference for how these types of lexical-binding bugs are fixed?

It's a question of style and local details.
E.g. whether you want to preserve compatibility with Emacs<24 or XEmacs.
Personally I dislike such abuses of `eval`, so I'd replace it with
`funcall` as in the (100% untested) patch below.


        Stefan


diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index c6693b4de53..7bb07343ae0 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -8374,6 +8374,52 @@ vhdl-update-sensitivity-list-buffer
      (message "Updating sensitivity lists...done")))
   (when noninteractive (save-buffer)))
 
+(defconst vhdl--signal-regions-functions
+  (list
+   ;; right-hand side of signal/variable assignment
+   ;; (special case: "<=" is relational operator in a condition)
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "[<:]=" proc-end t)
+       (save-excursion
+	 (vhdl-re-search-forward ";\\|\\<\\(then\\|loop\\|report\\|severity\\|is\\)\\>" proc-end t))))
+   ;; if condition
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "^\\s-*if\\>" proc-end t)
+       (save-excursion (vhdl-re-search-forward "\\<then\\>" proc-end t))))
+   ;; elsif condition
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "\\<elsif\\>" proc-end t)
+       (save-excursion (vhdl-re-search-forward "\\<then\\>" proc-end t))))
+   ;; while loop condition
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "^\\s-*while\\>" proc-end t)
+       (save-excursion (vhdl-re-search-forward "\\<loop\\>" proc-end t))))
+   ;; exit/next condition
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "\\<\\(exit\\|next\\)\\s-+\\w+\\s-+when\\>" proc-end t)
+       (save-excursion (vhdl-re-search-forward ";" proc-end t))))
+   ;; assert condition
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "\\<assert\\>" proc-end t)
+       (save-excursion
+	 (vhdl-re-search-forward "\\(\\<report\\>\\|\\<severity\\>\\|;\\)"
+		                 proc-end t))))
+   ;; case expression
+   (lambda (proc-end)
+     (when (vhdl-re-search-forward "^\\s-*case\\>" proc-end t)
+       (save-excursion (vhdl-re-search-forward "\\<is\\>" proc-end t))))
+   ;; parameter list of procedure call, array index
+   (lambda (proc-end)
+     (when (re-search-forward "^\\s-*\\(\\w\\|\\.\\)+[ \t\n\r\f]*(" proc-end t)
+       (forward-char -1)
+       (save-excursion
+	 (forward-sexp)
+	 (while (looking-at "(") (forward-sexp)) (point)))))
+  "Define syntactic regions where signals are read.
+Each function is called with one arg (a limit for the (forward) search) and
+should return either nil or the end position of the region (in which case
+point will be set to its beginning).")
+
 (defun vhdl-update-sensitivity-list ()
   "Update sensitivity list."
     (let ((proc-beg (point))
@@ -8394,35 +8440,7 @@ vhdl-update-sensitivity-list
 	(let
 	    ;; scan for visible signals
 	    ((visible-list (vhdl-get-visible-signals))
-	     ;; define syntactic regions where signals are read
-	     (scan-regions-list
-	      '(;; right-hand side of signal/variable assignment
-		;; (special case: "<=" is relational operator in a condition)
-		((vhdl-re-search-forward "[<:]=" proc-end t)
-		 (vhdl-re-search-forward ";\\|\\<\\(then\\|loop\\|report\\|severity\\|is\\)\\>" proc-end t))
-		;; if condition
-		((vhdl-re-search-forward "^\\s-*if\\>" proc-end t)
-		 (vhdl-re-search-forward "\\<then\\>" proc-end t))
-		;; elsif condition
-		((vhdl-re-search-forward "\\<elsif\\>" proc-end t)
-		 (vhdl-re-search-forward "\\<then\\>" proc-end t))
-		;; while loop condition
-		((vhdl-re-search-forward "^\\s-*while\\>" proc-end t)
-		 (vhdl-re-search-forward "\\<loop\\>" proc-end t))
-		;; exit/next condition
-		((vhdl-re-search-forward "\\<\\(exit\\|next\\)\\s-+\\w+\\s-+when\\>" proc-end t)
-		 (vhdl-re-search-forward ";" proc-end t))
-		;; assert condition
-		((vhdl-re-search-forward "\\<assert\\>" proc-end t)
-		 (vhdl-re-search-forward "\\(\\<report\\>\\|\\<severity\\>\\|;\\)" proc-end t))
-		;; case expression
-		((vhdl-re-search-forward "^\\s-*case\\>" proc-end t)
-		 (vhdl-re-search-forward "\\<is\\>" proc-end t))
-		;; parameter list of procedure call, array index
-		((and (re-search-forward "^\\s-*\\(\\w\\|\\.\\)+[ \t\n\r\f]*(" proc-end t)
-		      (1- (point)))
-		 (progn (backward-char) (forward-sexp)
-			(while (looking-at "(") (forward-sexp)) (point)))))
+	     (scan-regions-list vhdl--signal-regions-functions)
 	     name field read-list sens-list signal-list tmp-list
 	     sens-beg sens-end beg end margin)
 	  ;; scan for signals in old sensitivity list
@@ -8453,9 +8471,7 @@ vhdl-update-sensitivity-list
 	  ;; scan for signals read in process
 	  (while scan-regions-list
 	    (goto-char proc-mid)
-	    (while (and (setq beg (eval (nth 0 (car scan-regions-list))))
-			(setq end (eval (nth 1 (car scan-regions-list)))))
-	      (goto-char beg)
+	    (while (setq end (funcall (car scan-regions-list) proc-end))
 	      (unless (or (vhdl-in-literal)
 			  (and seq-region-list
 			       (let ((tmp-list seq-region-list))






  reply	other threads:[~2022-04-05 21:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 16:17 bug#54730: 28.1; vhdl-update-sensitivity-list not working in Windows Cyril Arnould
2022-04-05 16:43 ` Eli Zaretskii
2022-04-05 17:08   ` bug#54730: AW: " Cyril Arnould
2022-04-05 17:12     ` Cyril Arnould
2022-04-05 17:26     ` Eli Zaretskii
2022-04-05 17:53       ` bug#54730: AW: " Cyril Arnould
2022-04-05 18:09         ` Robert Pluim
2022-04-05 21:21           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-04-05 22:27             ` bug#54730: AW: " Cyril Arnould
2022-04-05 18:18         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvee2b8d8y.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=54730@debbugs.gnu.org \
    --cc=cyril.arnould@outlook.com \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=reto@gnu.org \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.