2016-02-14 17:18:48 -05:00
|
|
|
|
;;; test-org-colview.el --- Tests for org-colview.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
2019-01-01 05:50:56 -05:00
|
|
|
|
;; Copyright (C) 2016, 2019 Nicolas Goaziou
|
2016-02-14 17:18:48 -05:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
|
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2021-03-20 03:27:57 -04:00
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-02-14 17:18:48 -05:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;;; Column view
|
|
|
|
|
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(require 'cl-lib)
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(require 'org-colview)
|
|
|
|
|
(require 'org-duration)
|
|
|
|
|
(require 'org-inlinetask)
|
2016-02-17 09:19:11 -05:00
|
|
|
|
|
2023-04-17 13:18:16 -04:00
|
|
|
|
(ert-deftest test-org-colview/uncompile-format ()
|
|
|
|
|
"Test `org-columns-uncompile-format' specifications."
|
|
|
|
|
;; With minimum data, one element
|
|
|
|
|
(should
|
|
|
|
|
(equal "%ITEM"
|
|
|
|
|
(org-columns-uncompile-format '(("ITEM" "ITEM" nil nil nil)))))
|
|
|
|
|
;; With minimum data, two element
|
|
|
|
|
(should
|
|
|
|
|
(equal "%ITEM %TODO"
|
|
|
|
|
(org-columns-uncompile-format
|
|
|
|
|
`(("ITEM" "ITEM" nil nil nil) ("TODO" "TODO" nil nil nil)))))
|
|
|
|
|
;; Read width
|
|
|
|
|
(should
|
|
|
|
|
(equal "%10ITEM"
|
|
|
|
|
(org-columns-uncompile-format `(("ITEM" "ITEM" 10 nil nil)))))
|
|
|
|
|
;; Read title
|
|
|
|
|
(should
|
|
|
|
|
(equal "%ITEM(some title)"
|
|
|
|
|
(org-columns-uncompile-format `(("ITEM" "some title" nil nil nil)))))
|
|
|
|
|
;; Read operator
|
|
|
|
|
(should
|
|
|
|
|
(equal "%ITEM{+}"
|
|
|
|
|
(org-columns-uncompile-format `(("ITEM" "ITEM" nil "+" nil)))))
|
|
|
|
|
;; Read operator printf
|
|
|
|
|
(should
|
|
|
|
|
(equal "%ITEM{+;%.1f}"
|
|
|
|
|
(org-columns-uncompile-format `(("ITEM" "ITEM" nil "+" "%.1f"))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-colview/compile-format ()
|
|
|
|
|
"Test `org-columns-compile-format' specifications."
|
|
|
|
|
;; With minimum data, one element
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "ITEM" nil nil nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%ITEM")))
|
|
|
|
|
;; With minimum data, two element
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "ITEM" nil nil nil) ("TODO" "TODO" nil nil nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%ITEM %TODO")))
|
|
|
|
|
;; Read width
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "ITEM" 10 nil nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%10ITEM")))
|
|
|
|
|
;; Upcase property name
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "item" nil nil nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%item")))
|
|
|
|
|
;; Read title
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "some title" nil nil nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%ITEM(some title)")))
|
|
|
|
|
;; Read operator
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "ITEM" nil "+" nil))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%ITEM{+}")))
|
|
|
|
|
;; Read operator printf
|
|
|
|
|
(should
|
|
|
|
|
(equal `(("ITEM" "ITEM" nil "+" "%.1f"))
|
|
|
|
|
(org-columns-compile-format
|
|
|
|
|
"%ITEM{+;%.1f}"))))
|
|
|
|
|
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(ert-deftest test-org-colview/substring-below-width ()
|
|
|
|
|
"Test `org-columns--truncate-below-width'."
|
|
|
|
|
(cl-flet ((check (string width expect)
|
|
|
|
|
(string= expect (org-columns--truncate-below-width
|
|
|
|
|
string width))))
|
|
|
|
|
(if (= (char-width ?…) 2)
|
|
|
|
|
(progn (should (check "12…" 3 "12"))
|
|
|
|
|
(should (check "1…2" 1 "1"))
|
|
|
|
|
(should (check "1…2" 2 "1"))
|
|
|
|
|
(should (check "1…2" 3 "1…"))
|
|
|
|
|
(should (check "……………………" 7 "………")))
|
|
|
|
|
(progn (should (check "12…" 4 "12…"))
|
|
|
|
|
(should (check "1…2" 1 "1"))
|
|
|
|
|
(should (check "1…2" 2 "1…"))
|
|
|
|
|
(should (check "1…2" 3 "1…2"))
|
|
|
|
|
(should (check "……………………" 7 "…………………"))))))
|
|
|
|
|
|
2016-02-23 09:11:58 -05:00
|
|
|
|
(ert-deftest test-org-colview/get-format ()
|
|
|
|
|
"Test `org-columns-get-format' specifications."
|
|
|
|
|
;; Without any clue, use `org-columns-default-format'.
|
|
|
|
|
(should
|
|
|
|
|
(equal "%A"
|
|
|
|
|
(org-test-with-temp-text "* H"
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format)))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
;; If COLUMNS keyword is set, use it.
|
|
|
|
|
(should
|
|
|
|
|
(equal "%B"
|
|
|
|
|
(org-test-with-temp-text "#+COLUMNS: %B\n* H"
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format)))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "%B"
|
|
|
|
|
(org-test-with-temp-text "#+columns: %B\n* H"
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format)))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "%B"
|
|
|
|
|
(org-test-with-temp-text "* H\n#+COLUMNS: %B"
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format)))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
;; When :COLUMNS: property is set somewhere in the tree, use it over
|
|
|
|
|
;; the previous ways.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"%C"
|
|
|
|
|
(org-test-with-temp-text
|
2023-04-25 10:56:02 -04:00
|
|
|
|
"#+COLUMNS: %B\n* H\n:PROPERTIES:\n:COLUMNS: %C\n:END:\n** S\n<point>"
|
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format)))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
;; When optional argument is provided, prefer it.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"%D"
|
|
|
|
|
(org-test-with-temp-text
|
2023-04-25 10:56:02 -04:00
|
|
|
|
"#+COLUMNS: %B\n* H\n:PROPERTIES:\n:COLUMNS: %C\n:END:\n** S\n<point>"
|
|
|
|
|
(let ((org-columns-default-format "%A"))
|
|
|
|
|
(org-columns-get-format "%D"))))))
|
2016-02-23 09:11:58 -05:00
|
|
|
|
|
2016-02-14 17:18:48 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-scope ()
|
|
|
|
|
"Test `org-columns' scope."
|
|
|
|
|
;; Before the first headline, view all document.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("H1" "H2" "H3")
|
|
|
|
|
(org-test-with-temp-text "Top\n* H1\n** H2\n* H3"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-map-entries
|
|
|
|
|
(lambda () (get-char-property (point) 'org-columns-value))))))
|
|
|
|
|
;; When :COLUMNS: is set up in the hierarchy, view tree starting
|
|
|
|
|
;; there.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(nil "H2" "H3" nil)
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n** H2\n:PROPERTIES:\n:COLUMNS: %ITEM\n:END:\n*** <point>H3\n* H4"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-map-entries
|
|
|
|
|
(lambda () (get-char-property (point) 'org-columns-value))))))
|
|
|
|
|
;; Otherwise, view tree starting at the current headline.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(nil "H2" "H3" nil)
|
|
|
|
|
(org-test-with-temp-text "Top\n* H1\n** <point>H2\n*** H3\n* H4"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-map-entries
|
|
|
|
|
(lambda () (get-char-property (point) 'org-columns-value))))))
|
|
|
|
|
;; With a non-nil prefix argument, always view all document.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("H1" "H2" "H3" "H4")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n** H2\n:PROPERTIES:\n:COLUMNS: %ITEM\n:END:\n*** <point>H3\n* H4"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns t))
|
|
|
|
|
(org-map-entries
|
|
|
|
|
(lambda () (get-char-property (point) 'org-columns-value))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-05-30 07:38:54 -04:00
|
|
|
|
'("1" "1")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"Top\n* H1\n** <point>H2\n:PROPERTIES:\n:A: 1\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{+}")) (org-columns t))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
(org-map-entries
|
|
|
|
|
(lambda () (get-char-property (point) 'org-columns-value)))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-colview/columns-width ()
|
|
|
|
|
"Test `org-columns' column widths."
|
|
|
|
|
;; When a width is specified in the format, use it.
|
|
|
|
|
(should
|
|
|
|
|
(= 9
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%9ITEM")) (org-columns))
|
2016-02-22 06:19:22 -05:00
|
|
|
|
(aref org-columns-current-maxwidths 0))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; Otherwise, use the width of the largest value in the column.
|
|
|
|
|
(should
|
|
|
|
|
(= 2
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:P: X\n:END:\n** H2\n:PROPERTIES:\n:P: XX\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%P")) (org-columns))
|
2016-02-22 06:19:22 -05:00
|
|
|
|
(aref org-columns-current-maxwidths 0))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; If the title is wider than the widest value, use title width
|
|
|
|
|
;; instead.
|
|
|
|
|
(should
|
|
|
|
|
(= 4
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-22 06:19:22 -05:00
|
|
|
|
(aref org-columns-current-maxwidths 0))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; Special case: stars do count for ITEM.
|
|
|
|
|
(should
|
|
|
|
|
(= 6
|
|
|
|
|
(org-test-with-temp-text "* Head"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-22 06:19:22 -05:00
|
|
|
|
(aref org-columns-current-maxwidths 0))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; Special case: width takes into account link narrowing in ITEM.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-01-01 11:23:35 -05:00
|
|
|
|
'("* 123" . 5)
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-temp-text "* [[https://orgmode.org][123]]"
|
2016-02-14 17:18:48 -05:00
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(cons (get-char-property (point) 'org-columns-value-modified)
|
2016-02-22 06:19:22 -05:00
|
|
|
|
(aref org-columns-current-maxwidths 0)))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; When a value is too wide for the current column, add ellipses.
|
|
|
|
|
;; Take into consideration length of `org-columns-ellipses'.
|
|
|
|
|
(should
|
|
|
|
|
(equal "123.. |"
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:P: 123456\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%5P")
|
|
|
|
|
(org-columns-ellipses ".."))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(org-trim (get-char-property (point) 'display)))))
|
|
|
|
|
(should
|
2023-04-25 10:56:02 -04:00
|
|
|
|
(equal (if (= 1 (char-width ?…)) "1234… |" "123… |")
|
2016-02-14 17:18:48 -05:00
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:P: 123456\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%5P")
|
|
|
|
|
(org-columns-ellipses "…"))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(org-trim (get-char-property (point) 'display))))))
|
|
|
|
|
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-summary ()
|
|
|
|
|
"Test `org-columns' summary types."
|
|
|
|
|
;; {+} and {+;format} add numbers.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"3"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{+}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"3.0"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{+;%.1f}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {$} is a shortcut for {+;%.2f}.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"3.60"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1.50
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2.10
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{$}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2017-05-20 16:11:45 -04:00
|
|
|
|
;; Obey to format string even in leaf values.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"1.0"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{+;%.1f}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2018-06-21 16:05:17 -04:00
|
|
|
|
;; {:} sums times. Plain numbers are minutes.
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"4:10"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:30
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2:40
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2018-06-21 16:05:17 -04:00
|
|
|
|
"1:32"
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:30
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {X}, {X/} and {X%} indicate checkbox status.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[ ]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[-]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[X]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[1/2]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X/}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[50%]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
2017-05-21 05:08:11 -04:00
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X%}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {X/} handles recursive summaries.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[1/2]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S2
|
|
|
|
|
*** S21
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:
|
|
|
|
|
*** S22
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X/}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[1/2]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:
|
|
|
|
|
** S2
|
|
|
|
|
*** S21
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
*** S22
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X/}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {X%} handles recursive summaries.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[50%]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
** S2
|
|
|
|
|
*** S21
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:
|
|
|
|
|
*** S22
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X%}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"[50%]"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [X]
|
|
|
|
|
:END:
|
|
|
|
|
** S2
|
|
|
|
|
*** S21
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
|
|
|
|
:END:
|
|
|
|
|
*** S22
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: [ ]
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{X%}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {min} is the smallest number in column, {max} the largest one.
|
|
|
|
|
;; {mean} is the arithmetic mean of numbers in column.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"42"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{min}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"99"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{max}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"51.0"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 60
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{mean}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {:min}, {:max} and {:mean} apply to time values.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"1:20"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 4:40
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:min}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"4:40"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 4:40
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:max}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"3:00"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 4:40
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:mean}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {@min}, {@max} and {@mean} apply to ages.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-08 16:24:32 -05:00
|
|
|
|
"0min"
|
2019-02-12 17:44:23 -05:00
|
|
|
|
(org-test-at-time "<2014-03-04 Tue>"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
2016-02-17 09:19:11 -05:00
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: <2012-03-29 Thu>
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: <2014-03-04 Tue>
|
|
|
|
|
:END:"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(let ((org-columns-default-format "%A{@min}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified)))))
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-12-03 02:57:37 -05:00
|
|
|
|
"2d"
|
2019-02-12 17:44:23 -05:00
|
|
|
|
(org-test-at-time "<2014-03-04 Tue>"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
2016-02-17 09:19:11 -05:00
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-12-03 02:57:37 -05:00
|
|
|
|
:A: <2014-03-03 Mon>
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-12-03 02:57:37 -05:00
|
|
|
|
:A: <2014-03-02 Sun>
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(let ((org-columns-default-format "%A{@max}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified)))))
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-12-03 02:57:37 -05:00
|
|
|
|
"1d 12h"
|
2019-02-12 17:44:23 -05:00
|
|
|
|
(org-test-at-time "<2014-03-04 Tue>"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
2016-02-17 09:19:11 -05:00
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-12-03 02:57:37 -05:00
|
|
|
|
:A: <2014-03-03 Mon>
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-12-03 02:57:37 -05:00
|
|
|
|
:A: <2014-03-02 Sun>
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:"
|
2016-06-04 15:27:55 -04:00
|
|
|
|
(let ((org-columns-default-format "%A{@mean}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified)))))
|
2016-02-20 16:42:51 -05:00
|
|
|
|
;; If a time value is expressed as a duration, return a duration.
|
2016-11-11 06:02:34 -05:00
|
|
|
|
;; If any of them follows H:MM:SS pattern, use it too. Also handle
|
|
|
|
|
;; combinations of duration and H:MM:SS patterns.
|
2016-02-20 16:42:51 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-08 16:24:32 -05:00
|
|
|
|
"3d 4:20"
|
2016-02-20 16:42:51 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 3d 3h
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:}")
|
2017-02-08 16:24:32 -05:00
|
|
|
|
(org-duration-units '(("d" . 1440) ("h" . 60)))
|
|
|
|
|
(org-duration-format '(("d" . nil) (special . h:mm))))
|
2016-02-20 16:42:51 -05:00
|
|
|
|
(org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"6:00:10"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 4:40:10
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2016-11-11 06:02:34 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-08 16:24:32 -05:00
|
|
|
|
"3d 4:20"
|
2016-11-11 06:02:34 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 3d 3h
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 0d 1:20
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{:}")
|
2017-02-08 16:24:32 -05:00
|
|
|
|
(org-duration-units '(("d" . 1440) ("h" . 60)))
|
|
|
|
|
(org-duration-format '(("d" . nil) (special . h:mm))))
|
2016-11-11 06:02:34 -05:00
|
|
|
|
(org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2017-02-08 16:24:32 -05:00
|
|
|
|
;; @min, @max and @mean also accept regular duration.
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-08 16:24:32 -05:00
|
|
|
|
"1d 10h"
|
2016-02-17 09:19:11 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-02-08 16:24:32 -05:00
|
|
|
|
:A: 1d 10h 0min
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
2017-02-08 16:24:32 -05:00
|
|
|
|
:A: 5d 3h
|
2016-02-17 09:19:11 -05:00
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{@min}")) (org-columns))
|
2016-02-17 15:35:34 -05:00
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; {est+} gives a low-high estimate using mean and standard
|
|
|
|
|
;; deviation.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"3-17"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 0-10
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 0-10
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{est+}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; When using {est+} summary, a single number is understood as
|
|
|
|
|
;; a degenerate range.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"4-4"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 4
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%A{est+}")) (org-columns))
|
2016-02-20 18:16:51 -05:00
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2016-02-22 09:00:31 -05:00
|
|
|
|
;; Allow custom summary types.
|
2016-02-20 18:16:51 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"1|2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-summary-types
|
|
|
|
|
'(("custom" . (lambda (s _) (mapconcat #'identity s "|")))))
|
|
|
|
|
(org-columns-default-format "%A{custom}")) (org-columns))
|
2016-02-22 09:00:31 -05:00
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
2017-09-08 15:26:56 -04:00
|
|
|
|
;; Allow custom _collect_ for summary types.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:A-OK: 1
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-summary-types
|
|
|
|
|
'(("custom" org-columns--summary-sum
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(if (equal "1" (org-entry-get nil (format "%s-OK" p)))
|
|
|
|
|
(org-entry-get nil p)
|
|
|
|
|
"")))))
|
|
|
|
|
(org-columns-default-format "%A{custom}")) (org-columns))
|
|
|
|
|
(get-char-property (point) 'org-columns-value-modified))))
|
|
|
|
|
;; Allow custom collect function to be used for different columns
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("2" "1")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:B: 1
|
|
|
|
|
:B-OK: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:B: 2
|
|
|
|
|
:A-OK: 1
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-summary-types
|
|
|
|
|
'(("custom" org-columns--summary-sum
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(if (equal "1" (org-entry-get nil (format "%s-OK" p)))
|
|
|
|
|
(org-entry-get nil p)
|
|
|
|
|
"")))))
|
|
|
|
|
(org-columns-default-format "%A{custom} %B{custom}")) (org-columns))
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value-modified)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value-modified)))))
|
2016-02-22 09:00:31 -05:00
|
|
|
|
;; Allow multiple summary types applied to the same property.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("42" "99")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{min} %A{max}")) (org-columns))
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value-modified)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value-modified)))))
|
|
|
|
|
;; Allow mixing both summarized and non-summarized columns for
|
|
|
|
|
;; a property. However, the first column takes precedence and
|
|
|
|
|
;; updates the value.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("1000" "42")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1000
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %A{min}")) (org-columns))
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value-modified)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value-modified)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("42" "42")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1000
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 42
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{min} %A")) (org-columns))
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value-modified)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value-modified))))))
|
2016-02-17 09:19:11 -05:00
|
|
|
|
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-new ()
|
|
|
|
|
"Test `org-columns-new' specifications."
|
|
|
|
|
;; Insert new column at the left of the current one.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("FOO" "ITEM")
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(list (get-char-property (point) 'org-columns-key)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-key)))))
|
|
|
|
|
(should
|
2016-02-21 13:30:13 -05:00
|
|
|
|
(equal '("ITEM" "FOO" "BAR")
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %BAR")) (org-columns))
|
|
|
|
|
(forward-char)
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(list (get-char-property (1- (point)) 'org-columns-key)
|
|
|
|
|
(get-char-property (point) 'org-columns-key)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-key)))))
|
2016-02-22 04:48:00 -05:00
|
|
|
|
;; Update #+COLUMNS keyword if needed.
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "#+COLUMNS: %FOO %ITEM"
|
|
|
|
|
(org-test-with-temp-text "#+COLUMNS: %ITEM\n<point>* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "#+COLUMNS: %ITEM %FOO %BAR"
|
|
|
|
|
(org-test-with-temp-text "#+COLUMNS: %ITEM %BAR\n<point>* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %BAR")) (org-columns))
|
|
|
|
|
(forward-char)
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-21 08:59:52 -05:00
|
|
|
|
(goto-char (point-min))
|
2016-02-22 04:48:00 -05:00
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))
|
|
|
|
|
;; Mind case when updating #+COLUMNS.
|
|
|
|
|
(should
|
|
|
|
|
(equal "#+COLUMNS: %ITEM %Foo %BAR"
|
|
|
|
|
(org-test-with-temp-text "#+COLUMNS: %ITEM %BAR\n<point>* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %BAR")) (org-columns))
|
|
|
|
|
(forward-char)
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "Foo" "Foo" nil nil nil)
|
2016-02-22 04:48:00 -05:00
|
|
|
|
(goto-char (point-min))
|
2016-02-22 16:42:03 -05:00
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "#+columns: %ITEM %Foo %BAR"
|
|
|
|
|
(org-test-with-temp-text "#+columns: %ITEM %BAR\n<point>* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %BAR")) (org-columns))
|
|
|
|
|
(forward-char)
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "Foo" "Foo" nil nil nil)
|
2016-02-22 16:42:03 -05:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))
|
|
|
|
|
;; Also update :COLUMNS: properties.
|
|
|
|
|
(should
|
|
|
|
|
(equal "%FOO %ITEM"
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:COLUMNS: %ITEM\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-22 16:42:03 -05:00
|
|
|
|
(org-entry-get nil "COLUMNS"))))
|
|
|
|
|
;; If no keyword nor any property is available, insert one.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p (regexp-quote "#+COLUMNS: %FOO %ITEM")
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
2016-02-23 10:22:17 -05:00
|
|
|
|
(org-columns-new nil "FOO" "FOO" nil nil nil)
|
2016-02-22 16:42:03 -05:00
|
|
|
|
(buffer-string)))))
|
2016-02-21 08:59:52 -05:00
|
|
|
|
|
2016-02-17 16:38:39 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-update ()
|
|
|
|
|
"Test `org-columns-update' specifications."
|
|
|
|
|
;; Update display.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"12 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%5A")) (org-columns))
|
|
|
|
|
(search-forward "1")
|
|
|
|
|
(insert "2")
|
|
|
|
|
(org-columns-update "A")
|
|
|
|
|
(get-char-property (point-min) 'display))))
|
2016-02-22 04:48:00 -05:00
|
|
|
|
;; Update is case-insensitive.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"12 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%5A")) (org-columns))
|
|
|
|
|
(search-forward "1")
|
|
|
|
|
(insert "2")
|
|
|
|
|
(org-columns-update "a")
|
|
|
|
|
(get-char-property (point-min) 'display))))
|
2016-02-17 16:38:39 -05:00
|
|
|
|
;; Update stored values.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("12" "12")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%5A")) (org-columns))
|
|
|
|
|
(search-forward "1")
|
|
|
|
|
(insert "2")
|
|
|
|
|
(org-columns-update "A")
|
|
|
|
|
(list (get-char-property (point-min) 'org-columns-value)
|
|
|
|
|
(get-char-property (point-min) 'org-columns-value-modified)))))
|
2016-02-22 09:00:31 -05:00
|
|
|
|
;; When multiple columns are using the same property, value is
|
|
|
|
|
;; updated according to the specifications of the first one.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A{min} %A")) (org-columns))
|
|
|
|
|
(org-columns-update "A")
|
|
|
|
|
(org-entry-get nil "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %A{min}")) (org-columns))
|
|
|
|
|
(org-columns-update "A")
|
|
|
|
|
(org-entry-get nil "A"))))
|
|
|
|
|
;; Ensure modifications propagate in upper levels even when multiple
|
|
|
|
|
;; summary types apply to the same property.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("1" "22")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S2
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: <point>2
|
|
|
|
|
:END:"
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((org-columns-default-format "%A{min} %A{max}")) (org-columns)))
|
|
|
|
|
(insert "2")
|
|
|
|
|
(org-columns-update "A")
|
|
|
|
|
(list (get-char-property 1 'org-columns-value)
|
|
|
|
|
(get-char-property 2 'org-columns-value-modified)))))
|
2016-02-17 16:38:39 -05:00
|
|
|
|
;; Ensure additional processing is done (e.g., ellipses, special
|
|
|
|
|
;; keywords fontification...).
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"ve.. |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: text
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%4A")
|
|
|
|
|
(org-columns-ellipses ".."))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(search-forward ":A: ")
|
|
|
|
|
(insert "very long ")
|
|
|
|
|
(org-columns-update "A")
|
2016-02-18 05:33:33 -05:00
|
|
|
|
(get-char-property (point-min) 'display))))
|
|
|
|
|
;; Values obtained from inline tasks are at the same level as those
|
|
|
|
|
;; obtained from children of the current node.
|
|
|
|
|
(when (featurep 'org-inlinetask)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
*************** Inline task
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:
|
|
|
|
|
*************** END
|
|
|
|
|
** Children
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 3
|
|
|
|
|
:END:
|
|
|
|
|
"
|
|
|
|
|
(let ((org-columns-default-format "%A{min}")
|
|
|
|
|
(org-columns-ellipses "..")
|
|
|
|
|
(org-inlinetask-min-level 15))
|
Re-implement org-element-cache and add headline support
* lisp/org-element.el (org-element-with-disabled-cache): New macro.
(org-element-greater-elements): Add new org-data element. It
functions like a virtual headline containing the whole buffer. The
org-data properties are like headlie properties, but according to the
top-level drawer. org-data's category is the buffer's category as
defined by top-level property drawer, #+CATEGORY keyworsd, and the
buffer file name.
(org-element--cache-element-properties, org-element-set-element): New
variable containing properties to be transferred when updating changed
element in cache in `org-element-set-element'.
(org-element--get-node-properties): Allow parsing node propreties in
top-level drawer when new optional argument is passed. Respect
PROPERTY+ syntax.
(org-element--get-global-node-properties): New function. It returns
node properties for top-level property drawer.
(org-element-org-data-parser, org-element-org-data-interpreter):
Implement the new org-data element.
(org-element-headline-parser, org-element-section-parser): Add new
:robust-begin and :robust-end
properties delimiting safe changes that do not modify headline
element.
(org-element--list-struct): Fix cache update when adding a headline
inside list.
(org-element--current-element): Implement cache support. Record
parsing mode (:mode) and parsing granularity (:granularity) in the
element properties.
(org-element-parse-buffer, org-element--next-mode): Support new
org-data element.
(org-element--parse-elements): Record parsing granularity in the
returned tree
(org-element-use-cache): Enable cache by default.
(org-element-cache-persistent): New variable controlling cache
persistance across sessions. Enabled by default.
(org-element--cache-self-verify,
org-element--cache-self-verify-frequency,
org-element--cache-diagnostics, org-element--cache-map-statistics,
org-element--cache-map-statistics-threshold,
org-element--cache-diagnostics-level,
org-element--cache-diagnostics-ring,
org-element--cache-diagnostics-ring-size): New variables controlling
cache diagnostics and self-diagnostics. Greatly simplifies cache
debugging.
(org-element--cache, org-element--cache-sync-requests,
org-element--cache-sync-timer): Make cache buffer-local by default.
(org-element--headline-cache): Implement separate cache storing only
headlines and inlinetasks.
(org-element--cache-size, org-element--headline-cache-size): New
variables containing cache sizes. This is much faster than
`avl-tree-size'.
(org-element--cache-sync-requests): Update docstring explaning the
request list structure.
(org-element--cache-sync-keys-value): New variable replacing
`org-element--cache-sync-keys' hash table. The hash table was not
reliable because it was using elements as keys. Upon any cached
element update/shift, the keys were invalidated making cache ordering
incorrect and breaking the cache badly. Now, the cache keys are
stored as :org-element--cache-sync-key element property and the new
variable stores marker value indicating the current sync request
cycle. See `org-element--cache-key' for more details.
(org-element--cache-change-tic): New variable controlling buffer
modification count that is registered in cache. This variable allows
catching "stealth" edits.
(org-element--cache-non-modifying-commands): New variable listing
commands that will not be slown down if we fill cache on the fly.
(org-element--request-key, org-element--request-beg,
org-element--request-end, org-element--request-offset,
org-element--request-parent, org-element--request-phase): New macros.
They improve code readability (especially when using nameless-mode).
(org-element--format-element, org-element--cache-log-message,
org-element--cache-warn): New macros implementing generic logging
functionality.
(org-element--cache-key): Add section and org-data element support.
Change cache key storage from hash map to :org-element--cache-sync-key
element property + `org-element--cache-sync-keys-value'. We use the
latter to group all the cache keys during a single cache request
sequence. Once sync request is fully complete, the
`org-element--cache-sync-keys-value' is updated making all the old
sync keys obsolete (they will still be store as element properties).
(org-element--headline-cache-root): New function returning headline
cache root.
(org-element--cache-active-p): Prevent cache updates when
`inhibit-modification-hooks' is non-nil, unless non-nil optional
argument is provided.
(org-element--cache-find): Share cache between indirect buffers and
the base buffer. We have to do it because after-change hooks for
indirect buffer are not called in the base buffer and vice versa. Add
support for section and org-data elements.
(org-element--cache-put): Implement new approach for cache key
storage. Add diagnostics. Indicate cached elements using :cached
element property. Support cache size calculation.
(org-element--cache-remove): Invalidate parent contents when removing
element. Support cache size calculation. Detect cache corruption due
to misordered elements.
(org-element--cache-shift-positions): Support :robust-begin and
:robust-end element properties.
(org-element--cache-sync): Add diagnostics. Add detailed comments.
Prevent slowdown when large cache chunks need to be deleted forcing
O(N) complexity cutoff. In phase 2, fix cases when next request
contains deleted cache key. In phase 2, fix scenario when newly
inserted element intersects with existing elements in cache. In phase
2, detect obsolete parents removed from cache.
(org-element--open-end-p): New function checking if an element can
have blank lines right after its :contents-end.
(org-element--parse-to): Do not alter match data. Process complex
parsing mode changes correctly. Support headlines in cache. Support
org-data parsing. Add detailed comments. Add diagnostics.
(org-element--cache-sensitive-re): Make list lines sensitive.
(org-element--cache-change-warning): Update docstring. Now, the
variable can have t, nil, and number values. Numbers are used to
provide more details about changed headlines.
(org-element--cache-before-change, org-element--cache-after-change):
Handle headline hierarchy. Properly handle cache in indirect
buffers.
(org-element--cache-after-change): Update docstring clarifying the
return values. Add special handling for headline and org-data
elements updating them in-place instead of removing together with the
whole contents when possible. Use :robust-begin/:robust-end element
properties to detect robust changes.
(org-element--cache-submit-request): Add detailed comments. Correctly
handle cache in indirect buffers. Delegate element modifications to
`org-element--cache-for-removal'.
(org-element--cache-verify-element): New function for cache
self-verification.
(org-element--cache-persist-before-write,
org-element--cache-persist-before-read,
org-element--cache-persist-after-read): Implement cache persistance.
(org-element-cache-reset): Correctly handle cache in indirect
buffers. Support cache persistance. Support new cache size
calculation and new cache key schema.
(org-element-cache-map): New function analagous to `org-element-map',
but much faster. The function overperforms org-ql written by Adam
Porter aka alphapapa [1] and reuses some ideas from there (namely,
fast element skipping via regexps).
[1] https://github.com/alphapapa/org-ql/
(org-element-at-point): The returned elements are now guaranteed to
have correct parents up to org-data. New optional argument
CACHED-ONLY limits element search to current cache---if element is not
in cache and current command is not in cache
`org-element--cache-non-modifying-commands', the cache is not updated
and the function returns nil. Also, support cache verification.
(org-element-at-point-no-context): New function. It is analogous of
older `org-element-at-point' with no guarantee that :parent properties
are correct beyond direct parent heading. This function does not
update cache and can be useful when cache updates should be avoided
for performance reasons.
* lisp/ob-core.el (org-babel-where-is-src-block-result): Support
section and org-data elements in cache.
* lisp/org-macro.el (org-macro-replace-all,
org-macro--find-keyword-value): Support org-element-cache.
* lisp/org-table.el (orgtbl-to-generic): Support org-element-cache.
* lisp/org.el (org-mode): Add cache persistance.
(org-up-element): Preserve old behaviour when error is returned for
section and org-data element.
*
testing/lisp/test-org-archive.el (test-org-archive/update-status-cookie):
Fix test when cache is active.
* testing/lisp/test-org-colview.el (test-org-colview/columns-update):
Fix test.
* testing/lisp/test-org-element.el (test-org-element/extract-element):
Add suport for new org-data element.
* testing/lisp/test-org-element.el (test-org-element/parent-property):
Fix equality check. Parents returned by cache and `org-element-map'
may not be `eq' now. Just `equal'.
* testing/lisp/test-org-element.el (test-org-element/context): Support
section and headline parents.
2021-10-16 09:17:10 -04:00
|
|
|
|
(org-element-update-syntax)
|
2016-02-18 05:33:33 -05:00
|
|
|
|
(org-columns))
|
2016-02-22 09:00:31 -05:00
|
|
|
|
(get-char-property (point-min) 'org-columns-value)))))
|
|
|
|
|
;; Handle `org-columns-modify-value-for-display-function', even with
|
|
|
|
|
;; multiple titles for the same property.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("foo" "bar")
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %ITEM(Name)")
|
|
|
|
|
(org-columns-modify-value-for-display-function
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (title _value)
|
2016-02-22 09:00:31 -05:00
|
|
|
|
(pcase title ("ITEM" "foo") ("Name" "bar") (_ "baz")))))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(list (get-char-property 1 'org-columns-value-modified)
|
|
|
|
|
(get-char-property 2 'org-columns-value-modified))))))
|
2016-02-17 16:38:39 -05:00
|
|
|
|
|
2023-04-03 13:23:09 -04:00
|
|
|
|
(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."
|
2023-08-21 03:21:33 -04:00
|
|
|
|
;; `current-column' did not return _visual_ column prior to Emacs 29.
|
2023-08-21 05:58:44 -04:00
|
|
|
|
(skip-unless (version<= "29" emacs-version))
|
2023-04-03 13:23:09 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal 35
|
2023-08-21 03:21:33 -04:00
|
|
|
|
(org-test-with-temp-text "* H
|
2023-04-03 13:23:09 -04:00
|
|
|
|
** A
|
|
|
|
|
** B
|
|
|
|
|
"
|
2023-08-21 03:21:33 -04:00
|
|
|
|
(org-columns)
|
|
|
|
|
(next-line 1)
|
|
|
|
|
(forward-char 2)
|
|
|
|
|
(org-columns--move-row)
|
|
|
|
|
(current-column)))))
|
2023-04-03 13:23:09 -04:00
|
|
|
|
|
|
|
|
|
(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)))))))
|
|
|
|
|
|
2016-02-23 09:26:57 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-move-left ()
|
|
|
|
|
"Test `org-columns-move-left' specifications."
|
|
|
|
|
;; Error when trying to move the left-most column.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-columns-move-left)))
|
|
|
|
|
;; Otherwise, move column to left and update display.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("2" "1")
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:B: 2\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %B")) (org-columns))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(org-columns-move-left)
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value)))))
|
|
|
|
|
;; Handle multiple columns with the same property.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("2" "1")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A{min} %A{max}"))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(forward-char 2)
|
|
|
|
|
(org-columns-move-left)
|
|
|
|
|
(list (get-char-property (point) 'org-columns-value)
|
|
|
|
|
(get-char-property (1+ (point)) 'org-columns-value)))))
|
|
|
|
|
;; Special case: do not update values even if move entails changing
|
|
|
|
|
;; them.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %A{max}"))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(org-columns-move-left)
|
|
|
|
|
;; Since the first column matching a given property
|
|
|
|
|
;; determines how a value is computed, the following
|
|
|
|
|
;; should return "99" instead. However, this behavior is
|
|
|
|
|
;; in practice surprising so we just ignore the value
|
|
|
|
|
;; change. It can be computed later.
|
|
|
|
|
(org-entry-get (point) "A")))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-colview/columns-move-right ()
|
|
|
|
|
"Test `org-columns-move-right' specifications."
|
|
|
|
|
;; Error when trying to move the right-most column.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-columns-move-right)))
|
|
|
|
|
;; Otherwise, move column to left and update display.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("2" "1")
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:B: 2\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %B")) (org-columns))
|
|
|
|
|
(org-columns-move-right)
|
|
|
|
|
(list (get-char-property (1- (point)) 'org-columns-value)
|
|
|
|
|
(get-char-property (point) 'org-columns-value)))))
|
|
|
|
|
;; Handle multiple columns with the same property.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("2" "1")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 2
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A{min} %A{max}"))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(org-columns-move-right)
|
|
|
|
|
(list (get-char-property (1- (point)) 'org-columns-value)
|
|
|
|
|
(get-char-property (point) 'org-columns-value)))))
|
|
|
|
|
;; Special case: do not update values even if move entails changing
|
|
|
|
|
;; them.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
** S1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 99
|
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A %A{max}"))
|
|
|
|
|
(org-columns))
|
|
|
|
|
(org-columns-move-right)
|
|
|
|
|
;; See `test-org-colview/columns-move-left' for an
|
|
|
|
|
;; explanation.
|
|
|
|
|
(org-entry-get (point) "A")))))
|
|
|
|
|
|
2016-02-23 12:38:48 -05:00
|
|
|
|
(ert-deftest test-org-colview/columns-next-allowed-value ()
|
|
|
|
|
"Test `org-columns-next-allowed-value' specifications."
|
|
|
|
|
;; Cannot shift "ITEM" property.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)))
|
|
|
|
|
;; Throw an error when allowed values are not defined.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)))
|
|
|
|
|
;; Throw an error when there's only one value to select.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:A_ALL: 1\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)))
|
|
|
|
|
;; By default select the next allowed value. Where there is no more
|
|
|
|
|
;; value, start again from first possible one.
|
|
|
|
|
(should
|
|
|
|
|
(equal "2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "3"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 3\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
;; PREVIOUS argument moves backward.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value 'previous)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 3\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value 'previous)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "3"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value 'previous)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
;; Select Nth element with optional argument NTH.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value nil 1)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
;; If NTH is negative, go backwards, 0 being the last one and -1 the
|
|
|
|
|
;; penultimate.
|
|
|
|
|
(should
|
|
|
|
|
(equal "3"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value nil 0)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "2"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value nil -1)
|
|
|
|
|
(org-entry-get (point) "A"))))
|
|
|
|
|
;; Throw an error if NTH is greater than the number of allowed
|
|
|
|
|
;; values.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 2\n:A_ALL: 1 2 3\n:END:"
|
|
|
|
|
(let ((org-columns-default-format "%A")) (org-columns))
|
|
|
|
|
(org-columns-next-allowed-value nil 4)
|
|
|
|
|
(org-entry-get (point) "A")))
|
|
|
|
|
;; Pathological case: when shifting the value alters the current
|
|
|
|
|
;; heading, make sure all columns are still at their correct
|
|
|
|
|
;; location.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("H" "" "" "" "TODO")
|
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A %B %C %TODO"))
|
|
|
|
|
(org-columns)
|
|
|
|
|
(forward-char 4)
|
|
|
|
|
(org-columns-next-allowed-value)
|
|
|
|
|
(list (get-char-property (- (point) 4) 'org-columns-value)
|
|
|
|
|
(get-char-property (- (point) 3) 'org-columns-value)
|
|
|
|
|
(get-char-property (- (point) 2) 'org-columns-value)
|
|
|
|
|
(get-char-property (- (point) 1) 'org-columns-value)
|
|
|
|
|
(get-char-property (point) 'org-columns-value)))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("H" "VERYLONGTODO")
|
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "VERYLONGTODO"))))
|
|
|
|
|
(org-test-with-temp-text "* TODO H"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %TODO"))
|
|
|
|
|
(org-columns)
|
|
|
|
|
(forward-char)
|
|
|
|
|
(org-columns-next-allowed-value)
|
|
|
|
|
(list (get-char-property (- (point) 1) 'org-columns-value)
|
|
|
|
|
(get-char-property (point) 'org-columns-value))))))))
|
|
|
|
|
|
2016-02-14 17:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Dynamic block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-colview/dblock ()
|
|
|
|
|
"Test the column view table."
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| ITEM | A |
|
|
|
|
|
|------+---|
|
|
|
|
|
| H | 1 |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:END:\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
2024-04-05 07:03:31 -04:00
|
|
|
|
;; Test column widths.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| <5> |
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%5ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
;; Properties are case insensitive.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| a |
|
|
|
|
|
|---|
|
|
|
|
|
| 1 |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:END:\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%a")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
;; Test titles given to columns.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| Name | Prop |
|
|
|
|
|
|------+------|
|
|
|
|
|
| H | 1 |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:END:\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM(Name) %A(Prop)"))
|
|
|
|
|
(org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
;; Test `:id' parameter
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :id local
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H1 |
|
|
|
|
|
| H1.1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n<point>#+BEGIN: columnview :id local\n#+END:\n** H1.1\n* H2"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :id global
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H1 |
|
|
|
|
|
| H1.1 |
|
|
|
|
|
| H2 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"\n* H1\n<point>#+BEGIN: columnview :id global\n#+END:\n** H1.1\n* H2"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
;; Test `:hlines' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :hlines t :id global
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H |
|
|
|
|
|
|------|
|
|
|
|
|
| H2 |
|
|
|
|
|
|------|
|
|
|
|
|
| H2.1 |
|
|
|
|
|
#+END:\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H
|
|
|
|
|
<point>#+BEGIN: columnview :hlines t :id global
|
|
|
|
|
#+END:
|
|
|
|
|
* H2
|
|
|
|
|
** H2.1"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :hlines 1 :id global
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H |
|
|
|
|
|
|------|
|
|
|
|
|
| H2 |
|
|
|
|
|
| H2.1 |
|
|
|
|
|
#+END:\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H
|
|
|
|
|
<point>#+BEGIN: columnview :hlines 1 :id global
|
|
|
|
|
#+END:
|
|
|
|
|
* H2
|
2016-02-27 03:21:11 -05:00
|
|
|
|
** H2.1"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :hlines 1 :id \"id\"
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H2 |
|
|
|
|
|
| H2.1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H
|
|
|
|
|
<point>#+BEGIN: columnview :hlines 1 :id \"id\"
|
|
|
|
|
#+END:
|
|
|
|
|
* H2
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:ID: id
|
|
|
|
|
:END:
|
|
|
|
|
** H2.1"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :hlines 1 :id id
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H2 |
|
|
|
|
|
| H2.1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H
|
|
|
|
|
<point>#+BEGIN: columnview :hlines 1 :id id
|
|
|
|
|
#+END:
|
|
|
|
|
* H2
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:ID: id
|
|
|
|
|
:END:
|
2016-02-14 17:18:48 -05:00
|
|
|
|
** H2.1"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
;; Test `:indent' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :indent t
|
|
|
|
|
| ITEM |
|
|
|
|
|
|----------|
|
|
|
|
|
| H1 |
|
|
|
|
|
| \\_ H1.1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n<point>#+BEGIN: columnview :indent t\n#+END:\n** H1.1"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :indent t
|
|
|
|
|
| Prop | Name |
|
|
|
|
|
|------+----------|
|
|
|
|
|
| | H1 |
|
|
|
|
|
| | \\_ H1.1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n<point>#+BEGIN: columnview :indent t\n#+END:\n** H1.1"
|
|
|
|
|
(let ((org-columns-default-format "%A(Prop) %ITEM(Name)"))
|
|
|
|
|
(org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
;; Test `:vlines' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :vlines t
|
|
|
|
|
| | ITEM | A |
|
|
|
|
|
|---+------+----|
|
|
|
|
|
| | H | 1 |
|
|
|
|
|
| / | <> | <> |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:A: 1\n:END:\n<point>#+BEGIN: columnview :vlines t\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
;; Test `:skip-empty-rows' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :skip-empty-rows t
|
|
|
|
|
| ITEM | A |
|
|
|
|
|
|------+---|
|
|
|
|
|
| H1.1 | 1 |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H1
|
|
|
|
|
<point>#+BEGIN: columnview :skip-empty-rows t
|
|
|
|
|
#+END:
|
|
|
|
|
** H1.1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
2018-07-04 08:27:24 -04:00
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
;; Test `:exclude-tags' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :exclude-tags (\"excludeme\")
|
|
|
|
|
| ITEM | A |
|
|
|
|
|
|------+---|
|
|
|
|
|
| H1 | |
|
|
|
|
|
#+END:
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
* H1
|
|
|
|
|
<point>#+BEGIN: columnview :exclude-tags (\"excludeme\")
|
|
|
|
|
#+END:
|
|
|
|
|
** H1.1 :excludeme:
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
2016-02-14 17:18:48 -05:00
|
|
|
|
:END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (outline-next-heading)))))
|
|
|
|
|
;; Test `:format' parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview :format \"%ITEM(Name)\"
|
|
|
|
|
| Name |
|
|
|
|
|
|------|
|
|
|
|
|
| H |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n<point>#+BEGIN: columnview :format \"%ITEM(Name)\"\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
;; When inserting ITEM values, make sure to clean sensitive
|
|
|
|
|
;; contents, like unique targets or forbidden inline src-blocks.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H 1 |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H <<target>> 1\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| ITEM |
|
|
|
|
|
|------|
|
|
|
|
|
| H 1 |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H src_emacs-lisp{(+ 1 1)} 1\n<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
2020-05-11 21:55:58 -04:00
|
|
|
|
(buffer-substring-no-properties (point) (point-max)))))
|
|
|
|
|
;; Active time stamps are displayed as inactive.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN: columnview
|
|
|
|
|
| ITEM | d | s | t |
|
|
|
|
|
|------+------------------+------------------+------------------|
|
|
|
|
|
| H | [2020-05-14 Thu] | [2020-05-11 Mon] | [2020-06-10 Wed] |
|
|
|
|
|
#+END:"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H
|
|
|
|
|
SCHEDULED: <2020-05-11 Mon> DEADLINE: <2020-05-14 Thu>
|
|
|
|
|
<2020-06-10 Wed>
|
|
|
|
|
<point>#+BEGIN: columnview\n#+END:"
|
|
|
|
|
(let ((org-columns-default-format
|
|
|
|
|
"%ITEM %DEADLINE(d) %SCHEDULED(s) %TIMESTAMP(t)"))
|
|
|
|
|
(org-update-dblock))
|
|
|
|
|
(buffer-substring-no-properties (point) (point-max))))))
|
2016-02-14 17:18:48 -05:00
|
|
|
|
|
|
|
|
|
(provide 'test-org-colview)
|
|
|
|
|
;;; test-org-colview.el ends here
|