all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Alexander Adolf <alexander.adolf@condition-alpha.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM
Date: Fri, 19 Apr 2024 10:49:41 +0000	[thread overview]
Message-ID: <87a5lpeiey.fsf@localhost> (raw)
In-Reply-To: <91dfeb0fed1a1fe0564e5eb9b95a409d@condition-alpha.com>

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:


> Subject: [PATCH 1/2] lisp/org-colview.el: add formatter parameter to colview
>  dynamic block

Thanks for the patches!
See my comments below.

> * 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.

In the changelog entries, we quote the symbol and variable names like
`this'.

> +- =:formatter= ::
> +
> +  A function for formatting the data in the dynamic block, overriding
> +  the default formatting function set in
> +  ~org-columns-dblock-formatter~.

You can also mention that the function also inserts the data. Something
similar to what we do when describe the equivalent option for clock tables:

    - =:formatter= ::
    
      A function to format clock data and insert it into the buffer.

Also, if you mention a variable in the manual, please add #+vindex:
entry. Maybe even #+cindex: entry for "formatter", to make the parameter
more discoverable.

> +*** 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

... and inserting its contents.

It would also be helpful to refer to the existing :formatter parameter
in clock tables.

> +*** =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

... and insert the data

> +(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"

We do not need :version tag when there is :package-version.

> +(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

This new function ignores IPOS parameter. It should not.
 
> From 4d69c3407c7c00fe0a1f52c383ced572f3524076 Mon Sep 17 00:00:00 2001
> From: Alexander Adolf <alexander.adolf@condition-alpha.com>
> Date: Mon, 15 Apr 2024 18:01:40 +0200
> Subject: [PATCH 2/2] lisp/org-colview.el: add link parameter to colview
>  dynamic block

*Add
(capitalize)

> * 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.

`org-columns--capture-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)

While this is an internal function and we are free to change it as we
need, it is generally more robust to not make changes in the order of
function arguments. I recommend

(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags format local &optional link)

> +	       (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))

In org-clock, we do

(org-link-make-string
			     (if (not (buffer-file-name)) search
			       (format "file:%s::%s" (buffer-file-name) search))
			     ;; Prune statistics cookies.  Replace
			     ;; links with their description, or
			     ;; a plain link if there is none.
			     (org-trim
			      (org-link-display-format
			       (replace-regexp-in-string
				"\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" ""
				headline))))

Is there any reason why you did not remove the statistics cookies here
as well?

> `make compile` didn't complain at all, and `make test` ended with the
> following:
> ...
> 4 unexpected results:
>    FAILED  ob-calc/matrix-inversion
>    FAILED  test-ob-shell/bash-uses-assoc-arrays
>    FAILED  test-ob-shell/bash-uses-assoc-arrays-with-lists
>    FAILED  test-org-table/sort-lines

MacOS? There are known issues with locale rules in MacOS that may cause
test failures.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2024-04-19 10:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 21:08 columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM Alexander Adolf
2024-04-11 13:44 ` Ihor Radchenko
2024-04-12 12:13   ` Alexander Adolf
2024-04-13 14:19     ` Ihor Radchenko
2024-04-13 16:37       ` Alexander Adolf
2024-04-13 16:55         ` Ihor Radchenko
2024-04-15 16:46           ` Alexander Adolf
2024-04-19 10:49             ` Ihor Radchenko [this message]
2024-04-19 15:35               ` Alexander Adolf
2024-04-19 17:09                 ` Ihor Radchenko
2024-04-20 14:30                   ` Alexander Adolf
2024-04-21 13:42                     ` Ihor Radchenko
2024-04-22 20:41                       ` Alexander Adolf
2024-04-23 11:28                         ` Ihor Radchenko
2024-04-23 16:27                           ` Alexander Adolf
2024-04-23 16:35                             ` Ihor Radchenko
2024-04-24 17:29                               ` Alexander Adolf
2024-04-26 12:21                                 ` Ihor Radchenko
2024-04-26 12:38                                   ` Bastien Guerry
2024-04-26 12:47                                     ` Ihor Radchenko
2024-04-26 16:07                                       ` Alexander Adolf
2024-04-28 13:13                                         ` Ihor Radchenko
2024-04-19 17:26               ` Alexander Adolf
2024-04-24 10:51             ` FAILED test-ob-shell/bash-uses-assoc-arrays Max Nikulin
2024-04-24 12:54               ` Ihor Radchenko
2024-04-24 16:04                 ` Max Nikulin
2024-04-26 11:08                   ` Ihor Radchenko
2024-04-26 16:41                     ` Max Nikulin
2024-04-28 13:11                       ` Ihor Radchenko
2024-05-02 10:20                         ` [PATCH] test-ob-shell.el: Skip based on feature detection Max Nikulin
2024-05-02 12:57                           ` Ihor Radchenko
2024-05-02 12:09             ` columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM Ihor Radchenko
2024-05-02 12:36               ` Alexander Adolf
2024-05-02 12:59                 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5lpeiey.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=alexander.adolf@condition-alpha.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.