From unknown Wed Jun 18 23:10:18 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#45795 <45795@debbugs.gnu.org> To: bug#45795 <45795@debbugs.gnu.org> Subject: Status: 27.1; prolog-mode prolog-system switch bug Reply-To: bug#45795 <45795@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:10:18 +0000 retitle 45795 27.1; prolog-mode prolog-system switch bug reassign 45795 emacs submitter 45795 k3tu0isui@gmail.com severity 45795 normal tag 45795 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 11 12:09:40 2021 Received: (at submit) by debbugs.gnu.org; 11 Jan 2021 17:09:40 +0000 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 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 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 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 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) 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) Date: Mon, 11 Jan 2021 22:39:22 +0530 From: k3tu0isui@gmail.com To: bug-gnu-emacs@gnu.org Subject: 27.1; prolog-mode prolog-system switch bug Message-ID: <20210111170922.42anbeq5g6uovhdu@sildranDT.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xxhaulymrjnqajv4" 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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --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-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 12 09:41:10 2021 Received: (at 45795) by debbugs.gnu.org; 12 Jan 2021 14:41:10 +0000 Received: from localhost ([127.0.0.1]:59626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzKr8-000343-JX for submit@debbugs.gnu.org; Tue, 12 Jan 2021 09:41:10 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:38199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzKr5-00033n-6M for 45795@debbugs.gnu.org; Tue, 12 Jan 2021 09:41:09 -0500 Received: by mail-pl1-f177.google.com with SMTP id d4so687154plh.5 for <45795@debbugs.gnu.org>; Tue, 12 Jan 2021 06:41:07 -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=FFbtvdyRJFRqxQDKNoQDz2HjFoneHbHY4FEumHQ4R1A=; b=qxPgwncT+8asU8v5NcMBSoGy7tDQVihmr+SlrbB3b8SiItbfL0D8k430grh/oBV0aG nLWn+gwQxFo7myAlKp6fwiDwzbOs0eW3TCQ/4v5Q/diZ208Aq78nVrnhT5AcpAA9YGpe Y/3GH48Jsb+UITT6pndB5Hz1vGkSjxuoeGrPbGDaoWeRzbdwmD41Mo8pwjEQhb5W24Os 4v1pqAC9GiDbRClPII/joTJeOtU6bFygjPQJdAjeCFEt9DuCn16YBGTLUWf5v1MgnH7L 3tsoPZgzlrorfYwFdzLGaSxJhD5zRxM0+VEsTUcsPMwwDIiEiyOlyfiMeSI7xcGss+fm 69xw== 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=FFbtvdyRJFRqxQDKNoQDz2HjFoneHbHY4FEumHQ4R1A=; b=BbO5+QuOWR+pGr2uhagZIJ+XlOW9G8NA69uzkejuYTmW3WOqoJ+lAvj51hdpGBbd3z KiqEsD6Rd8SRQB3ldVhBTh/O11uT6Z2rusY2M7nY8PIkaXuRfNkrKV5iVAtTuBRdHNr6 0Y88IUBDTTja428ew03y9JKRlmkVbg9RjgxjajV7Wymc1tYCsQbaW126LIh3oPX72Aaw s02Tx63r8f8rA+G57iRCIiCJ01xalo7Xa1xYibdKzSZbXhVThnfjK+aI4hfa6qkxOQ3U MAS4zQH8OIKjyJyFsDhqNQNkOm2nDJNrL2qM0FncR3wKuWYDB4/2fTXi7xa+bmj7nbGG aIpA== X-Gm-Message-State: AOAM532I4d70XDeukM71YeD0qa4MTpfBVJ+U9aU0B0TgrFXYVvxJ881I 78zaxYI50zlItH2MOodH0vVCsswdu9l4Hw== X-Google-Smtp-Source: ABdhPJzurpJiqhpLC77zmNzP70Zw16XVJxFNdsTW0f2bebNzcVbT9hDqU5Nh6w5nH3eohHdP4R1fBQ== X-Received: by 2002:a17:902:db84:b029:dc:2efb:659b with SMTP id m4-20020a170902db84b02900dc2efb659bmr5014522pld.83.1610462460475; Tue, 12 Jan 2021 06:41:00 -0800 (PST) Received: from sildranDT.localdomain ([27.59.147.45]) by smtp.gmail.com with ESMTPSA id t1sm3461666pfq.154.2021.01.12.06.40.55 for <45795@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:40:59 -0800 (PST) Date: Tue, 12 Jan 2021 20:10:44 +0530 From: k3tu0isui@gmail.com To: 45795@debbugs.gnu.org Subject: bug#45795: prolog-mode prolog-system switch bug - also with run-prolog Message-ID: <20210112144044.2pedibectjpbzuac@sildranDT.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45795 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 12 10:13:56 2021 Received: (at 45795) by debbugs.gnu.org; 12 Jan 2021 15:13:56 +0000 Received: from localhost ([127.0.0.1]:32836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzLMp-0004Db-Mv for submit@debbugs.gnu.org; Tue, 12 Jan 2021 10:13:56 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:40642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzLMn-0004DD-NI for 45795@debbugs.gnu.org; Tue, 12 Jan 2021 10:13:54 -0500 Received: by mail-pl1-f170.google.com with SMTP id q4so1543261plr.7 for <45795@debbugs.gnu.org>; Tue, 12 Jan 2021 07:13:53 -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=6gLTXQ++5gMKv/EcnsfRoqOOS/Xyuy5XDTFL59Q/ib4=; b=VL1zE3zy8lNhWUbXDkhy9gR/uhnbYk4Srto6oXFD4+9aLT+7kEHS1WTeY3QyM1Mamd Ce2Xi2y2L3DcczQ367TE/fYcvwevWUm/f/BssSFQQoljJrKPOJUrVN5onFVjF4V5iTl3 bZiFBFSvDpIaHwgBaRY52eU2Jk/6qWazX6uncafThuO58xQLxXnaOq+xEMpQxIgZXXql XxhEWAOU9qBjHHAfZFwCzHcfVo/qNif6VausXjbldQO9/C8XBIiV0/CJdTSQHONNV0yc QgXC9ZR3ZwI2HP4HD23/bM8uuaIHSlj5UJEvV1ILuTJIYHw5ZuXDcQMLZaDVuW3s18rD toIA== 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=6gLTXQ++5gMKv/EcnsfRoqOOS/Xyuy5XDTFL59Q/ib4=; b=FKRghvMOo3Fz8DbwIVuab84nWPKfv17j69vmGsWd0ZVRFnPLFK2QH5dClEbI0KtCqO btnXSHDwFrzuxpwGEWT7PMB3/yph4rs1blDqf+5ykBMG1gqUZrQLK72TJAy+oMDuYDCo 4yXSSH5p9nYRdqZnh6myFpejen8WW7BeB2OvO4u8lEamiLT2j8N9W1Lg0UWurX905y17 HGSxOuc76jKS77tyEyeLLGkpkwWsUr5ZfSUXgGlVFII5goezB+bYuzPWn9Ycb5Qit0mB kx/CA8gTvktzOB0IJe7e4es/M9HFO9wjlxAEpFz26Lptglo9NUsfrG1Lql4F0mZqpV0n YhVg== X-Gm-Message-State: AOAM531fd/5loNHn/Un8Z+VVCjVBR31tNRyY5OZvcKmUXsivkAy1KlLF sHj2ROyvXglCy4iDaDUxJwt+C3wiSzqA9A== X-Google-Smtp-Source: ABdhPJwSayBcWzhGD9t2kjO90SqPEPvuHYTd/uzvU6nTbbOplGiNqGmhRVM56k0L1pkcbX8ch8sV5A== X-Received: by 2002:a17:902:bd42:b029:de:1758:8d5f with SMTP id b2-20020a170902bd42b02900de17588d5fmr4654053plx.73.1610464427307; Tue, 12 Jan 2021 07:13:47 -0800 (PST) Received: from sildranDT.localdomain ([27.59.147.45]) by smtp.gmail.com with ESMTPSA id c5sm4333507pgt.73.2021.01.12.07.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 07:13:46 -0800 (PST) Date: Tue, 12 Jan 2021 20:43:25 +0530 From: k3tu0isui@gmail.com To: 45795@debbugs.gnu.org Subject: [PATCH] prolog-mode run-prolog and prolog-consult-file fixes when prolog-system changes Message-ID: <20210112151325.j4gguewyr5ays2a3@sildranDT.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3azmrgwpl5z6x5wt" Content-Disposition: inline X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45795 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --3azmrgwpl5z6x5wt Content-Type: text/plain; charset=us-ascii Content-Disposition: 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. --3azmrgwpl5z6x5wt Content-Type: text/plain; charset=us-ascii Content-Description: whitespace ignored diff Content-Disposition: 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*") --3azmrgwpl5z6x5wt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="prolog-switch-final.diff" 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,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*") --3azmrgwpl5z6x5wt-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 30 08:34:12 2021 Received: (at control) by debbugs.gnu.org; 30 Jul 2021 12:34:13 +0000 Received: from localhost ([127.0.0.1]:59328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RiO-0004dK-Po for submit@debbugs.gnu.org; Fri, 30 Jul 2021 08:34:12 -0400 Received: from quimby.gnus.org ([95.216.78.240]:41862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RiM-0004d7-U2 for control@debbugs.gnu.org; Fri, 30 Jul 2021 08:34:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6lHaWM3pjktFTTIxb6iDnwlGbPBqJux2epi296C+wMg=; b=Ec+qHaxYagGnHhP2w4wtsTsadL b1kSzI/m/Z6T0wtXlVVKrFk9WQrA+mo4bEVYEkf1M3DVoQzX39xrBJUA0ZUyqJFu5h91xKTSd5qzq VbqSnU/HxgnRSt4EvC8U6LpkjYw+u5T94DWEJtppFSgTCwDIZry1wCaN+B9FW6QcCNrg=; Received: from 2.149.45.105.tmi.telenormobil.no ([2.149.45.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9RiF-0007Pg-7G for control@debbugs.gnu.org; Fri, 30 Jul 2021 14:34:05 +0200 Date: Fri, 30 Jul 2021 14:34:01 +0200 Message-Id: <87lf5om152.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #45795 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 45795 + patch quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 45795 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 30 08:40:12 2021 Received: (at 45795) by debbugs.gnu.org; 30 Jul 2021 12:40:12 +0000 Received: from localhost ([127.0.0.1]:59341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RoC-0004n9-Jh for submit@debbugs.gnu.org; Fri, 30 Jul 2021 08:40:12 -0400 Received: from quimby.gnus.org ([95.216.78.240]:41986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RoA-0004mp-J7 for 45795@debbugs.gnu.org; Fri, 30 Jul 2021 08:40:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9aEgmUAxy2Cdd9N8soITJqy7h23NFimQ4mTN/UY+a/s=; b=WxklnKvURoXXkt9qWMuCGEQIy+ XaSIids84bHq8PMg6YQRY3b4vgZY7L4MQEYiSsfuvAMLrLyZC5A2ZYdMg5CScgLWcO5PKZ7J3+IGs 71OORodYO8zHf1eonr2Cl5hoUMzg80sBogDfciXaXIJ77W54mRvCIHkJMp39FHculFXE=; Received: from 2.149.45.105.tmi.telenormobil.no ([2.149.45.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9Ro2-0007UE-0i; Fri, 30 Jul 2021 14:40:04 +0200 From: Lars Ingebrigtsen To: k3tu0isui@gmail.com Subject: Re: bug#45795: 27.1; prolog-mode prolog-system switch bug References: <20210111170922.42anbeq5g6uovhdu@sildranDT.localdomain> <20210112151325.j4gguewyr5ays2a3@sildranDT.localdomain> Date: Fri, 30 Jul 2021 14:39:58 +0200 In-Reply-To: <20210112151325.j4gguewyr5ays2a3@sildranDT.localdomain> (k3tu0isui@gmail.com's message of "Tue, 12 Jan 2021 20:43:25 +0530") Message-ID: <87h7gcm0v5.fsf_-_@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: k3tu0isui@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-pro [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45795 Cc: 45795@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) k3tu0isui@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 From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 30 08:40:18 2021 Received: (at control) by debbugs.gnu.org; 30 Jul 2021 12:40:18 +0000 Received: from localhost ([127.0.0.1]:59345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RoH-0004nQ-Pu for submit@debbugs.gnu.org; Fri, 30 Jul 2021 08:40:17 -0400 Received: from quimby.gnus.org ([95.216.78.240]:42000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9RoG-0004mz-2g for control@debbugs.gnu.org; Fri, 30 Jul 2021 08:40:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yfE0EWuFZtczEVb8JiNVlz+4iah+ZpepOkQdLvIxTuo=; b=K5BBgTb86atsuEbyKNnzJorYtq PIB9qCPu5zahHioBswS1f45gOWLeviiakdj+KvyVSrR2tyjqG3xC7fVY2LDgEqnEHDtrIx+JVfvBm b3h+7jicw+7FYdPdx2diWvQk3CBE0gnIDwPt9Hiyps4a26v1Ubi2aXmbd6fSLvIgcTjQ=; Received: from 2.149.45.105.tmi.telenormobil.no ([2.149.45.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9Ro8-0007UP-2K for control@debbugs.gnu.org; Fri, 30 Jul 2021 14:40:10 +0200 Date: Fri, 30 Jul 2021 14:40:06 +0200 Message-Id: <87fsvwm0ux.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #45795 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 45795 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 45795 28.1 quit From unknown Wed Jun 18 23:10:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 28 Aug 2021 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator