From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id cGHOKEVaHWZsQQEAqHPOHw:P1 (envelope-from ) for ; Mon, 15 Apr 2024 18:48:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id cGHOKEVaHWZsQQEAqHPOHw (envelope-from ) for ; Mon, 15 Apr 2024 18:48:05 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713199685; 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; bh=cuvQ48OjU6OqaP0RedqJv/Elw5ysmHd9uYZ/nr18H1U=; b=jX3KXsx3IyNf8z953fvkqr6J8I50oRbqUeTzALJPLctmq6fkE+bVFkVoNN/WwyVE1tY857 38BIDF2pOYqFRfXQGAKv/RCBVSnyixvSkyok9rZjo43MS9ORfUEIEDeKEX4XJHInhu2ZmT ScjH5R1GUTs7MgTL44D26/V9WwsJmTO4zYdkaLjIg5mxlLxpA6BC5P+uASzfZnldJYteOc WzXHKeODJYfnjZgl1rrUQp++mK0XlvAsSlJVrvWCelrjTU+FOXJsVaryKJqISTzrmq4z51 MpH+aHGHksKBvdLT3ueQQWrCM4FK+YzUex3aiYyysdkpk5xv1LsU9xe1Q0Owyw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713199685; a=rsa-sha256; cv=none; b=ACn86Eq6Cx2MTBgO5T+I5R0xyHXKgurR7LjY5/Wnnf7J27aQIenk+C5wY9hQBvclFnI2e6 Kxt5/dFDd+cXa/3OxFH9loLWte8fKzqTFooBNe7ig1/wm9HQBvD/zIiYsSsVV+tnfrY9Ko iAq5Vc3YcDKV2eTDo5878TC4v8fHh0gT95Er2nje6cOVvRiMOvQU/FcJvRXaOOZSlhwUWj ss1Lg2TPStY2FMj2nDhR89uK5smhAP1V6wTJJl1rREfiOkmmbNesWF2JR27QW1E/rWQr3A PCOepFqX2M7+DtAsBEYJI0dj6G2WnEPgrxxKU8n76GIFaVSwA2FgXYv6ftyLHQ== 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 6EFED3997D for ; Mon, 15 Apr 2024 18:48:05 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwPUG-0006c3-Vf; Mon, 15 Apr 2024 12:47:21 -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 1rwPU7-0006ZP-5O for emacs-orgmode@gnu.org; Mon, 15 Apr 2024 12:47:15 -0400 Received: from smtprelay01.ispgateway.de ([80.67.31.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwPU0-0005G2-7K for emacs-orgmode@gnu.org; Mon, 15 Apr 2024 12:47:07 -0400 Received: from [185.17.206.225] (helo=condition-alpha.com) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1rwPTv-000000003g8-1KKt; Mon, 15 Apr 2024 18:46:59 +0200 Message-Id: <91dfeb0fed1a1fe0564e5eb9b95a409d@condition-alpha.com> From: Alexander Adolf To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM In-Reply-To: <87cyqtyzgt.fsf@localhost> References: <486d2b818b62c71b3f307305c06c4318@condition-alpha.com> <871q7cypxl.fsf@localhost> <00aa9bf72dc93f6554bdd236fdfba192@condition-alpha.com> <87y19hbb05.fsf@localhost> <8b72386d118136210f27b553f0a13066@condition-alpha.com> <87cyqtyzgt.fsf@localhost> Date: Mon, 15 Apr 2024 18:46:58 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Df-Sender: YWxleGFuZGVyLmFkb2xmQGNvbmRpdGlvbi1hbHBoYS5jb20= Received-SPF: pass client-ip=80.67.31.28; envelope-from=alexander.adolf@condition-alpha.com; helo=smtprelay01.ispgateway.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: -6.37 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -6.37 X-Migadu-Queue-Id: 6EFED3997D X-TUID: 1H7WII7QNqTn --=-=-= Content-Type: text/plain Many thanks for the pointers, Ihor! The instructions were clear and concise, so the patch creation went smoothly. Results attached below. I cloned the Org repository from git://git.sv.gnu.org/emacs/org-mode.git and followed the instructions at https://orgmode.org/worg/org-contribute.html#first-patch. I hope I succeeded for most part. ;-) `make compile` didn't complain at all, and `make test` ended with the following: ---------------------------- Begin Quote ----------------------------- Ran 1254 tests, 1238 results as expected, 4 unexpected, 12 skipped (2024-04-15 18:39:50+0200, 57.383197 sec) 2 expected failures 4 unexpected results: FAILED ob-calc/matrix-inversion ((should (equal "[[-1, 0.625, -0.125], [0.25, -0.5, 0.25], [0.5, 0.125, -0.125]]" (org-babel-execute-src-block))) :form (equal "[[-1, 0.625, -0.125], [0.25, -0.5, 0.25], [0.5, 0.125, -0.125]]" "[[-1, 625e-3, -125e-3], [250e-3, -500e-3, 250e-3], [500e-3, 125e-3, -125e-3]]") :value nil :explanation (arrays-of-different-length 63 77 "[[-1, 0.625, -0.125], [0.25, -0.5, 0.25], [0.5, 0.125, -0.125]]" "[[-1, 625e-3, -125e-3], [250e-3, -500e-3, 250e-3], [500e-3, 125e-3, -125e-3]]" first-mismatch-at 6)) FAILED test-ob-shell/bash-uses-assoc-arrays ((should (equal "two" (org-trim (org-babel-execute-src-block)))) :form (equal "two" "three") :value nil :explanation (arrays-of-different-length 3 5 "two" "three" first-mismatch-at 1)) FAILED test-ob-shell/bash-uses-assoc-arrays-with-lists ((should (equal "20 cm" (org-trim (org-babel-execute-src-block)))) :form (equal "20 cm" "50 dl") :value nil :explanation (array-elt 0 (different-atoms (50 "#x32" "?2") (53 "#x35" "?5")))) FAILED test-org-table/sort-lines ((should (equal "| a | x |\n| B | 4 |\n| c | 3 |\n" (org-test-with-temp-text "| a | x |\n| c | 3 |\n| B | 4 |\n" (org-table-sort-lines nil 97) (buffer-string)))) :form (equal "| a | x |\n| B | 4 |\n| c | 3 |\n" #("| B | 4 |\n| a | x |\n| c | 3 |\n" 0 9 (face org-table) 9 10 (face org-table-row) 10 19 (face org-table) 19 20 (face org-table-row) 20 29 (face org-table) 29 30 (face org-table-row))) :value nil :explanation (array-elt 2 (different-atoms (97 "#x61" "?a") (66 "#x42" "?B")))) 12 skipped results: SKIPPED org-missing-dependency/test-ob-R ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-clojure ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-haskell-ghci ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-julia ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-lua ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-maxima ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-octave ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-python ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-ruby ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-ob-scheme ((skip-unless nil) :form nil :value nil) SKIPPED org-missing-dependency/test-org-attach-git ((skip-unless nil) :form nil :value nil) SKIPPED test-org-fold/org-fold-display-inline-images ((skip-unless (not noninteractive)) :form (not t) :value nil) make: *** [test] Error 1 ----------------------------- End Quote ------------------------------ At first glance, nothing seems to point into a direction suggesting that I had broken anything (i.e. nothing about any breakage relating to columnview)? Many thanks and looking forward to your thoughts, --alexander --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-org-colview.el-add-formatter-parameter-to-colvi.patch >From c21b18475dd154eed8d3f2489daa5a468531dc82 Mon Sep 17 00:00:00 2001 From: Alexander Adolf Date: Sun, 14 Apr 2024 18:14:05 +0200 Subject: [PATCH 1/2] lisp/org-colview.el: add formatter parameter to colview dynamic block * lisp/org-colview.el (org-dblock-write:column view): Factor out the existing formatting code to new function org-columns-dblock-write-default, and honour new dblock parameter :formatter for specifying a different formatting function. (org-columns-dblock-write-default): New function with current formatting code. (org-columns--capture-view): Amend docstring to better explain the format of the data being passed to the formatting function. (org-clock-clocktable-formatter): New option to define a global default formatting function, defaulting to the current behaviour. * doc/org-manual.org (Capturing column view): Describe new :formatter parameter. * etc/ORG-NEWS (New option ~org-columns-dblock-formatter~): Announce new option. (=colview= dynamic block supports custom formatting function): Describe new custom formatting function feature. --- doc/org-manual.org | 6 ++++++ etc/ORG-NEWS | 26 ++++++++++++++++++++++++++ lisp/org-colview.el | 38 ++++++++++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 6c699ae1e..e66e48cda 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -6012,6 +6012,12 @@ This dynamic block has the following parameters: Specify a column attribute (see [[*Column attributes]]) for the dynamic block. +- =:formatter= :: + + A function for formatting the data in the dynamic block, overriding + the default formatting function set in + ~org-columns-dblock-formatter~. + The following commands insert or update the dynamic block: - ~org-columns-insert-dblock~ :: diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e61bd6988..eab181bc3 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -999,6 +999,16 @@ even though it does not have its own ID. By giving files top-level id properties, links to headlines in the file can also be made more robust by using the file id instead of the file path. +*** New option ~org-columns-dblock-formatter~ + +=colview= dynamic blocks now understand a new ~:formatter~ parameter +to use a specific function for formatting the contents of the dynamic +block. This new option can be used to set the global default +formatting function that will be used for =colview= dynamic blocks +that do not specify any ~:formatter~ parameter. Its default value (the +new function ~org-columns-dblock-write-default~) yields the previous +(fixed) formatting behaviour. + ** New features *** =colview= dynamic block now writes column width specifications @@ -1030,6 +1040,22 @@ Example: : | PROYECTO EMACS | : #+END: +*** =colview= dynamic block supports custom formatting function + +The =colview= dynamic block understands a new ~:formatter~ parameter, +which specifies a user-supplied function to format the data in the +dynamic block. + +A global default formatting function for =colview= dynamic blocks can +be set via the new option ~org-columns-dblock-formatter~ which +defaults to the new function ~org-columns-dblock-write-default~, that +implements the previous (fixed) formatting behaviour. Hence, the +default behaviour is identical to previous versions. + +The global default function can be overridden for any given =colview= +dynamic block individually by specifying a custom formatter function +using the new ~:formatter~ parameter on the block's =BEGIN= line. + *** =ob-tangle.el=: New flag to remove tangle targets before writing When ~org-babel-tangle-remove-file-before-write~ is set to ~t~ the diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 4718d1db7..5c908affe 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -123,6 +123,13 @@ in `org-columns-summary-types-default', which see." (function :tag "Summarize") (function :tag "Collect"))))) +(defcustom org-columns-dblock-formatter #'org-columns-dblock-write-default + "Function to format data in column view dynamic blocks. +For more information, see `org-columns-dblock-write-default'." + :group 'org-properties + :version "30.0" + :package-version '(Org . "9.7") + :type 'function) ;;; Column View @@ -1442,9 +1449,13 @@ that will be excluded from the resulting view. FORMAT is a format string for columns, or nil. When LOCAL is non-nil, only capture headings in current subtree. -This function returns a list containing the title row and all -other rows. Each row is a list of fields, as strings, or -`hline'." +This function returns a list containing the title row and all other +rows. Each row is either a list, or the symbol `hline'. The first list +is the heading row as a list of strings with the column titles according +to FORMAT. All subsequent lists each represent a body row as a list +whose first element is an integer indicating the outline level of the +entry, and whose remaining elements are strings with the contents for +the columns according to FORMAT." (org-columns (not local) format) (goto-char org-columns-top-level-marker) (let ((columns (length org-columns-current-fmt-compiled)) @@ -1545,8 +1556,13 @@ PARAMS is a property list of parameters: `:vlines' When non-nil, make each column a column group to enforce - vertical lines." - (let ((table + vertical lines. + +`:formatter' + + A function to format the data and insert it into the buffer." + (let ((insert-pos (point)) + (table (let ((id (plist-get params :id)) view-file view-pos) (pcase id @@ -1573,7 +1589,17 @@ PARAMS is a property list of parameters: (plist-get params :exclude-tags) (plist-get params :format) view-pos))))) - (width-specs + (formatter (or (plist-get params :formatter) + org-columns-dblock-formatter + #'org-columns-dblock-write-default))) + (funcall formatter insert-pos table params))) + +(defun org-columns-dblock-write-default (ipos table params) + "Write out a columnview table at position IPOS in the current buffer. +TABLE is a table with data as produced by `org-columns--capture-view'. +PARAMS is the parameter property list obtained from the dynamic block +definition." + (let ((width-specs (mapcar (lambda (spec) (nth 2 spec)) org-columns-current-fmt-compiled))) (when table -- 2.39.3 (Apple Git-146) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-lisp-org-colview.el-add-link-parameter-to-colview-dy.patch >From 4d69c3407c7c00fe0a1f52c383ced572f3524076 Mon Sep 17 00:00:00 2001 From: Alexander Adolf Date: Mon, 15 Apr 2024 18:01:40 +0200 Subject: [PATCH 2/2] lisp/org-colview.el: add link parameter to colview dynamic block * lisp/org-colview.el (org-columns--capture-view): Add new link parameter, which when non-nil causes ITEM headlines to be linked to their origins. (org-dblock-write:columnview): Pass new link parameter to org-columns--capture-view, and explain its use in the docstring. * doc/org-manual.org (Capturing column view): Describe new :link parameter. * etc/ORG-NEWS (=colview= dynamic block can link to headlines): Describe new link feature. --- doc/org-manual.org | 5 +++++ etc/ORG-NEWS | 6 ++++++ lisp/org-colview.el | 34 ++++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index e66e48cda..5e2549f49 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -6007,6 +6007,11 @@ This dynamic block has the following parameters: When non-~nil~, indent each =ITEM= field according to its level. +- =:link= :: + + When non-~nil~, link the =ITEM= headlines in the table to their + origins. + - =:format= :: Specify a column attribute (see [[*Column attributes]]) for the dynamic diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index eab181bc3..449487ac0 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -1056,6 +1056,12 @@ The global default function can be overridden for any given =colview= dynamic block individually by specifying a custom formatter function using the new ~:formatter~ parameter on the block's =BEGIN= line. +*** =colview= dynamic block can link to headlines + +The =colview= dynamic block understands a new ~:link~ parameter, which +when non-~nil~ causes =ITEM= headlines in the table to be linked to +their origins. + *** =ob-tangle.el=: New flag to remove tangle targets before writing When ~org-babel-tangle-remove-file-before-write~ is set to ~t~ the diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 5c908affe..1771283f2 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1439,15 +1439,15 @@ and variances (respectively) of the individual estimates." ;;; Dynamic block for Column view -(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags format local) +(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags link format local) "Get the column view of the current buffer. -MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip -empty rows, an empty row being one where all the column view -specifiers but ITEM are empty. EXCLUDE-TAGS is a list of tags -that will be excluded from the resulting view. FORMAT is a -format string for columns, or nil. When LOCAL is non-nil, only -capture headings in current subtree. +MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip empty +rows, an empty row being one where all the column view specifiers but +ITEM are empty. EXCLUDE-TAGS is a list of tags that will be excluded +from the resulting view. When LINK is non-nil, item headlines will be +linked to their origins. FORMAT is a format string for columns, or nil. +When LOCAL is non-nil, only capture headings in current subtree. This function returns a list containing the title row and all other rows. Each row is either a list, or the symbol `hline'. The first list @@ -1467,12 +1467,21 @@ the columns according to FORMAT." (let (row) (dotimes (i columns) (let* ((col (+ (line-beginning-position) i)) - (p (get-char-property col 'org-columns-key))) - (push (org-quote-vert + (p (get-char-property col 'org-columns-key)) + (cell-content + (org-quote-vert (get-char-property col (if (string= p "ITEM") 'org-columns-value - 'org-columns-value-modified))) + 'org-columns-value-modified))))) + (push (if (and link (string= p "ITEM")) + (let ((search (org-link-heading-search-string + cell-content))) + (org-link-make-string + (if (not (buffer-file-name)) search + (format "file:%s::%s" (buffer-file-name) search)) + cell-content)) + cell-content) row))) (unless (or (and skip-empty @@ -1558,6 +1567,10 @@ PARAMS is a property list of parameters: When non-nil, make each column a column group to enforce vertical lines. +`:link' + + Link the item headlines in the table to their origins. + `:formatter' A function to format the data and insert it into the buffer." @@ -1587,6 +1600,7 @@ PARAMS is a property list of parameters: (plist-get params :match) (plist-get params :skip-empty-rows) (plist-get params :exclude-tags) + (plist-get params :link) (plist-get params :format) view-pos))))) (formatter (or (plist-get params :formatter) -- 2.39.3 (Apple Git-146) --=-=-=--