From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id OMjTA4B212V/eAEAqHPOHw:P1 (envelope-from ) for ; Thu, 22 Feb 2024 17:29:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id OMjTA4B212V/eAEAqHPOHw (envelope-from ) for ; Thu, 22 Feb 2024 17:29:52 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=LP9151Ya; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708619391; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ZXgcO6i31JBmH5T8DVWAa3IZjMfhAbfe8b2FSzj+WbA=; b=cFD5/s/oEFFVBUbju8T87fbCPRjbX4tIKragszP/f8M08DT/PF2zb7Jkpm9o8Z0y61+q4V sBs359Q6vBq2mHAA7uEVWpi0+vE2iLEM4sYO2/IbUdiAni3NHrRzcleyWvwLQFyb6/zELi GchFXHh5vZjjRQG/hlJquy0aGcsH6faPzPpqGmbNDEhJIITvXsGsg/SMlU03EhgiV7oUJr i48GhDnxZvcNxJUpIAcPfLzoEoWb9KhxqeTi2BOAWoOVClDeF/p1RRqSCtXkw06Y36ZDfm g2YxdFurlQO25GM98y8xR0uqjc2uvd3eL2aO+HLycQj6QlwCHmyNhKzVPzfyPA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=LP9151Ya; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708619391; a=rsa-sha256; cv=none; b=dUYpy/2gw67/enMcGe1Mg3isThA/dM08mfqngLfHGRh+PuVIKcsA5yN6AsErKYVoisaQQR zChjm+oUwm3qsW4xnCCJsQ8VMEe0Wng58GZF1jZd4oJ7hguMcyRisbYF+v0vaxBLPuQTKi 1XOgliubjfprPiho15pk70y18JJTOG43HD2alWrMfBhFdDkt7OS/0MdyQI9ulA43lQI3N9 EvYr7R1/+rrrKa4pbw5l5M9MeHYyQnzPkBImmIVz1H/hjbb+xcg1We2em3aGoR+3mLwaFT l46eAy1vVwiUwlcHPLaIQTBL9pubXkbWkDwCbSw/plj/9k0fWbEMmalm9QzLwg== 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 995586D8F7 for ; Thu, 22 Feb 2024 17:29:51 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdBwN-0004Bg-KF; Thu, 22 Feb 2024 11:28:55 -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 1rdBwM-0004B8-3W for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 11:28:54 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdBwI-0007YL-JW for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 11:28:53 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6840E240103 for ; Thu, 22 Feb 2024 17:28:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1708619328; bh=U9HJ6RzQqvkGOS4lc0Nh6Z2XDQ2yslpY2mikxjPTVZk=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Cc:Subject:Message-ID:From; b=LP9151Ya7tATupUWpzHlj3/S43MA6i5ZrWqqkhe57zPr7DBZgKnsPuVqqIFGXNn5X QgaJOOqpSuTiKhPljljfI6HgF4zzqjXz2HkG7B2iCNxZe0VmdxeYH9F5QVbx+5o1D/ /KLNqCFyxwkAoKEkavB236JO6OIfMeVtjKtOBimU2k2CPGzTR+SPGp6Ieo79pDK3DF 6otYJGsdwjTh5fuQI5TMpJGncoDnIjuLK8lN+1oD8PsYwQEEdmZfEhL1s2Vy74233Y uGdZbGEexRhUyLNaDXXARWS94rhfAFiGbvsmx6+8Cfd7YtWfszR1h3zG4Hb7jWRfuq Y4fqPYE5fQ2xg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Tgdqz4pTXz9rxQ; Thu, 22 Feb 2024 17:28:47 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Thu, 22 Feb 2024 16:28:47 +0000 From: gerard.vermeulen@posteo.net To: Ihor Radchenko Cc: Emacs orgmode , emacs-orgmode-bounces+gerard.vermeulen=posteo.net@gnu.org Subject: Re: [PATCH] org-babel-demarcate-block: split using element API In-Reply-To: References: <7e41f9b6e9026a404e256f33371e974c@posteo.net> <87v88a78qd.fsf@localhost> <7f23ea966f0f0aad3fad29b0b96864f3@posteo.net> <87y1d55fc6.fsf@localhost> <37fdcc4bfcf734c2e5ec439d40b4f7d8@posteo.net> <878r50yqmo.fsf@localhost> <442006329cfba666710c989aece5191a@posteo.net> <261356c53e857e0bc4b04f884366edfa@posteo.net> <87bk9uy31w.fsf@localhost> <680e4a4fccf4f3c5c8f51d8215257eff@posteo.net> <87a5p9uute.fsf@localhost> <87wmscrty4.fsf@localhost> <2c82fa1399ddaa52ebe5bb21e241fb5f@posteo.net> <87o7dll7vn.fsf@localhost> <874je4hjmr.fsf@localhost> <87frxmtasr.fsf@localhost> Message-ID: Received-SPF: pass client-ip=185.67.36.66; envelope-from=gerard.vermeulen@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -8.12 X-Spam-Score: -8.12 X-Migadu-Queue-Id: 995586D8F7 X-TUID: P8qF2t8JBMnS On 21.02.2024 19:19, gerard.vermeulen@posteo.net wrote: > On 21.02.2024 10:40, Ihor Radchenko wrote: >> gerard.vermeulen@posteo.net writes: [...] >> May you please provide more details? >=20 This is different of what I saw before: When splitting python blocks in an org file I got a long list of=20 warnings: Warning (org-element): =E2=80=98org-element-at-point=E2=80=99 cannot be use= d in non-Org=20 buffer # (python-mode) until it stopped by itself. I traced this to user-errors in my own `org-babel-edit-prep:python'=20 which I use to let eglot handle python source blocks. I rewrote my `org-babel-edit-prep:python' to get rid of user-errors but then I bumped on the user-error coming from=20 `org-src--make-source-overlay'. I think that this may be the case for other definitions of=20 `org-babel-edit-prep:LANG' I copy my `org-babel-edit-edit-prep:python' without user-errors below: #+begin_src emacs-lisp -n :results silent (with-eval-after-load 'emacs (defcustom eglot-maybe-ensure-modes '(python-mode) "Modes where maybe `eglot-ensure' should be or has been called. This may be in the case of proper directory local variables or in the case of proper `org-src-mode' buffers.") ;; https://www.reddit.com/r/emacs/comments/w4f4u3 ;; /using_rustic_eglot_and_orgbabel_for_literate/ (defun eglot-org-babel-edit-prep (info) "Try to setup an `org-mode-src' buffer to make `eglot-ensure'=20 succeed. INFO has a form similar to the return value of `org-babel-get-src-block-info'. Try to load the tangled file into the `org-src-mode' buffer as well as to narrow the region to the Org-mode source block code before calling `eglot-ensure'." (when-let ((ok (bound-and-true-p org-src-mode)) (mark (point)) (body (nth 1 info)) (filename (cdr (assq :tangle (nth 2 info))))) (when (string=3D filename "no") (message "Org source block has no tangled file") (setq ok nil)) (when ok (setq filename (expand-file-name filename)) (unless (file-readable-p filename) (message "Tangled file %s is not readable" filename) (setq ok nil))) (when ok (with-temp-buffer (insert-file-contents filename 'visit nil nil 'replace) (unless (search-forward body nil 'noerror) (message "Org source block does not occur in tangled file=20 %s" filename) (setq ok nil)) (when (search-forward body nil 'noerror) (message "Org source block occurs twice or more in tangled=20 file %s" filename) (setq ok nil)))) (when ok (goto-char (point-min)) (insert-file-contents filename 'visit nil nil 'replace) (search-forward body) (narrow-to-region (match-beginning 0) (match-end 0)) (goto-char mark) (eglot-ensure)) ;; (message "Buffer %s is no `org-src-mode' buffer" (buffer-name)) )) (defun org-babel-edit-prep:python (info) (eglot-org-babel-edit-prep info))) #+end_src Regards -- Gerard