Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-08-20 Thread Ihor Radchenko
Sławomir Grochowski  writes:

> I thought it would get lost in the many thousands of other TODOs you have
> on your plate.
> Thank you.

Merging contributed patches is high priority. I either have them
scheduled in agenda or they are the next thing to do upon clearing the
scheduled tasks.

The last thing I want is being a sole committer to Org.

> But to my another surprise you have fixed the bug that was killing me
> everyday 'org-insert-heading: Fix when folded text is kept right at the new
> heading'.
> Thank you very much.

A reproducer was provided :) So I was able to debug what was going on.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-08-20 Thread Sławomir Grochowski
I thought it would get lost in the many thousands of other TODOs you have
on your plate.
Thank you.

But to my another surprise you have fixed the bug that was killing me
everyday 'org-insert-heading: Fix when folded text is kept right at the new
heading'.
Thank you very much.

Regards,
Sławomir Grochowski


On Sun, Aug 20, 2023 at 12:43 PM Ihor Radchenko  wrote:

> Ihor Radchenko  writes:
>
> > I suspect that it is something with overlay boundaries. AFAIR, some org
> > subtree motion functions use `insert-before-markers', which may be
> > tricky when we insert right at the beginning/end of an overlay.
>
> It was totally unrelated bug on Org side.
> Applied, onto main, with minor amendments to function docstring and
> changelog format.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=650e42996
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e08d87831
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-08-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> I suspect that it is something with overlay boundaries. AFAIR, some org
> subtree motion functions use `insert-before-markers', which may be
> tricky when we insert right at the beginning/end of an overlay.

It was totally unrelated bug on Org side.
Applied, onto main, with minor amendments to function docstring and
changelog format.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=650e42996
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e08d87831

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-12 Thread Ihor Radchenko
Sławomir Grochowski  writes:

> As I understand it something with overlay. Which try to jump before the
> first line of the buffer.

Most likely.

> And that makes some kind of overflow?
> I will try to simplify the example and create a simple overlay without
> org-columns.
> If anyone has some ideas how to debug it I will be grateful for the hints.

I suspect that it is something with overlay boundaries. AFAIR, some org
subtree motion functions use `insert-before-markers', which may be
tricky when we insert right at the beginning/end of an overlay.

I suggest using M-x debug-on-entry and stepping through the code.
You may also add a random colour to colview overlays to track how they
behave visually. You can also examine `org-columns-overlays' variable
that holds all the active colview overlays.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-11 Thread Sławomir Grochowski
Thank you Ihor for finding such an important bug.

I've tried to pinpoint it.
I think it happens only when: first heading (row) is the first line of the
buffer.
To reproduce it:
* a
* b
* c

