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: [PATCH] prolog-mode run-prolog and prolog-consult-file fixes when prolog-system changes Date: Tue, 12 Jan 2021 20:43:25 +0530 Message-ID: <20210112151325.j4gguewyr5ays2a3@sildranDT.localdomain> References: <20210111170922.42anbeq5g6uovhdu@sildranDT.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="3azmrgwpl5z6x5wt" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10295"; 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 Tue Jan 12 16:14:30 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 1kzLNH-00023f-Cd for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Jan 2021 16:14:23 +0100 Original-Received: from localhost ([::1]:44312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzLNG-0000ei-8L for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Jan 2021 10:14:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzLMw-0000eL-4P for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 10:14:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzLMv-0002Jb-Tv for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 10:14:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kzLMv-0004E4-OS for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 10:14:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <20210111170922.42anbeq5g6uovhdu@sildranDT.localdomain> Resent-From: k3tu0isui@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Jan 2021 15:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45795 X-GNU-PR-Package: emacs Original-Received: via spool by 45795-submit@debbugs.gnu.org id=B45795.161046443616224 (code B ref 45795); Tue, 12 Jan 2021 15:14:01 +0000 Original-Received: (at 45795) by debbugs.gnu.org; 12 Jan 2021 15:13:56 +0000 Original-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 Original-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 Original-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) Original-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) Content-Disposition: inline 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:197796 Archived-At: --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--