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, 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.
This commit is contained in:
parent
58c5c5882c
commit
650e42996e
|
@ -5843,6 +5843,30 @@ either for all clocks or just for today.
|
||||||
#+findex: org-columns-delete
|
#+findex: org-columns-delete
|
||||||
Delete the current column.
|
Delete the current column.
|
||||||
|
|
||||||
|
- {{{kbd(M-LEFT)}}} (~org-columns-move-left~) ::
|
||||||
|
|
||||||
|
#+kindex: M-LEFT
|
||||||
|
#+findex: org-columns-move-left
|
||||||
|
Move the current column left.
|
||||||
|
|
||||||
|
- {{{kbd(M-RIGHT)}}} (~org-columns-move-right~) ::
|
||||||
|
|
||||||
|
#+kindex: M-RIGHT
|
||||||
|
#+findex: org-columns-move-right
|
||||||
|
Move the current column right.
|
||||||
|
|
||||||
|
- {{{kbd(M-UP)}}} (~org-columns-move-row-up~) ::
|
||||||
|
|
||||||
|
#+kindex: M-UP
|
||||||
|
#+findex: org-columns-move-row-up
|
||||||
|
Move the current row up.
|
||||||
|
|
||||||
|
- {{{kbd(M-DOWN)}}} (~org-columns-move-row-down~) ::
|
||||||
|
|
||||||
|
#+kindex: M-DOWN
|
||||||
|
#+findex: org-columns-move-row-down
|
||||||
|
Move the current row down.
|
||||||
|
|
||||||
*** Capturing column view
|
*** Capturing column view
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:DESCRIPTION: A dynamic block for column view.
|
:DESCRIPTION: A dynamic block for column view.
|
||||||
|
|
|
@ -895,6 +895,11 @@ After:
|
||||||
|
|
||||||
|
|
||||||
** New features
|
** New features
|
||||||
|
*** Column view: new commands to move rows up & down
|
||||||
|
You can move rows up & down in column view with
|
||||||
|
~org-columns-move-row-up~ and ~org-columns-move-row-down~.
|
||||||
|
Keybindings are the same as ~org-move-subtree-up~ and ~org-move-subtree-down~
|
||||||
|
=M-<up>= and =M-<down>=.
|
||||||
*** Clock table can now produce quarterly reports
|
*** Clock table can now produce quarterly reports
|
||||||
|
|
||||||
=:step= clock table parameter can now be set to =quarter=.
|
=:step= clock table parameter can now be set to =quarter=.
|
||||||
|
|
|
@ -210,6 +210,8 @@ See `org-columns-summary-types' for details.")
|
||||||
(org-defkey org-columns-map ">" #'org-columns-widen)
|
(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 right)] #'org-columns-move-right)
|
||||||
(org-defkey org-columns-map [(meta left)] #'org-columns-move-left)
|
(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 right)] #'org-columns-new)
|
||||||
(org-defkey org-columns-map [(shift meta left)] #'org-columns-delete)
|
(org-defkey org-columns-map [(shift meta left)] #'org-columns-delete)
|
||||||
(dotimes (i 10)
|
(dotimes (i 10)
|
||||||
|
@ -231,6 +233,8 @@ See `org-columns-summary-types' for details.")
|
||||||
"--"
|
"--"
|
||||||
["Move column right" org-columns-move-right t]
|
["Move column right" org-columns-move-right t]
|
||||||
["Move column left" org-columns-move-left t]
|
["Move column left" org-columns-move-left t]
|
||||||
|
["Move row up" org-columns-move-row-up t]
|
||||||
|
["Move row down" org-columns-move-row-down t]
|
||||||
["Add column" org-columns-new t]
|
["Add column" org-columns-new t]
|
||||||
["Delete column" org-columns-delete t]
|
["Delete column" org-columns-delete t]
|
||||||
"--"
|
"--"
|
||||||
|
@ -1021,6 +1025,27 @@ details."
|
||||||
(org-columns-move-right)
|
(org-columns-move-right)
|
||||||
(backward-char 1)))
|
(backward-char 1)))
|
||||||
|
|
||||||
|
(defun org-columns--move-row (&optional up)
|
||||||
|
"Move the current table row down.
|
||||||
|
With non-nil optional argument UP, move it 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 the current table row down."
|
||||||
|
(interactive)
|
||||||
|
(org-columns--move-row))
|
||||||
|
|
||||||
|
(defun org-columns-move-row-up ()
|
||||||
|
"Move the current table row up."
|
||||||
|
(interactive)
|
||||||
|
(org-columns--move-row 'up))
|
||||||
|
|
||||||
(defun org-columns-store-format ()
|
(defun org-columns-store-format ()
|
||||||
"Store the text version of the current columns format.
|
"Store the text version of the current columns format.
|
||||||
The format is stored either in the COLUMNS property of the node
|
The format is stored either in the COLUMNS property of the node
|
||||||
|
|
|
@ -1093,6 +1093,71 @@
|
||||||
(list (get-char-property 1 'org-columns-value-modified)
|
(list (get-char-property 1 'org-columns-value-modified)
|
||||||
(get-char-property 2 'org-columns-value-modified))))))
|
(get-char-property 2 'org-columns-value-modified))))))
|
||||||
|
|
||||||
|
(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)))))))
|
||||||
|
|
||||||
|
(ert-deftest test-org-colview/columns-move-row-up ()
|
||||||
|
"Test `org-columns-move-row-up' specifications."
|
||||||
|
(should
|
||||||
|
(equal "* H
|
||||||
|
** B
|
||||||
|
** A
|
||||||
|
"
|
||||||
|
(org-test-with-temp-text "* H
|
||||||
|
** A
|
||||||
|
** B
|
||||||
|
"
|
||||||
|
(let ((org-columns-default-format "%ITEM")) (org-columns)
|
||||||
|
(next-line 2)
|
||||||
|
(org-columns-move-row-up)
|
||||||
|
(buffer-substring-no-properties (point-min) (point-max)))))))
|
||||||
|
|
||||||
|
(ert-deftest test-org-colview/columns--move-row-stay-at-the-same-column ()
|
||||||
|
"After function call 'org-columns--move-row' point should stay at the same column."
|
||||||
|
(should
|
||||||
|
(equal 35
|
||||||
|
(org-test-with-temp-text "* H
|
||||||
|
** A
|
||||||
|
** B
|
||||||
|
"
|
||||||
|
(org-columns)
|
||||||
|
(next-line 1)
|
||||||
|
(forward-char 2)
|
||||||
|
(org-columns--move-row)
|
||||||
|
(current-column)))))
|
||||||
|
|
||||||
|
(ert-deftest test-org-colview/columns-move-row-down-with-subheading ()
|
||||||
|
"Test `org-columns-move-row-up' specifications with subheading."
|
||||||
|
(should
|
||||||
|
(equal "* H
|
||||||
|
** B
|
||||||
|
** A
|
||||||
|
*** A1
|
||||||
|
"
|
||||||
|
|
||||||
|
(org-test-with-temp-text "* H
|
||||||
|
** A
|
||||||
|
*** A1
|
||||||
|
** 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)))))))
|
||||||
|
|
||||||
(ert-deftest test-org-colview/columns-move-left ()
|
(ert-deftest test-org-colview/columns-move-left ()
|
||||||
"Test `org-columns-move-left' specifications."
|
"Test `org-columns-move-left' specifications."
|
||||||
;; Error when trying to move the left-most column.
|
;; Error when trying to move the left-most column.
|
||||||
|
|
Loading…
Reference in New Issue