From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 4EtJNRurFGeFXgEAqHPOHw:P1 (envelope-from ) for ; Sun, 20 Oct 2024 07:02:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 4EtJNRurFGeFXgEAqHPOHw (envelope-from ) for ; Sun, 20 Oct 2024 09:02:52 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J7LXRTYj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1729407771; a=rsa-sha256; cv=none; b=n3m9hDKic6k7Ft8WKt/Kli4z5FdkqBvSuEcAk6rHmVvwT2G4sHHUfd+6bCY78BWVM5sSMH 32iPW149CawYt4yaFrBMo5tIljbQL4QWTV5M/N+LYuuywhmkq8MiXKtTRk4hyrJvw8Qxtx gnMDE1cpxAPa0Csf+Fge+zltSywWn4GcNOdprKcOYjnSz4A7fu/hCnO2WSVRfdGTpl+CNi SEJ3arSz8bePlMbAv4dd4xylQdsYmKlEoVD3jlTVSk8wlhis7d7pCfY95k5dq+WRVMh7h1 bVuNc9mwNah8ixyHVGXkC4bqX2m34lRWh9Dem4cyWSWlphdIb3n+eXteojSN+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J7LXRTYj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1729407771; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=OsUKWltZDPbOs44d7UVy5LvgHFqzdNLfQyAp8QnDR6c=; b=E5hAQKMmh6JQuwjcfF/KktLUru204Y2Nz834i91yUxfF86QjpRYXtj0woRVuW0f4kbghvo AEtLQIj0jDvCAhHoE9U/RoA7pKEXWey90KsAiIoV3TabbJTvXTfft2+rTmDNm1EMX7x2ka rh/fop7pUoQkhh9k4OGxzQlSZF8P4xa485n5kFAiCdsYaltlMAWqGiN2uvzTIpjinu1ED1 dXE0qLrETbFg7m73yPzVPO9pIppy39DEt6XuEkhL92swoUWJ59ZpOeneCY/FAfUeC2cbFP C9ikjnOo0gmOF84sRK8LZnsLg1d1xiphl9q06umcekZuT1KwJA5KNmEVQu3SmA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 291D88F831 for ; Sun, 20 Oct 2024 09:02:51 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2Pwr-0001Ia-BN; Sun, 20 Oct 2024 03:01:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2Pwp-0001IC-9a for emacs-orgmode@gnu.org; Sun, 20 Oct 2024 03:01:55 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t2Pwn-0007sF-Ce for emacs-orgmode@gnu.org; Sun, 20 Oct 2024 03:01:55 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-20c8c50fdd9so28473055ad.0 for ; Sun, 20 Oct 2024 00:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729407711; x=1730012511; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=OsUKWltZDPbOs44d7UVy5LvgHFqzdNLfQyAp8QnDR6c=; b=J7LXRTYjLS5SF7aDDEHXmf5hJq5BmMnnM05uHSvElDgSEsZV9tmd8+r8bxA50hlHp1 VA3iCK4hqJR11cnXRiCgIu4haAsnD+MGQJZap580jbvWz8+9FcEc54bY1TVheLC4Abit mZzbuWHUdifaN8BJncYqhv++GFNVqNYGW/XKpmTSoF0knb6DyE7cWncG5dNA2ux0Gs8j w1cv17JO61iI1I7CpvZe+uX7ZN79bujGlrnBEoyTK/KDmWutFAOvamhyI1CRizJK6iUf NT+APXCGwMNcbPeTXCoCn+bgQtAIUhKbW6I1dX7tvoM57HwabPLfN7w464y8nVOzr+4r uMjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729407711; x=1730012511; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OsUKWltZDPbOs44d7UVy5LvgHFqzdNLfQyAp8QnDR6c=; b=aTh3p90RQ79MUSFbvZuSiip7AIGqOmBFp3E/gN6Wu0nMsFyU0HvlffXXmH01kt0Qyo DBmSVC4WeQZJHlJOaFjy3RR8tXPpHV5IjrGFxzMfc7RSdCFCZX7GGxgAPXepBXm/+GMK AZQdE5+TT77kMqoBM9gUFbqwR26O+N423VEFHwT+CBw1irC/K+7I7wG6XrpGWmIyIdHM buZKtOTiPDzsmipJKjDJqqmZwaQYtAATtbtgVXvV270SBS9vCfubd0gTso2u7h+cL8mt d0rBo2w/bcQV20mSkctoIUOltQjOFidarL04CMu8JUtCP6IIwqbKjZLB2Z4r86fBP2xH G/5g== X-Gm-Message-State: AOJu0Yw4vGAfaVGyui65+j24WQx+02XHHCL5rUSPoMSuWLx4iu5BZa2g qk3s12xTIK/RJexXv4ENmsLbdB7+5tiaaxDvBOGtUFsku7ixt20E X-Google-Smtp-Source: AGHT+IES4Cu/dazDF4z2QDLhe6tjr6agJ4Eqj2DdErbubS/MxL60Up/plEFUAeNe4WlCEf4yp4gifQ== X-Received: by 2002:a05:6a20:b58b:b0:1d9:281f:2f27 with SMTP id adf61e73a8af0-1d92cb56961mr10506097637.19.1729407711064; Sun, 20 Oct 2024 00:01:51 -0700 (PDT) Received: from localhost ([198.27.183.102]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1356780sm714506b3a.90.2024.10.20.00.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 00:01:49 -0700 (PDT) From: Jack Kamm To: Ihor Radchenko Cc: emacs-orgmode@gnu.org, matt@excalamus.com, jeremiejuste@gmail.com Subject: Re: [PATCH] Async sessions: Fix prompt removal regression in ob-R In-Reply-To: <87h698wml2.fsf@localhost> References: <87setrqs4z.fsf@gmail.com> <87wmiqigfp.fsf@localhost> <87wmi9etku.fsf@gmail.com> <87h698wml2.fsf@localhost> Date: Sun, 20 Oct 2024 00:01:48 -0700 Message-ID: <87ed4b45r7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=jackkamm@gmail.com; helo=mail-pl1-x62e.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: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -1.56 X-Spam-Score: -1.56 X-Migadu-Queue-Id: 291D88F831 X-Migadu-Scanner: mx12.migadu.com X-TUID: kR9eQPgYZvl9 --=-=-= Content-Type: text/plain Ihor Radchenko writes: > I have one small nipick comment on the patch: > >> (org-babel-comint-async-register >> session (current-buffer) >> "ob_comint_async_python_\\(start\\|end\\|file\\)_\\(.+\\)" >> - 'org-babel-chomp 'org-babel-python-async-value-callback) >> + 'org-babel-chomp 'org-babel-python-async-value-callback >> + t) > > Rather than `t', I'd use something more descriptive like 'disable-prompt-filtering. Is the attached patch what you had in mind? If so I will squash it with the previous patch. You can also see both commits together in my branch here: https://github.com/jackkamm/org-mode/tree/2024-ob-r-async-prompt-bugfix2 > Looks reasonable in general. Thanks, look forward to applying it. But first -- note that the current patch is on top of bugfix. I had mentioned this in my original email but want to double check if it's OK. In particular, I'm not sure if it's acceptable for bugfix branch anymore, now that I'm changing the function signature of `org-babel-comint-async-register' (albeit in a backward-compatible way). I had originally proposed bugfix since I use R's table() function a lot (as in my original example), and it was causing me problems when I belatedly upgraded my work machine to Org 9.7. But if you prefer, I can rebase onto main. Another possibility would be to add a hardcoded check on bugfix to skip the prompt filtering if the major-mode is R or Python; then on main, revert the hard-coded check, and update the signature of `org-babel-comint-async-register' to set it properly with a variable. But not sure it's worth the hassle -- I might just switch to using main branch on my work machine at that point. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-to-be-squashed-with-previous-commit.patch >From f155c878ffa9f7244bdae417b824ffa6c4d92742 Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Sat, 19 Oct 2024 23:46:03 -0700 Subject: [PATCH 2/2] to be squashed with previous commit --- lisp/ob-R.el | 2 +- lisp/ob-comint.el | 21 +++++++++++++++------ lisp/ob-python.el | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 08d8227f0..5a8dfe22c 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -487,7 +487,7 @@ (defun ob-session-async-org-babel-R-evaluate-session "^\\(?:[>.+] \\)*\\[1\\] \"ob_comint_async_R_\\(start\\|end\\|file\\)_\\(.+\\)\"$" 'org-babel-chomp 'ob-session-async-R-value-callback - t) + 'disable-prompt-filtering) (cl-case result-type (value (let ((tmp-file (org-babel-temp-file "R-"))) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index f37aa5264..ea42eaccd 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -360,21 +360,30 @@ (defun org-babel-comint-async-filter (string) (defun org-babel-comint-async-register (session-buffer org-buffer indicator-regexp chunk-callback file-callback - &optional inhibit-prompt-removal) + &optional prompt-handling) "Set local org-babel-comint-async variables in SESSION-BUFFER. ORG-BUFFER is added to `org-babel-comint-async-buffers' if not present. `org-babel-comint-async-indicator', `org-babel-comint-async-chunk-callback', and `org-babel-comint-async-file-callback' are set to INDICATOR-REGEXP, CHUNK-CALLBACK, and FILE-CALLBACK respectively. -If INHIBIT-PROMPT-REMOVAL, -`org-babel-comint-async-remove-prompts-p' is set to `nil' to -prevent prompt detection and removal from async output." +PROMPT-HANDLING may be either of the symbols `filter-prompts', in +which case prompts matching `comint-prompt-regexp' are filtered +from output before it is passed to CHUNK-CALLBACK, or +`disable-prompt-filtering', in which case this behavior is +disabled. For backward-compatibility, the default value of `nil' +is equivalent to `filter-prompts'." (org-babel-comint-in-buffer session-buffer (setq org-babel-comint-async-indicator indicator-regexp org-babel-comint-async-chunk-callback chunk-callback - org-babel-comint-async-file-callback file-callback - org-babel-comint-async-remove-prompts-p (not inhibit-prompt-removal)) + org-babel-comint-async-file-callback file-callback) + (setq org-babel-comint-async-remove-prompts-p + (let ((prompt-handling (or prompt-handling 'filter-prompts))) + (cond + ((eq prompt-handling 'disable-prompt-filtering) nil) + ((eq prompt-handling 'filter-prompts) t) + (t (error (format "Unrecognized prompt handling behavior %s" + (symbol-name prompt-handling))))))) (unless (memq org-buffer org-babel-comint-async-buffers) (setq org-babel-comint-async-buffers (cons org-buffer org-babel-comint-async-buffers))) diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 38ebe9147..f41f44dbd 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -539,7 +539,7 @@ (defun org-babel-python-async-evaluate-session session (current-buffer) "ob_comint_async_python_\\(start\\|end\\|file\\)_\\(.+\\)" 'org-babel-chomp 'org-babel-python-async-value-callback - t) + 'disable-prompt-filtering) (pcase result-type (`output (let ((uuid (org-id-uuid))) -- 2.46.2 --=-=-=--