C-u C-c C-x C-c => runs `org-columns' with global argument.
Using a keyboard. Press M-, M-, M-.
Heading 'a' will disappear.

I've tried to create a test based on that behaviour, but can't reproduce
this bug in test env.
Also I can't reproduce this when I'm invoking the commands directly from
M-x.
As I understand it something with overlay. Which try to jump before the
first line of the buffer.
And that makes some kind of overflow?
I will try to simplify the example and create a simple overlay without
org-columns.
If anyone has some ideas how to debug it I will be grateful for the hints.


On Sun, Apr 9, 2023 at 11:13 AM Ihor Radchenko  wrote:

> Sławomir Grochowski  writes:
>
> > Thank you Ihor for the code review.
> > Now please help me find everything that can be improved in this patch.
>
> I just tried to use the patch using the following test case:
>
> 1. Create a new Org file containing
>
> * A
> * B
> * C
> ** C1
> * D
>
> 2. C-u C-c C-x C-c
> 3. M-<
> 4. M- M- M- M- M- M- M- M- C-c C-c
> 5. Observe text disappearing and columns being unhighlighted. At the
>end, the buffer is left with
>
> * B
>
> >> Finally, I see no records about you copyright assignment status.
> >> Please take a look at
> >> https://orgmode.org/worg/org-contribute.html#copyright
> >>
> >
> >  Yes, it's my first time. I sent an email to ass...@gnu.org, yesterday.
>
> Note that they should reply within 5 working days.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-09 Thread Ihor Radchenko
Sławomir Grochowski  writes:

> Thank you Ihor for the code review.
> Now please help me find everything that can be improved in this patch.

I just tried to use the patch using the following test case:

1. Create a new Org file containing

* A 
* B 
* C 
** C1
* D 

2. C-u C-c C-x C-c
3. M-<
4. M- M- M- M- M- M- M- M- C-c C-c
5. Observe text disappearing and columns being unhighlighted. At the
   end, the buffer is left with

* B

>> Finally, I see no records about you copyright assignment status.
>> Please take a look at
>> https://orgmode.org/worg/org-contribute.html#copyright
>>
>
>  Yes, it's my first time. I sent an email to ass...@gnu.org, yesterday.

Note that they should reply within 5 working days.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-08 Thread Sławomir Grochowski
Thank you Ihor for the code review.
Now please help me find everything that can be improved in this patch.


> The patch looks good in general, but you need to add proper commit
> message. See https://orgmode.org/worg/
> 
> org-contribute.html#commit-messages
> 


Fixed.

Also, you need to add etc/ORG-NEWS entry about the new functionality and
> also modify the manual.
>

I added description to the manual and missing description of two
other commands: org-columns-move-left, org-columns-move-right that were
missing.


> Finally, I see no records about you copyright assignment status.
> Please take a look at
> https://orgmode.org/worg/org-contribute.html#copyright
>

 Yes, it's my first time. I sent an email to ass...@gnu.org, yesterday.

Does this test have anything to do with the new feature?
>

 Yes, you are right. This test has nothing in common with the feature. I
have removed it.

On Fri, Apr 7, 2023 at 1:01 PM Ihor Radchenko  wrote:

> Sławomir Grochowski  writes:
>
> > Recently I often use 'column view' feature.
> > To my suprise in 'column view' user can't move rows up & down.
> > So I wrote a little code snippet to be able to do it, and I'm sharing it
> with you.
> >
> > Questions:
> > 1. Why user can't move rows up & down in 'column view'?
> > 2. Is this was intentional design decision?
>
> I do not see any particular reason.
> The current design dates back to 15 years ago - the initial commit in
> our current git repo.
>
> > I think 'column view' is missing one the core feel & functionality of
> org-mode - moving rows (headings) up & down.
> > In my experiance with 'column view' & tables I shuffle a lot of columns
> & rows order.
>
> Sounds reasonable.
>
> > From 1f0f2052b8dddf4982ab35267ed1564f2250784b Mon Sep 17 00:00:00 2001
> > From: Sławomir Grochowski 
> > Date: Mon, 3 Apr 2023 19:23:09 +0200
> > Subject: [PATCH] org-columns: add feat to move row up/down
>
> The patch looks good in general, but you need to add proper commit
> message. See https://orgmode.org/worg/org-contribute.html#commit-messages
>
> Also, you need to add etc/ORG-NEWS entry about the new functionality and
> also modify the manual.
>
> Finally, I see no records about you copyright assignment status.
> Please take a look at
> https://orgmode.org/worg/org-contribute.html#copyright
>
> > +(defun org-columns--move-row ( up)
> > +"Move table row. Calls `org-move-subtree-down' or
> `org-move-subtree-up'."
>
> *Move column view table row.
>
> We generally prefer single sentence as the first line of the docstring.
> Also, please describe UP argument in the docstring.
>
> > +;; Each column is an overlay on top of a character.  So there has
> > +;; to be at least as many characters available on the line as
> > +;; columns to display.
> > +;; 'org-columns--display-here'
> > +(ert-deftest test-org-colview/bug-add-whitespace ()
> > +  "Insert space characters if number of characters on the line
> > +  is lower then number of columns."
> > +  :expected-result :failed
>
> Does this test have anything to do with the new feature?
>
> > +(ert-deftest test-org-colview/columns-move-row-down ()
> > +  "Test `org-columns-move-row-down' specifications."
> > +  (should
> > +   (equal "* H
> > +** B
> > +** A
> > +"
> > +  (org-test-with-temp-text "* H
> > +** A
> > +** B
> > +"
> > +(let ((org-columns-default-format "%ITEM")) (org-columns)
> > + (next-line 1)
> > + (org-columns-move-row-down)
> > + (buffer-substring-no-properties (point-min)
> (point-max)))
>
> One special case we may want to consider is when columns are from
> different heading levels, like
>
> * H
> ** A
> *** A1
> ** B
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>
From c5cc24607306399d1b1ca583e63a2fe7b71dbf89 Mon Sep 17 00:00:00 2001
From: Sławomir Grochowski 
Date: Mon, 3 Apr 2023 19:23:09 +0200
Subject: [PATCH] lisp/org-colview.el: add new commands to move column view
 table row

* doc/org-manual.org (org-columns-move-row-up,
org-columns-move-row-down) and also (org-columns-move-left,
org-columns-move-right): Document two new and two old commands.
* etc/ORG-NEWS new commands to move rows up & down: Document the new feature.
* lisp/org-colview.el (org-columns--move-row, org-columns-move-row-up,
org-columns-move-row-down): New functions.
* testing/lisp/test-org-colview.el (test-org-colview/columns-move-row-down,
test-org-colview/columns-move-row-up,
test-org-colview/columns--move-row-stay-at-the-same-column,
test-org-colview/columns-move-row-down-with-subheading): New tests.
---
 doc/org-manual.org   | 24 
 etc/ORG-NEWS |  5 +++
 

Re: [RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-07 Thread Ihor Radchenko
Sławomir Grochowski  writes:

> Recently I often use 'column view' feature. 
> To my suprise in 'column view' user can't move rows up & down.
> So I wrote a little code snippet to be able to do it, and I'm sharing it with 
> you.
>
> Questions:
> 1. Why user can't move rows up & down in 'column view'?
> 2. Is this was intentional design decision?

I do not see any particular reason.
The current design dates back to 15 years ago - the initial commit in
our current git repo.

> I think 'column view' is missing one the core feel & functionality of 
> org-mode - moving rows (headings) up & down.
> In my experiance with 'column view' & tables I shuffle a lot of columns & 
> rows order.

Sounds reasonable.

> From 1f0f2052b8dddf4982ab35267ed1564f2250784b Mon Sep 17 00:00:00 2001
> From: Sławomir Grochowski 
> Date: Mon, 3 Apr 2023 19:23:09 +0200
> Subject: [PATCH] org-columns: add feat to move row up/down

The patch looks good in general, but you need to add proper commit
message. See https://orgmode.org/worg/org-contribute.html#commit-messages

Also, you need to add etc/ORG-NEWS entry about the new functionality and
also modify the manual.

Finally, I see no records about you copyright assignment status.
Please take a look at https://orgmode.org/worg/org-contribute.html#copyright

> +(defun org-columns--move-row ( up)
> +"Move table row. Calls `org-move-subtree-down' or `org-move-subtree-up'."

*Move column view table row.

We generally prefer single sentence as the first line of the docstring.
Also, please describe UP argument in the docstring.

> +;; Each column is an overlay on top of a character.  So there has
> +;; to be at least as many characters available on the line as
> +;; columns to display.
> +;; 'org-columns--display-here'
> +(ert-deftest test-org-colview/bug-add-whitespace ()
> +  "Insert space characters if number of characters on the line
> +  is lower then number of columns."
> +  :expected-result :failed

Does this test have anything to do with the new feature?

> +(ert-deftest test-org-colview/columns-move-row-down ()
> +  "Test `org-columns-move-row-down' specifications."
> +  (should
> +   (equal "* H
> +** B
> +** A
> +"
> +  (org-test-with-temp-text "* H
> +** A
> +** B
> +"
> +(let ((org-columns-default-format "%ITEM")) (org-columns)
> + (next-line 1)
> + (org-columns-move-row-down)
> + (buffer-substring-no-properties (point-min) 
> (point-max)))

One special case we may want to consider is when columns are from
different heading levels, like

* H
** A
*** A1
** B

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[RFC] [feat] org-colview/org-columns: 'column view' moving rows up/down

2023-04-06 Thread Sławomir Grochowski
Dear All,

This is my first proposal & code submit. 
I will be very gratefull for you comments & feedback what can be done better.  

Recently I often use 'column view' feature. 
To my suprise in 'column view' user can't move rows up & down.
So I wrote a little code snippet to be able to do it, and I'm sharing it with 
you.

Questions:
1. Why user can't move rows up & down in 'column view'?
2. Is this was intentional design decision?

I think 'column view' is missing one the core feel & functionality of org-mode 
- moving rows (headings) up & down.
In my experiance with 'column view' & tables I shuffle a lot of columns & rows 
order.

In my point of view 'core fuctionalities of org-mode' are: 
1. moving 'things' headings, rows, columns
   1. horizontally (left-right)
   2. vertically (up-down)
2. cyclic visibility

Let's compare this functionality in 3 areas:  

|   | heading | table | column view |
|---+-+---+-|
| moving left-right | [X] | [X]   | [X] |
| moving up-down| [X] | [X]   | [ ] |
| cyclic visibility | [X] | NA| [X] |

Cyclic visibility does not apply to 'table' because it operate on simple data, 
which is not structured, nested.

'Column view' transform 'headings' into rows, and their properties into 
columns, creating a table.

'Column view' is a combination of 'table' & 'heading':
'Heading' gives a 'table' properties for columns and cyclic visibilty feature, 
because it provide nested structure.
'Table' gives a 'heading' a 'column view' on heading properties.

'Column view' is similar to 'table'. They operate on same actions & keybindings.

| | column view  | table|
|-+--+--|
| move column left-right  | [X]  | [X]  |
| move column left-right keys | meta left-right  | meta left-right  |
| move row up-down| [ ]  | [X]  |
| move row up-down keys   |  | meta up-down |
| add column  | [X]  | [X]  |
| add column keys | shift-meta right | shift-meta right |
| remove column   | [X]  | [X]  |
| remove column keys  | shift-meta left  | shift-meta left  |

I thnik it would be beneficial to have consistance interface in 'column view' 
and 'table'.

Based on that, I propose to add functionality to 'move row up/down' in 'column 
view' and set keybinding the same as in table above -> meta up/down.
Patch is in the attachment.

What others think about it? 

Regards,
Sławomir Grochowski
>From 1f0f2052b8dddf4982ab35267ed1564f2250784b Mon Sep 17 00:00:00 2001
From: Sławomir Grochowski 
Date: Mon, 3 Apr 2023 19:23:09 +0200
Subject: [PATCH] org-columns: add feat to move row up/down

---
 lisp/org-colview.el  | 22 +++
 testing/lisp/test-org-colview.el | 66 
 2 files changed, 88 insertions(+)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 92a3b473d..0971d5eef 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -209,6 +209,8 @@ See `org-columns-summary-types' for details.")
 (org-defkey org-columns-map ">" #'org-columns-widen)
 (org-defkey org-columns-map [(meta right)] #'org-columns-move-right)
 (org-defkey org-columns-map [(meta left)]  #'org-columns-move-left)
+(org-defkey org-columns-map [(meta down)]  #'org-columns-move-row-down)
+(org-defkey org-columns-map [(meta up)]  #'org-columns-move-row-up)
 (org-defkey org-columns-map [(shift meta right)] #'org-columns-new)
 (org-defkey org-columns-map [(shift meta left)]  #'org-columns-delete)
 (dotimes (i 10)
@@ -1003,6 +1005,26 @@ details."
 (org-columns-move-right)
 (backward-char 1)))
 
+(defun org-columns--move-row ( up)
+"Move table row. Calls `org-move-subtree-down' or `org-move-subtree-up'."
+(let ((inhibit-read-only t)
+  (col (current-column)))
+  (if up (org-move-subtree-up)
+(org-move-subtree-down))
+  (let ((org-columns-inhibit-recalculation t))
+(org-columns-redo)
+(move-to-column col
+
+(defun org-columns-move-row-down ()
+  "Move table row (subtree) down."
+  (interactive)
+  (org-columns--move-row))
+
+(defun org-columns-move-row-up ()
+  "Move table row (subtree) up."
+  (interactive)
+  (org-columns--move-row 'up))
+
 (defun org-columns-store-format ()
   "Store the text version of the current columns format.
 The format is stored either in the COLUMNS property of the node
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 9daec18e2..fd02f054c 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -1010,6 +1010,72 @@
 	(list (get-char-property 1 'org-columns-value-modified)
 		  (get-char-property 2 'org-columns-value-modified))
 
+;; Each column is an overlay