Skip to content

Commit

Permalink
compliance with current function naming guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
tbanel committed Jan 21, 2023
1 parent c21b240 commit 0620da5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ Then answer =aggregate= for the type of block, and follow the instructions.
~columnview~, ~clocktable~, ~propview~, ~invoice~, ~transpose~, and any
future block).

=C-c C-x x aggregate= is equivalent to =M-x org-dblock-write:aggregate=.
=C-c C-x x aggregate= is equivalent to
=M-x orgtbl-aggregate-insert-dblock-aggregate=.

* Other examples

Expand Down Expand Up @@ -1574,11 +1575,10 @@ Then browse the list of available packages and install =orgtbl-aggregate=
M-x package-list-packages
#+END_EXAMPLE

Alternatively, you can download the lisp files, and load them:
Alternatively, you can download the lisp file, and load it:

#+BEGIN_EXAMPLE
(load-file "orgtbl-aggregate.el")
(load-file "org-insert-dblock.el") ;; optional, extends C-c C-c i
#+END_EXAMPLE

* Authors, contributors
Expand Down
57 changes: 37 additions & 20 deletions orgtbl-aggregate.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
;; #+END
;;
;; A wizard can be used:
;; M-x org-insert-dblock:aggregate
;; M-x orgtbl-aggregate-insert-dblock-aggregate
;;
;; Full documentation here:
;; https://github.com/tbanel/orgaggregate/blob/master/README.org
Expand Down Expand Up @@ -659,12 +659,12 @@ The list contains sorting specifications as follows:
nil
(string-to-number (match-string 2 sorting)))))
(pcase (match-string 1 sorting)
("a" (record 'sorting strength colnum nil #'identity 'string-lessp))
("A" (record 'sorting strength colnum t #'identity 'string-lessp))
("n" (record 'sorting strength colnum nil #'string-to-number '<))
("N" (record 'sorting strength colnum t #'string-to-number '<))
("t" (record 'sorting strength colnum nil #'orgtbl-aggregate--string-to-time '<))
("T" (record 'sorting strength colnum t #'orgtbl-aggregate--string-to-time '<))
("a" (record 'orgtbl-aggregate--sorting strength colnum nil #'identity #'string-lessp))
("A" (record 'orgtbl-aggregate--sorting strength colnum t #'identity #'string-lessp))
("n" (record 'orgtbl-aggregate--sorting strength colnum nil #'string-to-number #'<))
("N" (record 'orgtbl-aggregate--sorting strength colnum t #'string-to-number #'<))
("t" (record 'orgtbl-aggregate--sorting strength colnum nil #'orgtbl-aggregate--string-to-time #'<))
("T" (record 'orgtbl-aggregate--sorting strength colnum t #'orgtbl-aggregate--string-to-time #'<))
((or "f" "F") (user-error "f/F sorting specification not (yet) implemented"))
(_ (user-error "Bad sorting specification ^%s" sorting)))))))

Expand Down Expand Up @@ -1197,14 +1197,14 @@ should be converted to NAN or ignored.
;; aggregation in Push mode

;;;###autoload
(defun orgtbl-aggregate-table (table params)
"Convert the Org Mode TABLE to another Org Mode table.
(defun orgtbl-to-aggregated-table (table params)
"Convert the Org Mode TABLE to an aggregated version.
The resulting table contains aggregated material.
Grouping of rows is done for identical values of grouping columns.
For each group, aggregation (sum, mean, etc.) is done for other columns.
The source table must contain sending directives with the following format:
#+ORGTBL: SEND destination orgtbl-aggregate-table :cols ... :cond ...
#+ORGTBL: SEND destination orgtbl-to-aggregated-table :cols ... :cond ...
The destination must be specified somewhere in the same file
with a block like this:
Expand Down Expand Up @@ -1268,15 +1268,19 @@ and is incremented by one for each horizontal line.
Example:
add a line like this one before your table
,#+ORGTBL: SEND aggregatedtable orgtbl-aggregate-table :cols \"sum(X) q sum(Y) mean(Z) sum(X*X)\"
,#+ORGTBL: SEND aggregatedtable orgtbl-to-aggregated-table :cols \"sum(X) q sum(Y) mean(Z) sum(X*X)\"
then add somewhere in the same file the following lines:
,#+BEGIN RECEIVE ORGTBL aggregatedtable
,#+END RECEIVE ORGTBL aggregatedtable
Type \\<org-mode-map> & \\[org-ctrl-c-ctrl-c] into your source table
Note:
This is the 'push' mode for aggregating a table.
To use the 'pull' mode, look at the org-dblock-write:aggregate function."
To use the 'pull' mode, look at the org-dblock-write:aggregate function.
Note:
The name `orgtbl-to-aggregated-table' follows the Org Mode standard
with functions like `orgtbl-to-csv', `orgtbl-to-html'..."
(interactive)
(let ((aggregated-table
(orgtbl-aggregate--post-process
Expand Down Expand Up @@ -1362,7 +1366,12 @@ Example:
Note:
This is the 'pull' mode for aggregating a table.
To use the 'push' mode, look at the orgtbl-aggregate-table function."
To use the 'push' mode,
look at the `orgtbl-to-aggregated-table' function.
Note:
The name `org-dblock-write:aggregate' is constrained
by the `org-update-dblock' function."
(interactive)
(let ((formula (plist-get params :formula))
(content (plist-get params :content))
Expand Down Expand Up @@ -1411,7 +1420,7 @@ Note:
(defvar orgtbl-aggregate-history-cols ())

;;;###autoload
(defun org-insert-dblock:aggregate ()
(defun orgtbl-aggregate-insert-dblock-aggregate ()
"Wizard to interactively insert an aggregate dynamic block."
(interactive)
(let* ((table
Expand Down Expand Up @@ -1546,7 +1555,11 @@ table to re-create the transposed version.
Note:
This is the 'push' mode for transposing a table.
To use the 'pull' mode, look at the org-dblock-write:transpose function."
To use the 'pull' mode, look at the org-dblock-write:transpose function.
Note:
The name `orgtbl-to-transposed-table' follows the Org Mode standard
with functions like `orgtbl-to-csv', `orgtbl-to-html'..."
(interactive)
(let ((transposed-table
(orgtbl-aggregate--post-process
Expand Down Expand Up @@ -1606,7 +1619,11 @@ and the other way around.
Note:
This is the 'pull' mode for transposing a table.
To use the 'push' mode, look at the orgtbl-to-transposed-table function."
To use the 'push' mode, look at the orgtbl-to-transposed-table function.
Note:
The name `org-dblock-write:transpose' is constrained
by the `org-update-dblock' function."
(interactive)
(let ((formula (plist-get params :formula))
(content (plist-get params :content))
Expand Down Expand Up @@ -1649,7 +1666,7 @@ Note:
(args-out-of-range nil))))))

;;;###autoload
(defun org-insert-dblock:transpose ()
(defun orgtbl-aggregate-insert-dblock-transpose ()
"Wizard to interactively insert a transpose dynamic block."
(interactive)
(let* ((table
Expand Down Expand Up @@ -1689,9 +1706,9 @@ Note:
;; Insert a dynamic bloc with the C-c C-x x dispatcher
;;;###autoload
(eval-after-load 'org
'(when (fboundp 'org-dynamic-block-define)
(org-dynamic-block-define "aggregate" #'org-insert-dblock:aggregate)
(org-dynamic-block-define "transpose" #'org-insert-dblock:transpose)))
'(when (fboundp #'org-dynamic-block-define) ;; found in Emacs 27.1
(org-dynamic-block-define "aggregate" #'orgtbl-aggregate-insert-dblock-aggregate)
(org-dynamic-block-define "transpose" #'orgtbl-aggregate-insert-dblock-transpose)))

(provide 'orgtbl-aggregate)
;;; orgtbl-aggregate.el ends here

0 comments on commit 0620da5

Please sign in to comment.