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 yMy1I6eNJmOjPwAAbAwnHQ (envelope-from ) for ; Sun, 18 Sep 2022 05:16:55 +0200 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 mKq8I6eNJmO8VAEA9RJhRA (envelope-from ) for ; Sun, 18 Sep 2022 05:16:55 +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 34F9B2DCE5 for ; Sun, 18 Sep 2022 05:16:55 +0200 (CEST) Received: from localhost ([::1]:43494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZkne-0005cQ-Cn for larch@yhetil.org; Sat, 17 Sep 2022 23:16:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZknE-0005c2-Ol for emacs-orgmode@gnu.org; Sat, 17 Sep 2022 23:16:28 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:44999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZknC-0002iT-Tx for emacs-orgmode@gnu.org; Sat, 17 Sep 2022 23:16:28 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id CBB6332009B6 for ; Sat, 17 Sep 2022 23:16:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 17 Sep 2022 23:16:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecosaur.net; h= cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm1; t= 1663470984; x=1663557384; bh=LK1/0pZqA2nK3SbknHgPeU+/KdYpFTpGu+S xmPOL8jM=; b=JprPjCRf2ZzzTgU4wdrks/HZ/PrNtRyOqZOGVYI9fTv/9C3VXSY MWyRQuh5b0NKZPOIdXbREdxH0MPuuZ6TlLiEsgBg5dCWpQ4IubiBColPwxRGkUFe WVHEhfWktzRqWkXipTWq/Q3IYCENu3GP12XvknQEd5RdTu5dWDVjTn4KjiIqZ1QF PakTiWh1ig3N05Lsjuwc+q+qZg2lux1izq1cThPBkrMDqr6nRa2i10Lm3r6avKcM 8z0wnye5YoqJd5A9QRCMdBk9dPTyaqmtcxhKuBeSGU4ubeZTKSuQV0ia8YYaHA7X k2bVsnHB57K82oVSly4j9z5K9+qAvvC0Pew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1663470984; x= 1663557384; bh=LK1/0pZqA2nK3SbknHgPeU+/KdYpFTpGu+SxmPOL8jM=; b=T 1nJWprpKHbdLoQTfZD1rQM2UfDRmuZRCLlYB3+9xZyjFYyIfNB8mAXrJe5K8a8nX xySAbMPAuwPglyLD86jcpJGcBQKqIPgKVWs+dtkNFy0NzAnR08dHt2ut8paRrWOp 8ipxkxZEpmRSnWOdwwE2ecP/eA1KRcOm3ozHrJ7AZx/1XhxACRl4zbzE2mHZzsMG E1Fmt0b3S1wooprdDUOLksil0yjQA5j83kfHJcgB/x5rabrUfM/hDAnZ9pNZEVun k545jf9CLk5OFPA1Z+C+gilyRkny2enABdtO3nlVu+nhM6+piaTx2thMU9+sVdgO u+RB3tMry4NCh+QzulXWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvfedgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuffgfkfggtgesmhdtreertd erjeenucfhrhhomhepvfhimhhothhhhicuoehorhhgmhhouggvsehtvggtrdhtvggtohhs rghurhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdfhffelhfdvleevffffieeukeeuge egueffteevtedtveevvdevvdejjefhtefhnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepohhrghhmohguvgesthgvtgdrthgvtghoshgruhhrrd hnvght X-ME-Proxy: Feedback-ID: iecf94634:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 17 Sep 2022 23:16:23 -0400 (EDT) From: Timothy To: emacs-orgmode@gnu.org Subject: [PATCH] Babel evaluation: location and timing information Date: Sun, 18 Sep 2022 11:09:39 +0800 User-agent: mu4e 1.8.8; emacs 28.1.50 Message-ID: <87edw9z81n.fsf@tec.tecosaur.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=64.147.123.21; envelope-from=orgmode@tec.tecosaur.net; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_NONE=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" 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=1663471015; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=LK1/0pZqA2nK3SbknHgPeU+/KdYpFTpGu+SxmPOL8jM=; b=FozeWpaZyCcXcRgLCOZQsvASyTuamxUuoJEgo/5nMXnjnOcM8sBGa+ocXoVICUgpi7E0l2 WO8fUvxBrxhs4Cipr42YK/iNHxkOLh3L1+xDun09r+Z86bAzsHgk9tC/hSBzEgmrUbEoUw LOyp1wWHQC8DhL3qijm/f23Zmbdo70UlJDtUWvRD436Q/uyL7TLO7dL6NJxuHG80vBEtpk K4Z8yo+qQYsPghVt0RUkNQ3urh+zaV/wPn6913swF5uCur00sG1XG7BYwdcoEi9Fd82Tca J7+MqliaskpZ/C+ahb0Ia//OuULrNVUhYcBKA124wWZ7z0kZMT4mwVNFGEpDHA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663471015; a=rsa-sha256; cv=none; b=KG5Z5Yq28cUpN3kB4NBQ3iP+RXZ0k8CpjRDJGVl/JOGtOEd7M/8v0pAyZtaFh5jCM4Sia5 GelxyVn1MWtJTzAc4qj6kUbvYvO7tp4r2yTnrHz+GJ5WYLjS03F1wR0mhwF+ur1hmOgz2U 4Qo3isPUxUiQvEDWBL/Yqx/ueY0C2v816gQsTjiWIOV1VaD9cvw7uN2AHL01C8OoLwCl93 2ec4pglHP3p16fw02/oP+z8NM8rLP1oR/HNn5yW1S0+oHrKiMXFSpMWc/9VQyzAot5fIjU hpiWUfR9ZDcFkt0I9hZmmCiX6O/NYB53BlJ3cVhmT0vLHMuwARxc/s46JxnmZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tecosaur.net header.s=fm1 header.b=JprPjCRf; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="T 1nJWpr"; dmarc=none; 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: 1.76 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tecosaur.net header.s=fm1 header.b=JprPjCRf; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b="T 1nJWpr"; dmarc=none; 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: 34F9B2DCE5 X-Spam-Score: 1.76 X-Migadu-Scanner: scn0.migadu.com X-TUID: wyCB4kTDhfNP --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi All, This is a small set of patches to add a bit more information to the messages emitted in the course of babel evaluation. Specifically about =E2=81=83 What type of element is responsible for the evaluation (source bl= ock, babel call, inline source) =E2=81=83 Where the element is (if no name is set) =E2=81=83 How long evaluation took For example, previously `C-c C-c' on a babel call would have produced a mes= sage like this: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 executing Emacs-Lisp code block... =E2=94=82 Code block evaluation complete. =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 and now this might look like so: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 executing Emacs-Lisp call on line 143... =E2=94=82 Code block evaluation complete (took 0.2s). =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 I think this is a pretty sensible change, but feedback is always nice. If there are no objections, I expect I=E2=80=99ll merge this in a few days. All the best, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-core-Display-line-number-of-exec-babel-blocks.patch >From 5be372f8185aa8b482f63f182ee1cf252a777c3b Mon Sep 17 00:00:00 2001 From: TEC Date: Tue, 13 Sep 2022 18:55:06 +0800 Subject: [PATCH 1/3] ob-core: Display line number of exec babel blocks * lisp/ob-core.el (org-babel-execute-src-block): When an unnamed babel block is executed, show the line number of the block. This makes it easier to track the execution without having to name every block. --- lisp/ob-core.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 8a963fa8e..0a179f379 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -779,7 +779,11 @@ (defun org-babel-execute-src-block (&optional arg info params) (message "executing %s code block%s..." (capitalize lang) (let ((name (nth 4 info))) - (if name (format " (%s)" name) ""))) + (if name + (format "(%s)" name) + (format "on line %d" + (line-number-at-pos + (or (nth 5 info) org-babel-current-src-block-location)))))) (setq result (let ((r (funcall cmd body params))) (if (and (eq (cdr (assq :result-type params)) 'value) -- 2.37.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-ob-core-Display-type-of-element-babel-executes.patch >From 8e55a3e90f4c7bcec796d450e05e953ce3871e81 Mon Sep 17 00:00:00 2001 From: TEC Date: Sat, 17 Sep 2022 17:39:16 +0800 Subject: [PATCH 2/3] ob-core: Display type of element babel executes * lisp/ob-core.el (org-babel-execute-src-block): The babel execute function is run on more than just source blocks, so it makes sense to note the type of element being executed. --- lisp/ob-core.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 0a179f379..f95bd56e6 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -776,8 +776,12 @@ (defun org-babel-execute-src-block (&optional arg info params) result) (unless (fboundp cmd) (error "No org-babel-execute function for %s!" lang)) - (message "executing %s code block%s..." + (message "executing %s %s %s..." (capitalize lang) + (pcase (org-element-type (org-element-at-point)) + ('src-block "code block") + ('babel-call "call") + ('paragraph "inline code block")) (let ((name (nth 4 info))) (if name (format "(%s)" name) -- 2.37.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-ob-core-Display-babel-execution-time.patch >From f661b72d7c4837f5fed4201e0c764d0e0c6b0993 Mon Sep 17 00:00:00 2001 From: TEC Date: Sat, 17 Sep 2022 17:53:01 +0800 Subject: [PATCH 3/3] ob-core: Display babel execution time * lisp/ob-core.el (org-babel-execute-src-block, org-babel-format-result): Record the babel execution time, and then supplement the "Code block evaluation complete." (etc.) messages with the execution time when >0.05s. --- lisp/ob-core.el | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index f95bd56e6..946b37595 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -773,7 +773,7 @@ (defun org-babel-execute-src-block (&optional arg info params) (make-directory d 'parents) d)))) (cmd (intern (concat "org-babel-execute:" lang))) - result) + result exec-start-time) (unless (fboundp cmd) (error "No org-babel-execute function for %s!" lang)) (message "executing %s %s %s..." @@ -788,7 +788,8 @@ (defun org-babel-execute-src-block (&optional arg info params) (format "on line %d" (line-number-at-pos (or (nth 5 info) org-babel-current-src-block-location)))))) - (setq result + (setq exec-start-time (current-time) + result (let ((r (funcall cmd body params))) (if (and (eq (cdr (assq :result-type params)) 'value) (or (member "vector" result-params) @@ -831,7 +832,8 @@ (defun org-babel-execute-src-block (&optional arg info params) (if (member "none" result-params) (message "result silenced") (org-babel-insert-result - result result-params info new-hash lang))) + result result-params info new-hash lang + (time-subtract (current-time) exec-start-time)))) (run-hooks 'org-babel-after-execute-hook) result))))))) @@ -2242,7 +2244,7 @@ (defun org-babel-format-result (result &optional sep) ;; scalar result (funcall echo-res result)))) -(defun org-babel-insert-result (result &optional result-params info hash lang) +(defun org-babel-insert-result (result &optional result-params info hash lang exec-time) "Insert RESULT into the current buffer. By default RESULT is inserted after the end of the current source @@ -2250,7 +2252,8 @@ (defun org-babel-insert-result (result &optional result-params info hash lang) wrapped inside a `results' macro and placed on the same line as the inline source block. The macro is stripped upon export. Multiline and non-scalar RESULTS from inline source blocks are -not allowed. With optional argument RESULT-PARAMS controls +not allowed. When EXEC-TIME is provided it may be included in a +generated message. With optional argument RESULT-PARAMS controls insertion of results in the Org mode file. RESULT-PARAMS can take the following values: @@ -2555,11 +2558,15 @@ (defun org-babel-insert-result (result &optional result-params info hash lang) (not (and (listp result) (member "append" result-params)))) (indent-rigidly beg end indent)) - (if (null result) - (if (member "value" result-params) - (message "Code block returned no value.") - (message "Code block produced no output.")) - (message "Code block evaluation complete."))) + (let ((time-info + (if (and exec-time (> (float-time exec-time) 0.05)) + (format " (took %.1fs)" (float-time exec-time)) + ""))) + (if (null result) + (if (member "value" result-params) + (message "Code block returned no value%s." time-info) + (message "Code block produced no output%s." time-info)) + (message "Code block evaluation complete%s." time-info)))) (set-marker end nil) (when outside-scope (narrow-to-region visible-beg visible-end)) (set-marker visible-beg nil) -- 2.37.1 --=-=-=--