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.
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.
what does org table source look like by the way? I normally pass org tables into org source blocks (where they become s-expressions in lisp), but I'm not sure what the tables look like internally to org.
further about eq in common lisp at least, I've seen people make a mistake before- when you compile code, if you referred to "" twice, in common lisp compilers are allowed to coalesce them at which point they /will/ be eq. (Eq would be a good test to see if they /had/ been coalesced). But in the general case two strings entered in different places are not eq.
@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 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.
Jonathan Lamothe
in reply to Jonathan Lamothe • •I've run into a snag.
I have a function,
pivot-table-get-columns
(shorthanded aspt-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 )
#emacs #elisp
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 awhen
. I'll fix it later.reshared this
screwlisp and Chip Butty reshared this.
screwlisp
in reply to Jonathan Lamothe • • •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?
screwlisp
in reply to screwlisp • • •screwlisp
in reply to screwlisp • • •screwlisp
in reply to screwlisp • • •screwlisp
in reply to screwlisp • • •Jonathan Lamothe
in reply to screwlisp • •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:
Jonathan Lamothe
in reply to screwlisp • •@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.
Jonathan Lamothe
in reply to Jonathan Lamothe • •@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.
screwlisp
in reply to Jonathan Lamothe • • •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.
screwlisp reshared this.
Christian Tietze
in reply to Jonathan Lamothe • • •Jonathan Lamothe likes this.
hajovonta
in reply to Jonathan Lamothe • • •Jonathan Lamothe likes this.
screwlisp
in reply to hajovonta • • •Sensitive content
trivial-pivot-tables
Sacha Chua
in reply to Jonathan Lamothe • • •GitHub - tbanel/orgaggregate: Aggregate tables in Org mode
GitHubZeStig
in reply to Sacha Chua • • •Jonathan Lamothe
in reply to Sacha Chua • •Sacha Chua
in reply to Jonathan Lamothe • • •Jonathan Lamothe likes this.