GNU bug report logs - #45795
27.1; prolog-mode prolog-system switch bug

Previous Next

Package: emacs;

Reported by: k3tu0isui <at> gmail.com

Date: Mon, 11 Jan 2021 17:10:02 UTC

Severity: normal

Tags: patch

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45795 in the body.
You can then email your comments to 45795 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45795; Package emacs. (Mon, 11 Jan 2021 17:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to k3tu0isui <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 11 Jan 2021 17:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: k3tu0isui <at> gmail.com
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; prolog-mode prolog-system switch bug
Date: Mon, 11 Jan 2021 22:39:22 +0530
[Message part 1 (text/plain, inline)]
Switching between prolog systems is not supported properly.

Say I stated with (setq prolog-system 'swi) in my configuration, and I set (setq-local prolog-system 'gnu) in my working buffer. Now when I do `run-prolog` it is expected to run gprolog instead of swipl. But this is not happening, it still runs swipl.

The bug seems to be in `prolog-ensure-process` function. If the process is not running, a new process is created using make-comint-in-buffer whose program name is supplied using (prolog-program-name). But we have already shifted to the *prolog* buffer here, so whatever the value of prolog-system in our source buffer, the program started is still that of the global variable.

In my patch I just bound (prolog-program-name) and (prolog-program-switches) before switching to *prolog* buffer. This seems to work.
[0001-prolog-mode-prolog-system-switch-process-bug.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45795; Package emacs. (Tue, 12 Jan 2021 14:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 45795 <at> debbugs.gnu.org (full text, mbox):

From: k3tu0isui <at> gmail.com
To: 45795 <at> debbugs.gnu.org
Subject: bug#45795: prolog-mode prolog-system switch bug - also with run-prolog
Date: Tue, 12 Jan 2021 20:10:44 +0530
I have also noticed that this affects the `run-prolog` function in a way not affected by my previous patch.
In `run-prolog` function `prolog-ensure-process` is called after switching to the *prolog* buffer using `prolog-goto-prolog-process-buffer`. So my previous patch which deals with `prolog-ensure-process` will not affect this. I do not know how to rectify this due to the presence of SICStus-Prolog specific code that seems to be working in *prolog* buffer. If I moved `prolog-ensure-process` call before switching to *prolog* buffer, something SICStus might break. I have never worked with SICStus so I am not sure how to deal with this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45795; Package emacs. (Tue, 12 Jan 2021 15:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 45795 <at> debbugs.gnu.org (full text, mbox):

From: k3tu0isui <at> gmail.com
To: 45795 <at> debbugs.gnu.org
Subject: [PATCH] prolog-mode run-prolog and prolog-consult-file fixes when
 prolog-system changes
Date: Tue, 12 Jan 2021 20:43:25 +0530
[Message part 1 (text/plain, inline)]
Can someone working with SICStus check if this patch breaks debugger(or anything) when `run-prolog` is used?

I have repeatedly checked switching between GNU-Prolog and SWI-Prolog systems after setting `prolog-system` to buffer local values 'gnu' and 'swi' resp.
Both `prolog-consult-file` and `run-prolog` are now starting the correct interpreter.

[Message part 2 (text/plain, inline)]
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index 9f5f9ed6d3..00d865af1a 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -1316,6 +1316,7 @@ run-prolog
       (progn
         (process-send-string "prolog" "halt.\n")
         (while (get-process "prolog") (sit-for 0.1))))
+  (prolog-ensure-process)
   (let ((buff (buffer-name)))
     (if (not (string= buff "*prolog*"))
         (prolog-goto-prolog-process-buffer))
@@ -1325,7 +1326,6 @@ run-prolog
              prolog-use-sicstus-sd)
         (prolog-enable-sicstus-sd))
     (prolog-mode-variables)
-    (prolog-ensure-process)
     ))
 
 (defun prolog-inferior-guess-flavor (&optional ignored)
@@ -1350,7 +1350,9 @@ prolog-ensure-process
   "If Prolog process is not running, run it.
 If the optional argument WAIT is non-nil, wait for Prolog prompt specified by
 the variable `prolog-prompt-regexp'."
-  (if (null (prolog-program-name))
+  (let ((pname (prolog-program-name))
+        (pswitches (prolog-program-switches)))
+    (if (null pname)
         (error "This Prolog system has defined no interpreter."))
     (if (comint-check-proc "*prolog*")
         ()
@@ -1368,7 +1370,7 @@ prolog-ensure-process
 		   process-environment
 	         (cons "INFERIOR=yes" process-environment))))
 	  (apply 'make-comint-in-buffer "prolog" (current-buffer)
-	       (prolog-program-name) nil (prolog-program-switches)))
+	         pname nil pswitches))
 
         (unless prolog-system
           ;; Setup auto-detection.
@@ -1399,7 +1401,7 @@ prolog-ensure-process
                      (re-search-backward
                       (concat "\\(" (prolog-prompt-regexp) "\\)" "\\=")
                       nil t)))
-              (sit-for 0.1)))))))
+                (sit-for 0.1))))))))
 
 (defun prolog-inferior-buffer (&optional dont-run)
   (or (get-buffer "*prolog*")
[prolog-switch-final.diff (text/plain, attachment)]

Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 30 Jul 2021 12:35:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45795; Package emacs. (Fri, 30 Jul 2021 12:41:01 GMT) Full text and rfc822 format available.

Message #16 received at 45795 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: k3tu0isui <at> gmail.com
Cc: 45795 <at> debbugs.gnu.org
Subject: Re: bug#45795: 27.1; prolog-mode prolog-system switch bug
Date: Fri, 30 Jul 2021 14:39:58 +0200
k3tu0isui <at> gmail.com writes:

> I have repeatedly checked switching between GNU-Prolog and SWI-Prolog
> systems after setting `prolog-system` to buffer local values 'gnu' and
> 'swi' resp.
> Both `prolog-consult-file` and `run-prolog` are now starting the
> correct interpreter.

I don't use Prolog myself, but your patch seems to make sense to me, so
I've applied it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 45795 <at> debbugs.gnu.org and k3tu0isui <at> gmail.com Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 30 Jul 2021 12:41:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 28 Aug 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 239 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.