Laurent Gatto reshared this.
I've run into a snag.
I have a function, pivot-table-get-columns (shorthanded as pt-get-columns). Its job is to take an #OrgMode table and produce an alist of mappings of column names to column numbers. The column names are as defined by section 3.5.10 of the org-mode manual.
My code is here.
When I pass this function a table without column labels, it crashes on the format line (which it shouldn't even be reaching).
Can someone explain to me what I'm doing wrong?
(cc: @screwlisp )
Edit: I've been beating my head against a wall for some time on this getting nowhere and less than a minute after asking this, I see it. My first unless should be a when. I'll fix it later.
reshared this
vintage screwlisp account reshared this.
actually, I'm unaware of
(setq result (((format "%s" cell) . n) . result))
being a permissable form. It looks like
(setq result `((,(format "%s" cell) . ,n) . ,result))
to me but I might be wrong. Does it fix the problem or did you have another insight?
@screwtape
> in common lisp compilers are allowed to coalesce
[constants]Right, for details see what the _file_ compiler in particular may do.
I did some testing and found that if I pass a named table into a source block as a variable, it automatically gets converted into s-expression form.
See below:
#+NAME: my-table
| | a | b |
|---+---+---|
| 1 | 2 | 3 |
#+begin_src emacs-lisp :var table=my-table :colnames no :hlines yes
(format "%S" table)
#+end_src
#+RESULTS:
: (("" "a" "b") hline (1 2 3))
@screwlisp I've not seen the comma prefix used outside a macro before. Also, this would probably be better written as:(push (cons (format "%s" cell) n) result)
It would certainly be more legible.
@screwlisp Huzzah! That along with your point on eq vs. equal did the trick!
Now I've just got to, you know, write and document all the rest of it.
If this works out, I'm really excited about publishing it. I was surprised that it didn't already seem to exist.
it is very exciting!
commas have to appear inside backticks, and backticks are just quotes that can have certain things inside of them unquoted (using a comma).
Macros to a large extent work like this because one principle of lisp is that lisp code be regular lisp sequences. At read time, the function names are just symbols. So it's a list of symbols/atoms and lists.
However, sometimes we /do/ want to run some code, hence backtick and comma/unquote.
vintage screwlisp account reshared this.
> the comma prefix used outside a macro
Backquote forms are merely list (S-expression) constructors where some pieces are constant and some pieces are evaluated.
(The latter are marked with commas.)
Such forms can be used anywhere.
Obviously they are often used in macros, because macro functions construct lists (S-expressions).
I often write
`(,foo ,bar)
instead of
(list foo bar)
because the former seems clearer, especially when the structure is more involved.
@screwtape
> `((,(format "%s" cell) . ,n) . ,result))
In Common Lisp you would write
`(... ,@result))
but right now I am only fairly sure that Elisp has comma splicing.
GitHub - tbanel/orgaggregate: Aggregate tables in Org mode
Aggregate tables in Org mode. Contribute to tbanel/orgaggregate development by creating an account on GitHub.GitHub
Jonathan Lamothe likes this.
you might also be interested in mastodon.online/@hajovonta/114β¦
#cfw got an org-table import/export functionality. Just select the org-table and run M-x cfw-org-load. Analyse, sort, edit, filter your table in CFW. Then update the original org-table by M-x cfw-org-save.If there was no original org-table (the table was created from scratch or from other source like CSV), the cfw-org-save places the exported table into the kill-ring. This way org pivottables can be generated from CFW.
like this
Jonathan Lamothe and Yuriy Shirokov like this.
I WANT TO SHOW YOU MY TOYS!
I just did my 2024 taxes in org-mode spreadsheets!
Yeah, I'd love to show you! I keep meaning to write a blog post.
In summary, table references are updated when that table's cells are reordered.
If another table refers to a cell in this table, that reference is not updated when the cell moves.
You can name a field! I was able to decipher this confusing illustration after an hour of staring: orgmode.org/org.html#Advanced-β¦
I'd already decided to do each tax form as its own spreadsheet: gist.github.com/shapr/84e37fdfβ¦
Does the gist help?
A snippet of my taxes done in org-mode spreadsheets
A snippet of my taxes done in org-mode spreadsheets - taxes.orgGist
Ahem, sorry about that excitement explosion.
Yes, you can call elisp functions, um, lemme find the reference
Oh, as a vector? π€
Gosh I don't know about that.
orgmode.org/worg/org-tutorialsβ¦
That shows you how to define a column formula with elisp. I think think usual "vsum" and friends are vector operations from the emacs calculator, so it seems very likely?
I gotta go to the bike shop, but my heuristic would be:
1. I know vsum works in org-mode spreadsheet formulas
2. I know the v stands for "vector"
3. Can I use that function's source to define my own vector operations?
I like to think the answer is YES. I am hopeful at least.
vsum to see how it works. Internally it's calcFunc-vsum right?
vsum as mentioned earlier to see if there's a solution there.
I don't understand pivot tables, so I can't help.
What would this look like?
#+NAME: source
| Bill | Account | Amount |
|------+----------+--------|
| foo | chequing | 13.50 |
| bar | savings | 22.75 |
| baz | chequing | 9.50 |
| quux | savings | 11.15 |
#+NAME: pivot
| Account | Total |
|----------+-------|
| chequing | 23.00 |
| savings | 33.90 |
#+TBLFM: @2$2=remote(source,@2$3)+remote(source,@4$3);%1.2f::@3$2=remote(source,@3$3)+remote(source,@5$3);%1.2f
Hi @me
If you insert a formula in a table cell #orgmode will put it after the table in a special line (so you can see and edit it after) and insert the result in place. Of course, it can be recalculated anytime you want to.
But for a picot table, maybe you can also use org-aggregate? > github.com/tbanel/orgaggregate
GitHub - tbanel/orgaggregate: Aggregate tables in Org mode
Aggregate tables in Org mode. Contribute to tbanel/orgaggregate development by creating an account on GitHub.GitHub
@hajovonta This turns out to be relatively simple. See org-table-to-lisp.
Edit: function name correction
I like using org tables with org-babel like so:
#+NAME: test
| 1 | 4 |
| 2 | 5 |
| 3 | 6 |
#+begin src emacs-lisp :var test=test
(mapcar
'(lambda (r)
(mapcar '(lambda (x) (* x x)) r)) test)
#+RESULTS:
| 1 | 16 |
| 4 | 25 |
| 9 | 36 |
Is there a way to tell #Emacs #org-mode to omit yhe TOC and headline numbers when exporting to a text or markdown file? I'm trying to implement a #JohnnyDecimal system, so I'm supplying my own numbers and the 00.00-index.org file essentially is the table of contents.
Edit: Because not all replies federate, here's the solution I ended up with:
#+STARTUP: overview indent nonum
#+OPTIONS: toc:nillike this
randygalbraith likes this.
Jonathan Lamothe likes this.
This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.

Martin Stemplinger
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Martin Stemplinger • •Henry
in reply to Jonathan Lamothe • • •Agenda view of the current buffer
Stack Overflowlann
in reply to Jonathan Lamothe • • •emacs > org mode > agenda - always use current buffer
Stack Overflowa world without cars
in reply to Jonathan Lamothe • • •Per the help doc for org-agenda
"If the current buffer is in Org mode and visiting a file, you can also
first press β<β once to indicate that the agenda should be temporarily
(until the next use of βSPC o aβ) restricted to the current file.
Pressing β<β twice means to restrict to the current subtree or region
(if active).
"
In other words, execute org-agenda then press "<" before the command you want to run against the agenda.
a world without cars
in reply to a world without cars • • •Jonathan Lamothe
in reply to a world without cars • •@a world without cars I have a markdown plugin on my Friendica server. I just put it between backticks like this:
`org-agenda-files`.This wouldn't work on Mastodon though.
a world without cars
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to a world without cars • •lou.
in reply to Jonathan Lamothe • • •you could do something like this
```
(defun my/file-agenda ()
(interactive)
(when-let ((org-agenda-files (list (buffer-file-name (current-buffer)))))
(org-agenda)))
```