emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [FR] multiple column view definition
@ 2024-03-04 15:50 Slawomir Grochowski
  2024-03-05 12:41 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Slawomir Grochowski @ 2024-03-04 15:50 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: t_leitner

[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

Dear All,

Recently I started using multiple column view definition in org-columns. 

In e.g. I have calendar 'date tree' and I can switch between 3 views:
 
 1. dosage of medications
 2. exercise in e.g how many push ups daily
 3. some other statistics like weight or number of pomodoros daily  

#+begin_src org
   `* 2024        
   :PROPERTIES:
   :COLUMNS:  %40ITEM(item) %OMEGA-3-1000(omega 3){+} %MULTIVITAMIN(multivitamin){+}
   :COLUMNS:  %40ITEM(item) %PUSHUP(pushup){+} %CRUNCH(crunch){+} %BIRDIE(birdie){+} %LYING-LEG-RAISE(lying leg raise){+} %PLANK(plank){+}
   :COLUMNS:  %40ITEM(item) %FOOD-MORNING(s-food-t){:mean} %FOOD-NIGHT(e-food-t){:mean} %DOWN(down){:mean} %POMODORO(pomodoro){+} %WEIGHT(weight){mean;%.1f}
   :END: 
   `** week 10
   `*** [2024-03-10 Sun]
   `*** [2024-03-09 Sat]
   `*** [2024-03-08 Fri]
   `*** [2024-03-07 Thu]
   `*** [2024-03-06 Wed]
   `*** [2024-03-05 Tue]
   `*** [2024-03-04 Mon]
#+end_src

For better understanding and visualization I'm attaching a video in gif.

[-- Attachment #2: output.gif --]
[-- Type: image/gif, Size: 1136951 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1113 bytes --]

Is it OK to attach 1 MB file? 

To make it work I did a simple hack:

#+begin_src elisp
(defun org-columns-switch-columns ()
  (interactive)
  (save-excursion
    (org-columns-goto-top-level)
    (re-search-forward ":COLUMNS:")
    (org-metadown)
    (org-metadown)
    (org-columns)))
#+end_src

It works If I'm only changing the 'view', but it doesn't work properly
when I want to change column definition in e.g. remove or add a column.

Because the code for the view is 'reading' the last :COLUMNS: definition with
function (org-entry-get nil "COLUMNS" t).

But is 'changing' the first :COLUMNS: definition with function 
(org-entry-put nil "COLUMNS" fmt).

However, this is a bit of an inconsistency. This 'hack' could work
without any problems.  If the read and write behavior of property :COLUMNS: were
predictable, same.

Do you have any idea how to solve this problem?

Over 10 years ago Thomas Leitner asked about this feature
https://lists.gnu.org/archive/html/emacs-orgmode/2009-12/msg00797.html

@Thomas 
How did you deal with this feature?
Are you still using it?

Regards, 
-- 
Slawomir Grochowski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FR] multiple column view definition
  2024-03-04 15:50 [FR] multiple column view definition Slawomir Grochowski
@ 2024-03-05 12:41 ` Ihor Radchenko
  2024-03-05 16:40   ` Slawomir Grochowski
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-03-05 12:41 UTC (permalink / raw)
  To: Slawomir Grochowski; +Cc: emacs-orgmode, t_leitner

"Slawomir Grochowski" <slawomir.grochowski@gmail.com> writes:

>    :COLUMNS:  %40ITEM(item) %OMEGA-3-1000(omega 3){+} %MULTIVITAMIN(multivitamin){+}
>    :COLUMNS:  ...
>    :COLUMNS:  ...
> ...
> Because the code for the view is 'reading' the last :COLUMNS: definition with
> function (org-entry-get nil "COLUMNS" t).
>
> But is 'changing' the first :COLUMNS: definition with function 
> (org-entry-put nil "COLUMNS" fmt).
>
> However, this is a bit of an inconsistency. This 'hack' could work
> without any problems.  If the read and write behavior of property :COLUMNS: were
> predictable, same.
>
> Do you have any idea how to solve this problem?

It looks like you are asking for a way to choose between multiple column
specs when building column view. And that you have a very specific idea
how to implement it. However, the details of the idea are elusive to me.
May you elaborate?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FR] multiple column view definition
  2024-03-05 12:41 ` Ihor Radchenko
@ 2024-03-05 16:40   ` Slawomir Grochowski
  2024-03-06 10:53     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Slawomir Grochowski @ 2024-03-05 16:40 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode, t_leitner

Ihor Radchenko <yantar92@posteo.net> writes:

> It looks like you are asking for a way to choose between multiple column
> specs when building column view. And that you have a very specific idea
> how to implement it. However, the details of the idea are elusive to me.
> May you elaborate?

Sure.

We have two COLUMNS definition:

* 2024
:PROPERTIES:
:COLUMNS:  %ITEM(B) %TEST(B column)
:COLUMNS:  %ITEM(A) %TEST(A column)
:END:

#+BEGIN: columnview :hlines 1
|    A | A column |
|------+----------|
| 2024 |          |
#+END:

When and run `org-columns' on that heading it will display column view
using :COLUMNS: definition from bottom. ':COLUMNS:  %ITEM(A) %TEST(A column)'. 
The definition on top ':COLUMNS:  %ITEM(B) %TEST(B column)' is ignored. 

The function to get the :COLUMN: definition to display is (org-entry-get nil "COLUMNS" t).

Based on that behavior I made a simple function:

(defun org-columns-switch-columns ()
  (interactive)
  (save-excursion
    (org-columns-goto-top-level)
    (re-search-forward ":COLUMNS:")
    (org-metadown)
    (org-columns)))

So it's just to move :COLUMNS: definition from top to bottom. And run
`org-columns'. It works fine. 

The problem is when I want to modify the :COLUMNS: definition.
In e.g.  

* 2024
:PROPERTIES:
:COLUMNS:  %ITEM(B) %TEST(B column)
:COLUMNS:  %ITEM(A) %TEST(A column)
:END:

It will display ':COLUMNS:  %ITEM(A) %TEST(A column)'

#+BEGIN: columnview :hlines 1
|    A | A column |
|------+----------|
| 2024 |  (put cursor here and run org-columns-delete) |
#+END:

It will modify the ':COLUMNS:  %ITEM(B) %TEST(B column)'. 
So :COLUMNS: definition from top not from bottom. 

The function to modify :COLUMNS: definition is (org-entry-put nil "COLUMNS" fmt).
So this is the problem.

So in my opinion (org-entry-put nil "COLUMNS" fmt) should modify the
:COLUMNS: definition from bottom (the last one) not from top (the first one).  

Or maybe someone has a better idea how to implement the functionality
'multiple column view definition'? 

-- 
Slawomir Grochowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FR] multiple column view definition
  2024-03-05 16:40   ` Slawomir Grochowski
@ 2024-03-06 10:53     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-03-06 10:53 UTC (permalink / raw)
  To: Slawomir Grochowski; +Cc: emacs-orgmode, t_leitner

Slawomir Grochowski <slawomir.grochowski@gmail.com> writes:

>> It looks like you are asking for a way to choose between multiple column
>> specs when building column view. And that you have a very specific idea
>> how to implement it. However, the details of the idea are elusive to me.
>> May you elaborate?
>
> Sure.
>
> We have two COLUMNS definition:
>
> * 2024
> :PROPERTIES:
> :COLUMNS:  %ITEM(B) %TEST(B column)
> :COLUMNS:  %ITEM(A) %TEST(A column)
> :END:

This is ambiguous in Org mode property syntax. You cannot specify
property multiple times like this. No wonder you are getting undefined
and unexpected behaviour.

> ...
> Or maybe someone has a better idea how to implement the functionality
> 'multiple column view definition'? 

What you might do is hack `org-columns-get-format' to not default to
`org-columns-default-format', but instead ask user about the column
format to be used. For example, you can utilize
`org-property-get-allowed-values' and prompt user about the column
format to choose. Then, COLUMNS_ALL property may store multiple allowed
formats like:

* 2024
:PROPERTIES:
:COLUMNS_ALL:  "%ITEM(B) %TEST(B column)"
:COLUMNS_ALL+:  "%ITEM(A) %TEST(A column)"
:END:

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-06 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 15:50 [FR] multiple column view definition Slawomir Grochowski
2024-03-05 12:41 ` Ihor Radchenko
2024-03-05 16:40   ` Slawomir Grochowski
2024-03-06 10:53     ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).