From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id kN7uECq3zWMhHQAAbAwnHQ (envelope-from ) for ; Sun, 22 Jan 2023 23:22:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iAPwECq3zWN+bwAA9RJhRA (envelope-from ) for ; Sun, 22 Jan 2023 23:22:34 +0100 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 C55F42EDB4 for ; Sun, 22 Jan 2023 23:22:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJiiY-0002Qv-MR; Sun, 22 Jan 2023 17:21:38 -0500 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 1pJiiX-0002Qn-5Y for emacs-orgmode@gnu.org; Sun, 22 Jan 2023 17:21:37 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pJiiV-0008EJ-2i; Sun, 22 Jan 2023 17:21:36 -0500 Received: by mail-pj1-x102c.google.com with SMTP id k10-20020a17090a590a00b0022ba875a1a4so6729495pji.3; Sun, 22 Jan 2023 14:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=q2SnZHcgA+IgL8EYFM9xIRXqdbUCm88NuEdnwrMSXwg=; b=IsbfoIzkePrPQOU6no0I9/PiCExFbgBIzAlcaVX0vRLU0jlUZpSvYqB5o4HxMfTUXV 9xmCEuPtzIadq8C0nU4i132TWXWNIPdD0a1yeRNcbyTq2m1xBoRUoLXLlQ/5011oHF4p SK813/0JC19Tp6D/6Gn8GqmdObTNtWy60vspgV6lJJzatmfwBhKSR9G7iMCXBX7UCIXp rgIEQZwviQ1y7GQGJRo2D4p5sU8m5R0ba3XrafRS1M9udYnPSDN5jqxWavp+mmCybmxt hd43cosZQJce9dO+N3wtpo2v+Fk17A/dyQoslpa67gNtx1bkrmt4Tmy69gOMvmXuexzR PmLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=q2SnZHcgA+IgL8EYFM9xIRXqdbUCm88NuEdnwrMSXwg=; b=gjXpqhz9hxE8IAa3CGj3fIGNjeTkPAw0Qs+7uMj9rQkSFAphS74U4oeYCmsBV9zW96 BloCyYjBrriKo48g4H+Lvnppo7RHblJ2IMLz1QEKgScmf2LcuCEBd555c7THEEzsgqnL A3567qgkq+valBXi2WfZ7/4zj3gx96bSIKRbfGhwQD5R/5CyHWI9pmqKyJWplqxSSlV3 t4aMP3cAmjlyt8hQNA+VwBj6WfQkmRD3DzGBn2ygHbcj6dkvFseYVLiqZQlulclPFblP J6ArmkEwLWWsaJAjYYUQqkivr0oIo1xRmG1bfrW45hkaMBWycshC70fhF5m/5aymheTc KMUQ== X-Gm-Message-State: AFqh2kqusfOekAwwMxoSZDN3phLhmk4lwlCK3h3iKdpEPcr4/VGu4PGL kVaZ5lmcKGqy4GX5v468yxIDdvmOzXw= X-Google-Smtp-Source: AMrXdXt+dB21LU0oQENnA50+1xxpouEW7UXbznDj73RPVUviiS/EqQvZl2VCGhdb7Qz6w12Ar73gHA== X-Received: by 2002:a05:6a20:be1d:b0:b8:7e6d:5b52 with SMTP id ge29-20020a056a20be1d00b000b87e6d5b52mr21455285pzb.38.1674426091803; Sun, 22 Jan 2023 14:21:31 -0800 (PST) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id a19-20020aa79713000000b0058e0bad6705sm6088267pfg.67.2023.01.22.14.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jan 2023 14:21:30 -0800 (PST) From: Jack Kamm To: Ihor Radchenko , Bastien Guerry Cc: emacs-orgmode@gnu.org Subject: Re: [DISCUSSION] Should we deprecate python-mode.el (alternative to built-in python.el) support in ob-python? In-Reply-To: <87wn6atjid.fsf@localhost> References: <87bkprid1d.fsf@localhost> <87mt9am16j.fsf@gmail.com> <87r0yk7bx8.fsf@localhost> <87r0xqla74.fsf@localhost> <87r0xq8dk9.fsf@gnu.org> <87wn6atjid.fsf@localhost> Date: Sun, 22 Jan 2023 14:21:29 -0800 Message-ID: <877cxe2ot2.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=jackkamm@gmail.com; helo=mail-pj1-x102c.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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674426153; a=rsa-sha256; cv=none; b=D3ojDChRy/N1YQbVMUJVMThe0FvJfbmUZALv5yoJpprTC+zlg6nysQ3dlHusBVAAs842h4 4KCxK/unB6lgDCFVNy4ELyE5SvGttg61KU5H74m8y8QjSS3CXatvjRa0hZZBydv6Hd7eGW Oc7EPJKaOqfQ+YPbi/Z8x4xXM6DVC98sXuybuYvJQn5ljKajBui919x3S7cqFL2L3zR1Tg 3kb1Ow4sOCj9MfcJl5AJV0KqhkFmLgBuucJyRHMnmQRT8O3eAX8mBqawyMNNsk/hdRJYLd nHeIN7ZM778FUgru/NQ7hbJSSmV/W4s8SEEz1JVrrA11d7U4T5JjU9QQkyW75A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IsbfoIzk; 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=1674426153; 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=q2SnZHcgA+IgL8EYFM9xIRXqdbUCm88NuEdnwrMSXwg=; b=YM8Ptjs3Dnc1I9i58jNmmcsRiy/kyRv/rzSjdDOlNB0uHT+ODKSTTvVNs2UfZkSb0OuBEc k2nI/3IC+yIGB2cTMkL9wvchdj76Xqjk82A6ClIs2Nc/WgKFxXVP8OjllMu+79nAZ/HU3s e7mGpWjQ1+gR95Qe1DJZTB9rDmQGk84LR3wqByHVM2nm3wyA47nahBRKLVDID3TNL2D3w4 BRy67GbZ3+xgKUXG78zZWI5kCQ0TbQTjN1B2pI2Y+skj8YhuzszLh2nJpMOlJz31G7utSh Ocke+cBXvNUsrtoM2ajqo9JsVU1Pn0rmcOIw58E0mSVPflOm7736+/UBOoUEEg== X-Spam-Score: -8.75 X-Migadu-Queue-Id: C55F42EDB4 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IsbfoIzk; 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" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -8.75 X-TUID: e3dUCxVE6XS3 --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Marked for future removal in ob-python.el. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=21741a469 Thanks Ihor. Not sure if it's too early for this, but I've prepared a patch to remove the support for python-mode.el, attached. Also, to help any python-mode users with the transition, I ported the code to support python-mode to an external package here: https://gitlab.com/jackkamm/ob-python-mode-mode As always, feedback is welcome, either on this patch or the external package. Best, Jack --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-python-Remove-python-mode.el-support.patch >From 44bdfbbd9858f4190e4404467fa61b8a3f445347 Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Sat, 21 Jan 2023 08:24:41 -0800 Subject: [PATCH] ob-python: Remove python-mode.el support * lisp/ob-python.el (org-babel-python-mode): Remove customization variable. (org-babel-python-initiate-session-by-key): Remove code to support python-mode.el. (org-babel-python-send-string): Renamed from org-babel-python--send-string, turning it into a public function to accommodate ob-python-mode-mode which advises this function. Also, remove some code for python-mode.el (org-babel-python-evaluate-session): Update calls to renamed function org-babel-python-send-string. --- etc/ORG-NEWS | 10 ++++++ lisp/ob-python.el | 88 +++++++++++++---------------------------------- 2 files changed, 34 insertions(+), 64 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 3ef76ec1a..ad7bd6604 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -12,6 +12,16 @@ See the end of the file for license conditions. Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) +** Important announcements and breaking changes +*** =python-mode.el (MELPA)= support in =ob-python.el= is removed + +=python-mode.el= support has been removed from =ob-python.el=. The +related customization =org-babel-python-mode= has also been removed. + +If you still want to use python-mode with ob-python, you might +consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]], where the code to support python-mode +has been ported to. + ** New options *** New options for the "csl" citation export processor's LaTeX output diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 39fe5c28d..f19440e00 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -36,10 +36,6 @@ (require 'ob) (require 'org-macs) (require 'python) -(declare-function py-shell "ext:python-mode" (&rest args)) -(declare-function py-choose-shell "ext:python-mode" (&optional shell)) -(declare-function py-shell-send-string "ext:python-mode" (strg &optional process)) - (defvar org-babel-tangle-lang-exts) (add-to-list 'org-babel-tangle-lang-exts '("python" . "py")) @@ -52,16 +48,6 @@ (defcustom org-babel-python-command "python" :group 'org-babel :type 'string) -;; FIXME: Remove third-party `python-mode' package support in the next release. -(defcustom org-babel-python-mode - (if (featurep 'python-mode) 'python-mode 'python) - "Preferred python mode for use in running python interactively. -This will typically be either `python' or `python-mode'." - :group 'org-babel - :version "24.4" - :package-version '(Org . "8.0") - :type 'symbol) - (defcustom org-babel-python-hline-to "None" "Replace hlines in incoming tables with this when translating to python." :group 'org-babel @@ -183,7 +169,6 @@ (defun org-babel-python-without-earmuffs (session) (substring name 1 (- (length name) 1)) name))) -(defvar py-which-bufname) (defvar python-shell-buffer-name) (defvar-local org-babel-python--initialized nil "Flag used to mark that python session has been initialized.") @@ -197,47 +182,25 @@ (defun org-babel-python-initiate-session-by-key (&optional session) (cmd (if (member system-type '(cygwin windows-nt ms-dos)) (concat org-babel-python-command " -i") org-babel-python-command))) - (cond - ((eq 'python org-babel-python-mode) ; python.el - (unless py-buffer - (setq py-buffer (org-babel-python-with-earmuffs session))) - (let ((python-shell-buffer-name - (org-babel-python-without-earmuffs py-buffer))) - (run-python cmd) - (with-current-buffer py-buffer - (add-hook - 'python-shell-first-prompt-hook - (lambda () - (setq-local org-babel-python--initialized t) - (message "I am running!!!")) - nil 'local)))) - ((and (eq 'python-mode org-babel-python-mode) - (fboundp 'py-shell)) ; python-mode.el - (require 'python-mode) - ;; Make sure that py-which-bufname is initialized, as otherwise - ;; it will be overwritten the first time a Python buffer is - ;; created. - (py-choose-shell) - ;; `py-shell' creates a buffer whose name is the value of - ;; `py-which-bufname' with '*'s at the beginning and end - (let* ((bufname (if (and py-buffer (buffer-live-p py-buffer)) - (replace-regexp-in-string ;; zap surrounding * - "^\\*\\([^*]+\\)\\*$" "\\1" py-buffer) - (concat "Python-" (symbol-name session)))) - (py-which-bufname bufname)) - (setq py-buffer (org-babel-python-with-earmuffs bufname)) - (py-shell nil nil t org-babel-python-command py-buffer nil nil t nil))) - (t - (error "No function available for running an inferior Python"))) + (unless py-buffer + (setq py-buffer (org-babel-python-with-earmuffs session))) + (let ((python-shell-buffer-name + (org-babel-python-without-earmuffs py-buffer))) + (run-python cmd) + (with-current-buffer py-buffer + (add-hook + 'python-shell-first-prompt-hook + (lambda () + (setq-local org-babel-python--initialized t) + (message "I am running!!!")) + nil 'local))) ;; Wait until Python initializes. - (if (eq 'python org-babel-python-mode) ; python.el - ;; This is more reliable compared to - ;; `org-babel-comint-wait-for-output' as python may emit - ;; multiple prompts during initialization. - (with-current-buffer py-buffer - (while (not org-babel-python--initialized) - (org-babel-comint-wait-for-output py-buffer))) - (org-babel-comint-wait-for-output py-buffer)) + ;; This is more reliable compared to + ;; `org-babel-comint-wait-for-output' as python may emit + ;; multiple prompts during initialization. + (with-current-buffer py-buffer + (while (not org-babel-python--initialized) + (org-babel-comint-wait-for-output py-buffer))) (setq org-babel-python-buffers (cons (cons session py-buffer) (assq-delete-all session org-babel-python-buffers))) @@ -352,7 +315,7 @@ (defun org-babel-python-evaluate-external-process raw (org-babel-python-table-or-string (org-trim raw))))) -(defun org-babel-python--send-string (session body) +(defun org-babel-python-send-string (session body) "Pass BODY to the Python process in SESSION. Return output." (with-current-buffer session @@ -370,12 +333,9 @@ (defun org-babel-python--send-string (session body) print('%s')" (org-babel-python--shift-right body 4) org-babel-python-eoe-indicator))) - (if (not (eq 'python-mode org-babel-python-mode)) - (let ((python-shell-buffer-name - (org-babel-python-without-earmuffs session))) - (python-shell-send-string body)) - (require 'python-mode) - (py-shell-send-string body (get-buffer-process session))) + (let ((python-shell-buffer-name + (org-babel-python-without-earmuffs session))) + (python-shell-send-string body)) ;; same as `python-shell-comint-end-of-output-p' in emacs-25.1+ (while (not (string-match org-babel-python-eoe-indicator @@ -398,12 +358,12 @@ (defun org-babel-python-evaluate-session (let ((body (format org-babel-python--exec-tmpfile (org-babel-process-file-name tmp-src-file 'noquote)))) - (org-babel-python--send-string session body))) + (org-babel-python-send-string session body))) (`value (let* ((tmp-results-file (org-babel-temp-file "python-")) (body (org-babel-python-format-session-value tmp-src-file tmp-results-file result-params))) - (org-babel-python--send-string session body) + (org-babel-python-send-string session body) (sleep-for 0 10) (org-babel-eval-read-file tmp-results-file))))))) (org-babel-result-cond result-params -- 2.39.1 --=-=-=--