From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: k3tu0isui@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#45795: 27.1; prolog-mode prolog-system switch bug Date: Mon, 11 Jan 2021 22:39:22 +0530 Message-ID: <20210111170922.42anbeq5g6uovhdu@sildranDT.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="xxhaulymrjnqajv4" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3356"; mail-complaints-to="usenet@ciao.gmane.io" To: 45795@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 11 18:21:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kz0sL-0000kZ-4P for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 18:21:05 +0100 Original-Received: from localhost ([::1]:59190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz0sK-000379-3v for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 12:21:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz0he-0002WZ-Od for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 12:10:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kz0he-0006Et-Gp for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 12:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kz0he-00086m-9l for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 12:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: k3tu0isui@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Jan 2021 17:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45795 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161038498031131 (code B ref -1); Mon, 11 Jan 2021 17:10:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Jan 2021 17:09:40 +0000 Original-Received: from localhost ([127.0.0.1]:58139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kz0hH-000862-Oo for submit@debbugs.gnu.org; Mon, 11 Jan 2021 12:09:40 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:33254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kz0hF-00085u-9C for submit@debbugs.gnu.org; Mon, 11 Jan 2021 12:09:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz0hF-0001uG-3B for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 12:09:37 -0500 Original-Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:38297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kz0hA-00067j-Dt for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 12:09:35 -0500 Original-Received: by mail-pg1-x52e.google.com with SMTP id q7so73084pgm.5 for ; Mon, 11 Jan 2021 09:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=sI9i7p/dgzJxpuVmOgZFYW1GiOVv5JxKwLkUfU9+tVY=; b=aGNRuy5h3ZgLiR+txDy9L86YvVdx7b0Mlwee8R4SmYKWzkhQgUecTsEzMj5Ni6Kv33 oB+r1/Kla/OPHN3oJgLIFlgXOGK6r8fQ2SvDFF0zeii4yt8kU2+iIzr1gfuCAkpUgpqb 3V0ustO5sVYhG+0O+r6pWxjA5fprRTwxz1QdlbSoHJVUcjYwj53kQCsaxOqdCzVAU8D6 4oyCkwuDCR4lUMuMv3SZqdqKqCMxajeIsVhnVqgeNB1BHY+w9DQgf5FUgYklSY1OL3xE 3df4MkYSDcA8onUgMFFRyBm4V00x26Iw8RgkLumthfPykdsETomWGtQQlbD2ElSc9pyw 8qEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=sI9i7p/dgzJxpuVmOgZFYW1GiOVv5JxKwLkUfU9+tVY=; b=uWCFIsuPNZvyNSjgvJvUUe8OVJmNCQUKbbhJ9dcpz+1x2CGRvLWh9/PJ8ElIRg6Wf3 Laws5KWmk5eeFj2UihmuLiUW9PkruVy10/Wfn25U+uVYb18a//qsnyoolpYR3Ku9b8w+ 0AFvNppJ8K+pL9mvwCp3M5ekHaNl3A88JD3HpxSDLSrd1U23/WsUw5ncMT5AhJwn3NWx DZis0/qmKtKk0ddv1zNB/3jc3xtDH5Yoc/IfBUxhca54jZEqwIZE8bi17y0AVHXvfemv ALrvJliz5/GcOEYhW23xpURq8LCWb4B09c3lESHR+mJ4GY1CX+bDyWh5NkhOWhANoiYV gc+A== X-Gm-Message-State: AOAM531RM666LVb8Px3OpASPW9lP7SwrNLnHEJ6HPkTgigUm8uNjLv1k 7hyk33XUdgGUfotk/cIurszMy1fsJZE= X-Google-Smtp-Source: ABdhPJx2L5yq+v9zp2UOsKHmtteA+6H1mwER7VrRYYD613LR89M1uUP9ASGCM4bhiJKlnwpy0SJ4sQ== X-Received: by 2002:a65:689a:: with SMTP id e26mr452284pgt.413.1610384969938; Mon, 11 Jan 2021 09:09:29 -0800 (PST) Original-Received: from sildranDT.localdomain ([2401:4900:33a6:9101:fb45:be1:c4a:3242]) by smtp.gmail.com with ESMTPSA id c14sm193136pfd.37.2021.01.11.09.09.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 09:09:28 -0800 (PST) Content-Disposition: inline Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=k3tu0isui@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197728 Archived-At: --xxhaulymrjnqajv4 Content-Type: text/plain; charset=us-ascii Content-Disposition: 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. --xxhaulymrjnqajv4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-prolog-mode-prolog-system-switch-process-bug.patch" >From d9770ecac117fedd3d6351144a6f1464f701fd73 Mon Sep 17 00:00:00 2001 From: keutoi Date: Mon, 11 Jan 2021 22:34:20 +0530 Subject: [PATCH] prolog-mode prolog-system switch process bug --- lisp/progmodes/prolog.el | 102 ++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el index 9f5f9ed6d3..f866f1e2f6 100644 --- a/lisp/progmodes/prolog.el +++ b/lisp/progmodes/prolog.el @@ -1350,56 +1350,58 @@ 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)) - (error "This Prolog system has defined no interpreter.")) - (if (comint-check-proc "*prolog*") - () - (with-current-buffer (get-buffer-create "*prolog*") - (prolog-inferior-mode) - - ;; The "INFERIOR=yes" hack is for SWI-Prolog 7.2.3 and earlier, - ;; which assumes it is running under Emacs if either INFERIOR=yes or - ;; if EMACS is set to a nonempty value. The EMACS setting is - ;; obsolescent, so set INFERIOR. Newer versions of SWI-Prolog should - ;; know about INSIDE_EMACS (which replaced EMACS) and should not need - ;; this hack. - (let ((process-environment - (if (getenv "INFERIOR") - process-environment - (cons "INFERIOR=yes" process-environment)))) - (apply 'make-comint-in-buffer "prolog" (current-buffer) - (prolog-program-name) nil (prolog-program-switches))) - - (unless prolog-system - ;; Setup auto-detection. - (setq-local - prolog-system - ;; Force re-detection. - (let* ((proc (get-buffer-process (current-buffer))) - (pmark (and proc (marker-position (process-mark proc))))) - (cond - ((null pmark) (1- (point-min))) - ;; The use of insert-before-markers in comint.el together with - ;; the potential use of comint-truncate-buffer in the output - ;; filter, means that it's difficult to reliably keep track of - ;; the buffer position where the process's output started. - ;; If possible we use a marker at "start - 1", so that - ;; insert-before-marker at `start' won't shift it. And if not, - ;; we fall back on using a plain integer. - ((> pmark (point-min)) (copy-marker (1- pmark))) - (t (1- pmark))))) - (add-hook 'comint-output-filter-functions - 'prolog-inferior-guess-flavor nil t)) - (if wait - (progn - (goto-char (point-max)) - (while - (save-excursion - (not - (re-search-backward - (concat "\\(" (prolog-prompt-regexp) "\\)" "\\=") - nil t))) - (sit-for 0.1))))))) + (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*") + () + (with-current-buffer (get-buffer-create "*prolog*") + (prolog-inferior-mode) + + ;; The "INFERIOR=yes" hack is for SWI-Prolog 7.2.3 and earlier, + ;; which assumes it is running under Emacs if either INFERIOR=yes or + ;; if EMACS is set to a nonempty value. The EMACS setting is + ;; obsolescent, so set INFERIOR. Newer versions of SWI-Prolog should + ;; know about INSIDE_EMACS (which replaced EMACS) and should not need + ;; this hack. + (let ((process-environment + (if (getenv "INFERIOR") + process-environment + (cons "INFERIOR=yes" process-environment)))) + (apply 'make-comint-in-buffer "prolog" (current-buffer) + pname nil pswitches)) + + (unless prolog-system + ;; Setup auto-detection. + (setq-local + prolog-system + ;; Force re-detection. + (let* ((proc (get-buffer-process (current-buffer))) + (pmark (and proc (marker-position (process-mark proc))))) + (cond + ((null pmark) (1- (point-min))) + ;; The use of insert-before-markers in comint.el together with + ;; the potential use of comint-truncate-buffer in the output + ;; filter, means that it's difficult to reliably keep track of + ;; the buffer position where the process's output started. + ;; If possible we use a marker at "start - 1", so that + ;; insert-before-marker at `start' won't shift it. And if not, + ;; we fall back on using a plain integer. + ((> pmark (point-min)) (copy-marker (1- pmark))) + (t (1- pmark))))) + (add-hook 'comint-output-filter-functions + 'prolog-inferior-guess-flavor nil t)) + (if wait + (progn + (goto-char (point-max)) + (while + (save-excursion + (not + (re-search-backward + (concat "\\(" (prolog-prompt-regexp) "\\)" "\\=") + nil t))) + (sit-for 0.1)))))))) (defun prolog-inferior-buffer (&optional dont-run) (or (get-buffer "*prolog*") -- 2.29.2 --xxhaulymrjnqajv4--