From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 kFozHt802WJzcAAAbAwnHQ (envelope-from ) for ; Thu, 21 Jul 2022 13:13:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QBQ5Hd802WJZvgAAG6o9tA (envelope-from ) for ; Thu, 21 Jul 2022 13:13:35 +0200 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 067972C6DA for ; Thu, 21 Jul 2022 13:13:35 +0200 (CEST) Received: from localhost ([::1]:60196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEU7Z-0006S7-PX for larch@yhetil.org; Thu, 21 Jul 2022 07:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEU6g-0006Qy-Tn for emacs-orgmode@gnu.org; Thu, 21 Jul 2022 07:12:38 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:40466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEU6e-0007nP-JF for emacs-orgmode@gnu.org; Thu, 21 Jul 2022 07:12:38 -0400 Received: by mail-pl1-x636.google.com with SMTP id y24so1488685plh.7 for ; Thu, 21 Jul 2022 04:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=N44e+PO2dOt6YFkFBH4oKEz00UPczCV8egJTa3tVrEw=; b=MwT03wqH30kC4h/pziBQddp3S6CBUpRxfxp9Nh/uvmKk33Gs+/PGHBeT801hiG2Ylf IN1Kpg4caxI2g5r7rY/SmdI/La0wtwhkU1dTCx6kXnUbFKjde7597L5jAugLxTbkWvQp VhUNRkOPoD8EMzin85BK8TOdbXfdGeVfAJqlM5AIsIvl0r2k7c7hXarMS3Z3hJ9wq94r mK4BOI7Ng6eS8kmu1pyA2dWy5Ah6lLbj5Rjim9y0wi6pv2zLiK7xN7wc24ZD4j5DCJng X6C+nNZFAArqGUpOtv3XenuX04EihswKQFibNhKLxXUFAgWSzAv6dsjTfAryTeOEeROS Sd+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=N44e+PO2dOt6YFkFBH4oKEz00UPczCV8egJTa3tVrEw=; b=ExaegFNF/SoAHLFyaXXzlMrbpSYikP3aoY+joRQ3lLOJHDv02kVSqmJ1KGnFanGRNQ GxJu6DVvOIUujJ6SgGZ7Lil1R6bcNTJ84CrSEWqJX0uelyz5WurLtx1yCcXuYLKJbtIj SJPbZjGpL2QoIjMOLcdqiEtMuFgGCwltGDcoDGX3uEH9AuV0zkUePPZHTJu+SJOYVV4M V7d2iHvewSHq0pk00kmvTdBo/rQ3q4RkNgs6uH+NEbZxHAro0nhlk0tLqCh6oxcAdJuk WeeJmTd0o/l02cQn/si2YYR6cpgz8fdreeNgGFHxt55v7ho31HhjSQEdk535wAqSMnpA UDtQ== X-Gm-Message-State: AJIora/w5UeUiZiYJnlH9u50JpowBPDVs5eFFkH5b3JE9fnymIThA+wg YhJm5vVX9vXvoPL4FVvvPY/jPvaAxuv6fg== X-Google-Smtp-Source: AGRyM1t364GbcNdkWlXwqliBeygKFzjJkrMD7yomPJ/78OW9v3axJSJY62rlPp5sohStDBIBYQlwgQ== X-Received: by 2002:a17:90a:404f:b0:1f2:126b:ba29 with SMTP id k15-20020a17090a404f00b001f2126bba29mr10917116pjg.74.1658401954598; Thu, 21 Jul 2022 04:12:34 -0700 (PDT) Received: from localhost ([2409:8a70:2b7:3fb0:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id b19-20020a62a113000000b0052ba88f2de0sm1474631pff.131.2022.07.21.04.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 04:12:33 -0700 (PDT) From: Ihor Radchenko To: sebastien.miquel@posteo.eu Cc: emacs-orgmode Subject: [PATCH] org-babel: Do not echo output of resolved noweb references In-Reply-To: <7702b511-c289-5688-c64c-fb673324a63a@posteo.eu> References: <2dd9630a-c584-0702-62aa-393ad56c621e@posteo.eu> <875ymt8goc.fsf@localhost> <87v8urt8bu.fsf@localhost> <03eb4c66-ecaf-b5f5-c4cc-2195fb6c1a1a@posteo.eu> <87y1yiz3js.fsf@localhost> <7702b511-c289-5688-c64c-fb673324a63a@posteo.eu> Date: Thu, 21 Jul 2022 19:13:38 +0800 Message-ID: <87fsiu3ehp.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=yantar92@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1658402015; 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=N44e+PO2dOt6YFkFBH4oKEz00UPczCV8egJTa3tVrEw=; b=P8fE2efqRuBT06EqYYN68Ti53a5TbutcXSAS8Xy+1bq/BsmxO7FcyBOphX7QrA0pCHW32D 9QMoqKJusRuoprvkQNalxX0jsmAZNDKzYqR3OUd2UO8KJKZc6gMmkZAVXN9fDI7J76dZ6A Udpx3nogFfAmjYkb2bKowLQJqExL+K1Nf/Fs4qKfv9teYybJ6X3LR1shNHYftX2O0ki4il jsGuhzUswnDe36hZK6AhJ0X7lVBYNxM5IqM1oIEzGN6KS8bnUXgMNeEJJ6BCQjpPHxgm48 NUzWiWRx69wVntcJcL9FvqmysTahWI2l9OjVwLOP6tihF5gKgRecP79dXf1A9A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658402015; a=rsa-sha256; cv=none; b=d+PZarmBXpSbPj3CBevGw1qG9gzqFhlf2z7k3wBnEdkrLCyUtxSOPR4XVpe5cxMOXyfv+d 6cbx5XYQSFScGskZzyYUX0o1FNGQFUC1lXyQMOKyaBmP6HKBfHDxzGQ+ApoEehJsXQKQrQ M/EIob033TMWFZc2OQp6nVZm34gwy0GFfj+7TIreMCxthcJhxoJIZKE/OskCk+bZVLc9q1 Vby3zKWYwGlK5N/J7ZXCGXsNnfOMjtRC14kB40EruEDuCFzmg0AmokTmbmoIFqshHoXrAS ZdgXbu3BmoyjmdSWrgolA5PTAaCH9V/gtKxbfWl36pTffn0PhReu9ci8ypIM9A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MwT03wqH; 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-Spam-Score: -4.74 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MwT03wqH; 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-Queue-Id: 067972C6DA X-Spam-Score: -4.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: X6Jy5adiDHNH --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable S=C3=A9bastien Miquel writes: >>> =C2=A0+ the tangle gets very noisy: not only are the result of execut= ion >>> =C2=A0=C2=A0 printed in the echo buffer, but emacs visits the tanglin= g buffer >>> =C2=A0=C2=A0 and moves the point to each block. >>> =C2=A0=C2=A0 Perhaps this is a bug that can be fixed. >> Did you try to play with :results header argument to disable messages? >> What exactly went unexpected? > > I did. I might have missed something, but no combination of :results > argument to both the latex block and the string-escape block silences > the tangle (except for :results none, which doesn't tangle the content > of the block). During tangle, the contents of the latex block are > displayed (shortly) in the echo buffer (check *Messages*), and the > point very briefly moves to the latex block. This isn't very > noticeable with a single block. Point movement is normal, but usually invisible because it happens faster than redisplay cycle. As for displaying the resolved noweb references, I do think that it should not happen. Currently, every time Org resolves noweb references, the behaviour is resembling :results silent. That is, the results of evaluation are displayed, but not inserted after the executed source blocks. I propose to change this by using :results none that will display "results silenced" echo instead of messaging the whole result string. The proposed behaviour makes more sense compared with the default value because resolved noweb references are usually used to pipe data (including table data) between source blocks and to include generated code during noweb expansion. Such data tends to be fairly bulky and creates a lot of noise during export/tangling. Not to mention that displaying large messages also gives a considerable slowdown to the whole export/tangle process. Note that changing the current behaviour also triggered the way :results none are being processed. The de facto implementation in ob-core does not do any kind of return value post-processing on :results none, which is not consistent with the manual (16.6 Results of Evaluation). In the manual, "none" option is a part of the option class consisting of "replace", "silent", "none", "append", and "prepend". All other alternative options only influence how the results are inserted after evaluation and processing. The fact that "none" result is not being processed according to :file, :post, and other arguments is not consistent. I changed that. Now, :results "none" are being processed completely, and only the actual insertion is not performed. The above change affects the return value of org-babel-execute-src-block. Previously, it always returned nil with :results none. Now, it returns the actual post-processed result of evaluation. Let me know if you see any potential issues with the proposed change. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-babel-Do-not-echo-output-of-resolved-noweb-refer.patch >From f01818ef5bce0a557eb119c58c449d75b28a923e Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Thu, 21 Jul 2022 18:54:30 +0800 Subject: [PATCH] org-babel: Do not echo output of resolved noweb references * lisp/ob-core.el (org-babel-execute-src-block): Post-process and return results even when "none" results parameter is given. Document that the result value is returned, as it is assumed by `org-babel-ref-resolve'. (org-babel-result-cond): Do return results even when "none" results parameter is given. According to the manual ":results none" should only affect how the results of evaluation are inserted into the buffer. However, the results are simply ignored currently. Fix this. * lisp/ob-ref.el (org-babel-ref-resolve): Set :results to "none" when resolving noweb references. Together with the above changes, this makes Org not echo the results value yet returning the value programatically. Reported in https://orgmode.org/list/7702b511-c289-5688-c64c-fb673324a63a@posteo.eu --- lisp/ob-core.el | 118 ++++++++++++++++++++++++------------------------ lisp/ob-ref.el | 2 +- 2 files changed, 59 insertions(+), 61 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index ac9af5d24..714f70c6a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -712,7 +712,7 @@ (defvar *this*) ; Dynamically bound in `org-babel-execute-src-block' ;;;###autoload (defun org-babel-execute-src-block (&optional arg info params) - "Execute the current source code block. + "Execute the current source code block and return the result. Insert the results of execution into the buffer. Source code execution and the collection and formatting of results can be controlled through a variety of header arguments. @@ -776,51 +776,50 @@ (defun org-babel-execute-src-block (&optional arg info params) (capitalize lang) (let ((name (nth 4 info))) (if name (format " (%s)" name) ""))) - (if (member "none" result-params) - (progn (funcall cmd body params) - (message "result silenced")) - (setq result - (let ((r (funcall cmd body params))) - (if (and (eq (cdr (assq :result-type params)) 'value) - (or (member "vector" result-params) - (member "table" result-params)) - (not (listp r))) - (list (list r)) - r))) - (let ((file (and (member "file" result-params) - (cdr (assq :file params))))) - ;; If non-empty result and :file then write to :file. - (when file - ;; If `:results' are special types like `link' or - ;; `graphics', don't write result to `:file'. Only - ;; insert a link to `:file'. - (when (and result - (not (or (member "link" result-params) - (member "graphics" result-params)))) - (with-temp-file file - (insert (org-babel-format-result - result - (cdr (assq :sep params))))) - ;; Set file permissions if header argument - ;; `:file-mode' is provided. - (when (assq :file-mode params) - (set-file-modes file (cdr (assq :file-mode params))))) - (setq result file)) - ;; Possibly perform post process provided its - ;; appropriate. Dynamically bind "*this*" to the - ;; actual results of the block. - (let ((post (cdr (assq :post params)))) - (when post - (let ((*this* (if (not file) result - (org-babel-result-to-file - file - (org-babel--file-desc params result) - 'attachment)))) - (setq result (org-babel-ref-resolve post)) - (when file - (setq result-params (remove "file" result-params)))))) - (org-babel-insert-result - result result-params info new-hash lang))) + (setq result + (let ((r (funcall cmd body params))) + (if (and (eq (cdr (assq :result-type params)) 'value) + (or (member "vector" result-params) + (member "table" result-params)) + (not (listp r))) + (list (list r)) + r))) + (let ((file (and (member "file" result-params) + (cdr (assq :file params))))) + ;; If non-empty result and :file then write to :file. + (when file + ;; If `:results' are special types like `link' or + ;; `graphics', don't write result to `:file'. Only + ;; insert a link to `:file'. + (when (and result + (not (or (member "link" result-params) + (member "graphics" result-params)))) + (with-temp-file file + (insert (org-babel-format-result + result + (cdr (assq :sep params))))) + ;; Set file permissions if header argument + ;; `:file-mode' is provided. + (when (assq :file-mode params) + (set-file-modes file (cdr (assq :file-mode params))))) + (setq result file)) + ;; Possibly perform post process provided its + ;; appropriate. Dynamically bind "*this*" to the + ;; actual results of the block. + (let ((post (cdr (assq :post params)))) + (when post + (let ((*this* (if (not file) result + (org-babel-result-to-file + file + (org-babel--file-desc params result) + 'attachment)))) + (setq result (org-babel-ref-resolve post)) + (when file + (setq result-params (remove "file" result-params)))))) + (if (member "none" result-params) + (message "result silenced") + (org-babel-insert-result + result result-params info new-hash lang))) (run-hooks 'org-babel-after-execute-hook) result))))))) @@ -3199,20 +3198,19 @@ (defmacro org-babel-result-cond (result-params scalar-form &rest table-forms) (declare (indent 1) (debug t)) (org-with-gensyms (params) `(let ((,params ,result-params)) - (unless (member "none" ,params) - (if (or (member "scalar" ,params) - (member "verbatim" ,params) - (member "html" ,params) - (member "code" ,params) - (member "pp" ,params) - (member "file" ,params) - (and (or (member "output" ,params) - (member "raw" ,params) - (member "org" ,params) - (member "drawer" ,params)) - (not (member "table" ,params)))) - ,scalar-form - ,@table-forms))))) + (if (or (member "scalar" ,params) + (member "verbatim" ,params) + (member "html" ,params) + (member "code" ,params) + (member "pp" ,params) + (member "file" ,params) + (and (or (member "output" ,params) + (member "raw" ,params) + (member "org" ,params) + (member "drawer" ,params)) + (not (member "table" ,params)))) + ,scalar-form + ,@table-forms)))) (defun org-babel-temp-file (prefix &optional suffix) "Create a temporary file in the `org-babel-temporary-directory'. diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index d5356f18c..87a7ccf63 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -153,7 +153,7 @@ (defun org-babel-ref-resolve (ref) (setq ref split-ref)) (org-with-wide-buffer (goto-char (point-min)) - (let* ((params (append args '((:results . "silent")))) + (let* ((params (append args '((:results . "none")))) (regexp (org-babel-named-data-regexp-for-name ref)) (result (catch :found -- 2.35.1 --=-=-=--