Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
Carsten Dominik carsten.domi...@gmail.com writes: I think a better strategy would be to find these additional header lines right before this section of the recalculate function: ;; Now evaluate the column formulas, but skip fields covered by ;; field formulas and mark those extra header lines with the org-untouchable text property. Then you can let the column formulas do their game, and fields marked by this property will automatically exempted.. I just did that (and fixing a bug with the :org-untouchable property not being removed in certain circumstances which you might want to commit to master upfront). It looks much cleaner, see if you like it, too. I've also cleaned up all the commit messages, I hope they conform to the standard now. Another part which might need a look to support this would be `orgtbl-to-generic'. That I will have to think over a bit. This support depends on parsing the table into a list (AFAIK) and that currently treats cross headings as another sort of hlines. Changing this has a lot of repercussions elsewhere in the code as far as I can see. It might be an opportunity to re-factor some of the code that still works on the text representation, but that is certainly not something that I'd take lightly. Regards, Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ Samples for the Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
On 31.5.2011, at 20:01, Achim Gratz wrote: Hi Carsten, Carsten Dominik carsten.domi...@gmail.com writes: I think a better strategy would be to find these additional header lines right before this section of the recalculate function: [...] I'll have a look (probably not today), but I'd rather tag them with an org-header property and arrange it so that this can be used in other places as well. This property is not attached to these lines for long - it is just a temporary way of marking fields that should not be overwritten by column formulas. The property is added, and also removed again (I think) during the recalculation process. Another part which might need a look to support this would be `orgtbl-to-generic'. Noted. Finally: this patch goes clearly beyond the TINYCHANGE limits. What is yours, and Lawrence's copyright status with the FSF? My status with the FSF is succinctly and fully characterized as non-existing. I've sent that mail form to the FSF and I'll see what happens next — it seems I'll get snail mail in a few weeks? Thank you. Please let us know when the process gets stuck or completes. - Carsten
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
Hi Achim, On 30.5.2011, at 23:02, Achim Gratz wrote: Hi Carsten, Carsten Dominik carsten.domi...@gmail.com writes: this looks pretty good. One thing I found missing is that header lines should be exempted from column formulas being applied. This works for the headlines at the top of the table, but not in the middle. thank you for having a look. You are right, but this looks like something that goes a bit deeper than my current understanding, I'm afraid. Header lines don't appear to be marked in any way, but simply skipped over before starting the formula calculation. Consequently, the column formula is evaluated for any header line when doing a C-c * directly in the header, which might be considered a bug. I won't touched this aspect of the code since it will probably have farther reaching consequences if changed. I quickly hacked in some extra stuff that looks for cross headers and skips them while the full table is updated — but I'm not sure this is the right thing to do and the way the program logic works requires me to check certain pathological cases twice, which is a bit ugly. I've just rebased against current master and pushed everything back to the repo. I think a better strategy would be to find these additional header lines right before this section of the recalculate function: ;; Now evaluate the column formulas, but skip fields covered by ;; field formulas and mark those extra header lines with the org-untouchable text property. Then you can let the column formulas do their game, and fields marked by this property will automatically exempted.. Also documentation in the manual is missing - one or two sentences in the right place should be enough. Sure, but I'd like to get it working correctly first. :-) Fair enough. I'm using this code at work and things have gone smoothly, but I only use the HTML backend and certainly don't exercise the full breadth of the table functionality (obviously no column formulas were used by me, for instance). Another part which might need a look to support this would be `orgtbl-to-generic'. While testing I stumbled upon this: if a buffer has no undo information associated, org-self-insert-command produces an error while trying to edit the formula. This code path may need to be protected against this (admittedly rare) case, I've been triggering it while testing your example directly in the gnus article buffer. This issue is fixed, thanks for the report. Finally: this patch goes clearly beyond the TINYCHANGE limits. What is yours, and Lawrence's copyright status with the FSF? - Carsten Debugger entered--Lisp error: (wrong-type-argument listp t) cadr(t) (not (cadr buffer-undo-list)) (and ( org-self-insert-command-undo-counter 0) buffer-undo-list (not (cadr buffer-undo-list)) (setcdr buffer-undo-list (cddr buffer-undo-list))) (if (= org-self-insert-command-undo-counter 20) (setq org-self-insert-command-undo-counter 1) (and ( org-self-insert-command-undo-counter 0) buffer-undo-list (not ...) (setcdr buffer-undo-list ...)) (setq org-self-insert-command-undo-counter (1+ org-self-insert-command-undo-counter))) (if (not (eq last-command ...)) (setq org-self-insert-command-undo-counter 1) (if (= org-self-insert-command-undo-counter 20) (setq org-self-insert-command-undo-counter 1) (and ... buffer-undo-list ... ...) (setq org-self-insert-command-undo-counter ...))) (if org-self-insert-cluster-for-undo (if (not ...) (setq org-self-insert-command-undo-counter 1) (if ... ... ... ...))) (cond ((and org-use-speed-commands ...) (cond ... ... ... ...)) ((and ... ... ... ...) (let ... ... ... ... ...)) (t (setq org-table-may-need-update t) (self-insert-command N) (org-fix-tags-on-the-fly) (if org-self-insert-cluster-for-undo ...))) org-self-insert-command(1) Regards Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ Factory and User Sound Singles for Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
On 31/05/2011 08:21, Carsten Dominik wrote: [...] Finally: this patch goes clearly beyond the TINYCHANGE limits. What is yours, and Lawrence's copyright status with the FSF? I have papers with the FSF for past and future changes to Emacs, so I believe my contributions are covered. Lawrence
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
Hi Carsten, Carsten Dominik carsten.domi...@gmail.com writes: I think a better strategy would be to find these additional header lines right before this section of the recalculate function: [...] I'll have a look (probably not today), but I'd rather tag them with an org-header property and arrange it so that this can be used in other places as well. Another part which might need a look to support this would be `orgtbl-to-generic'. Noted. Finally: this patch goes clearly beyond the TINYCHANGE limits. What is yours, and Lawrence's copyright status with the FSF? My status with the FSF is succinctly and fully characterized as non-existing. I've sent that mail form to the FSF and I'll see what happens next — it seems I'll get snail mail in a few weeks? Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ SD adaptations for KORG EX-800 and Poly-800MkII V0.9: http://Synth.Stromeko.net/Downloads.html#KorgSDada
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
My status with the FSF is succinctly and fully characterized as non-existing. I've sent that mail form to the FSF and I'll see what happens next ― it seems I'll get snail mail in a few weeks? In my case the process took close to 4 months. Jambunathan K. --
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
Hi Carsten, Carsten Dominik carsten.domi...@gmail.com writes: this looks pretty good. One thing I found missing is that header lines should be exempted from column formulas being applied. This works for the headlines at the top of the table, but not in the middle. thank you for having a look. You are right, but this looks like something that goes a bit deeper than my current understanding, I'm afraid. Header lines don't appear to be marked in any way, but simply skipped over before starting the formula calculation. Consequently, the column formula is evaluated for any header line when doing a C-c * directly in the header, which might be considered a bug. I won't touched this aspect of the code since it will probably have farther reaching consequences if changed. I quickly hacked in some extra stuff that looks for cross headers and skips them while the full table is updated — but I'm not sure this is the right thing to do and the way the program logic works requires me to check certain pathological cases twice, which is a bit ugly. I've just rebased against current master and pushed everything back to the repo. Also documentation in the manual is missing - one or two sentences in the right place should be enough. Sure, but I'd like to get it working correctly first. :-) I'm using this code at work and things have gone smoothly, but I only use the HTML backend and certainly don't exercise the full breadth of the table functionality (obviously no column formulas were used by me, for instance). While testing I stumbled upon this: if a buffer has no undo information associated, org-self-insert-command produces an error while trying to edit the formula. This code path may need to be protected against this (admittedly rare) case, I've been triggering it while testing your example directly in the gnus article buffer. Debugger entered--Lisp error: (wrong-type-argument listp t) cadr(t) (not (cadr buffer-undo-list)) (and ( org-self-insert-command-undo-counter 0) buffer-undo-list (not (cadr buffer-undo-list)) (setcdr buffer-undo-list (cddr buffer-undo-list))) (if (= org-self-insert-command-undo-counter 20) (setq org-self-insert-command-undo-counter 1) (and ( org-self-insert-command-undo-counter 0) buffer-undo-list (not ...) (setcdr buffer-undo-list ...)) (setq org-self-insert-command-undo-counter (1+ org-self-insert-command-undo-counter))) (if (not (eq last-command ...)) (setq org-self-insert-command-undo-counter 1) (if (= org-self-insert-command-undo-counter 20) (setq org-self-insert-command-undo-counter 1) (and ... buffer-undo-list ... ...) (setq org-self-insert-command-undo-counter ...))) (if org-self-insert-cluster-for-undo (if (not ...) (setq org-self-insert-command-undo-counter 1) (if ... ... ... ...))) (cond ((and org-use-speed-commands ...) (cond ... ... ... ...)) ((and ... ... ... ...) (let ... ... ... ... ...)) (t (setq org-table-may-need-update t) (self-insert-command N) (org-fix-tags-on-the-fly) (if org-self-insert-cluster-for-undo ...))) org-self-insert-command(1) Regards Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ Factory and User Sound Singles for Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
Re: [O] [Orgmode] Re: [Feature Request] Cross headings in tables
On 8.2.2011, at 22:52, Achim Gratz wrote: If anybody wants to test the current state of affairs, I've just set up a fork repository to make it easier. Assuming you already have orgmode.git cloned, do a git remote add -t tableheadings remote-tableheadings git://repo.or.cz/org-mode/org-tableheadings.git git fetch remote-tableheadings tableheadings:local-tableheadings git checkout local-tableheadings to get it (change remote-tableheadings and local-tableheadings to suit your naming conventions for remotes and local branches, respectively). I will be _rebasing_ against master during development, so expect history in this branch to be volatile. As before, test cases and comments welcome. Hi Achim, hi Lawrence, this looks pretty good. One thing I found missing is that header lines should be exempted from column formulas being applied. This works for the headlines at the top of the table, but not in the middle. Try C-c C-c in the TBLFM line of: | aaa | bbb | ccc | ddd | |-+-+-+-| | ddd | eee | fff | 41 | | ddd | eee | fff | 41 | | ddd | eee | fff | 41 | |~+~+~+~| | ddd | | fff | ddd | |-+-+-+-| | ddd | eee | fff | 41 | | ddd | eee | fff | 41 | | xxx | yyy | zzz | 41 | #+TBLFM: $4=41 Also documentation in the manual is missing - one or two sentences in the right place should be enough. - Carsten
[Orgmode] Re: [Feature Request] Cross headings in tables
If anybody wants to test the current state of affairs, I've just set up a fork repository to make it easier. Assuming you already have orgmode.git cloned, do a git remote add -t tableheadings remote-tableheadings git://repo.or.cz/org-mode/org-tableheadings.git git fetch remote-tableheadings tableheadings:local-tableheadings git checkout local-tableheadings to get it (change remote-tableheadings and local-tableheadings to suit your naming conventions for remotes and local branches, respectively). I will be _rebasing_ against master during development, so expect history in this branch to be volatile. As before, test cases and comments welcome. Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ Factory and User Sound Singles for Waldorf Q+, Q and microQ: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [Feature Request] Cross headings in tables
Achim Gratz wrote: [...] The first header is still determined like it always was. Headers inside table need to get a special hline, the choice of ~ for this was dictated by most of the other characters already being used for various markup inside or outside tables. When I say halfway there, I mean that the export is working and the lines are recognized as hlines everywhere I could find (there may still be some regexpressions floating around that don't). However, aligning tables will replace the wigglies with plain dashes since I have not yet found a way to inject the correct character for the currently hardcoded -. The HTML export for the above table looks like this: [...] If somebody has an idea how to make the table alignment work, please lend me a hand. Experimental patch is attached, comments are welcome. How about the following two patches on top. The first fixes table alignment, the second fixes LaTeX export of these tables. From c555b7e15b617538490210a041bd4af45e51d752 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell we...@gmx.li Date: Wed, 2 Feb 2011 12:20:12 + Subject: [PATCH 1/2] Correctly realign tables with internal headers To: emacs-orgmode@gnu.org * lisp/org-table.el (org-table-align): Deal with internal headers (specified by ?~) when realigning. --- lisp/org-table.el | 38 -- 1 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 9437ae1..498a6fc 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -632,7 +632,7 @@ When nil, simply write \#ERROR\ in corrupted fields.) lines (new ) lengths l typenums ty fields maxfields i column (indent ) cnt frac -rfmt hfmt +rfmt hfmt tfmt (spaces '(1 . 1)) (sp1 (car spaces)) (sp2 (cdr spaces)) @@ -640,6 +640,8 @@ When nil, simply write \#ERROR\ in corrupted fields.) (make-string sp2 ?\ ) %%%s%ds (make-string sp1 ?\ ) |)) (hfmt1 (concat (make-string sp2 ?-) %s (make-string sp1 ?-) +)) +(tfmt1 (concat +(make-string sp2 ?~) %s (make-string sp1 ?~) +)) emptystrings links dates emph raise narrow falign falign1 fmax f1 len c e space) (untabify beg end) @@ -680,17 +682,19 @@ When nil, simply write \#ERROR\ in corrupted fields.) ;; Mark the hlines by setting the corresponding element to nil ;; At the same time, we remove trailing space. (setq lines (mapcar (lambda (l) - (if (string-match ^ *|[-~] l) - nil - (if (string-match [ \t]+$ l) - (substring l 0 (match-beginning 0)) - l))) + (cond ((string-match ^ *|[-] l) +'dash) + ((string-match ^ *|[~] l) +'tilde) + ((string-match [ \t]+$ l) +(substring l 0 (match-beginning 0))) + (t l))) lines)) ;; Get the data fields by splitting the lines. (setq fields (mapcar (lambda (l) (org-split-string l *| *)) - (delq nil (copy-sequence lines + (delq 'dash (delq 'tilde (copy-sequence lines) ;; How many fields in the longest line? (condition-case nil (setq maxfields (apply 'max (mapcar 'length fields))) @@ -770,19 +774,25 @@ When nil, simply write \#ERROR\ in corrupted fields.) (concat (car c) space ;; Compute the formats needed for output of the table -(setq rfmt (concat indent |) hfmt (concat indent |)) +(setq rfmt (concat indent |) hfmt (concat indent |) + tfmt (concat indent |)) (while (setq l (pop lengths)) (setq ty (if (pop typenums) -)) ; number types flushright (setq rfmt (concat rfmt (format rfmt1 ty l)) - hfmt (concat hfmt (format hfmt1 (make-string l ?-) + hfmt (concat hfmt (format hfmt1 (make-string l ?-))) + tfmt (concat tfmt (format tfmt1 (make-string l ?~) (setq rfmt (concat rfmt \n) - hfmt (concat (substring hfmt 0 -1) |\n)) - + hfmt (concat (substring hfmt 0 -1) |\n) + tfmt (concat (substring tfmt 0 -1) |\n)) (setq new (mapconcat (lambda (l) -(if l (apply 'format rfmt - (append (pop fields) emptystrings)) - hfmt)) +(cond ((eq l 'dash) + hfmt) + ((eq l 'tilde) + tfmt) + (t + (apply 'format rfmt + (append (pop fields) emptystrings) lines )) (if
[Orgmode] Re: [Feature Request] Cross headings in tables
Lawrence Mitchell we...@gmx.li writes: How about the following two patches on top. The first fixes table alignment, the second fixes LaTeX export of these tables. Thank you for this, brilliant idea of replacing the nil with a symbol... It integrates cleanly with what I have so far, I will need some more testing (just discovered a boundary case that I fixed). Also need to check the other export backends, thank you for taking care of LaTeX. Regards, Achim. -- +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+ Wavetables for the Terratec KOMPLEXER: http://Synth.Stromeko.net/Downloads.html#KomplexerWaves ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [Feature Request] Cross headings in tables
Achim Gratz strom...@nexgo.de writes: [...] So I'd like to have first-class cross headings, maybe like this: |--+---+-| | Header | some more | and more| |--+---+-| | item | stuff | things | | etc. | pp. | ad nauseam | |--+---+-| | Header | to keep | things together | |--+---+-| | | ... | | |--+---+-| So, the first heading would be determined by the first horizontal separator inside the table (for backwards compatibility) and any following heading would need get some special syntax (like the | above, but anything that doesn't collide with existing syntax will just be fine I think). If there's a heading marker before the first horizontal separation, it should probably take precedence over the backwards-compatible markup. That would also enable to have table headings without a separator, something that's not possible today. I've spent some time on this and have developed a patch that gets halfway there. You can have consecutive headers, headers inside the table and even headers at the end of the table: --8---cut here---start-8--- |-+ | unrelated 1 | |~| | Test1 | |-+ | unrelated 2 | | Test2 | | unrelated 3 | |~| | Test3 | |-+ | unrelated 4 | | Test4 | | unrelated 5 | | Test5 | |~| | unrelated 6 | | Test6 | |-+ --8---cut here---end---8--- The first header is still determined like it always was. Headers inside table need to get a special hline, the choice of ~ for this was dictated by most of the other characters already being used for various markup inside or outside tables. When I say halfway there, I mean that the export is working and the lines are recognized as hlines everywhere I could find (there may still be some regexpressions floating around that don't). However, aligning tables will replace the wigglies with plain dashes since I have not yet found a way to inject the correct character for the currently hardcoded -. The HTML export for the above table looks like this: --8---cut here---start-8--- table border=2 cellspacing=0 cellpadding=6 rules=groups frame=hsides caption/caption colgroupcol class=left /col class=left / /colgroup thead trth scope=col class=leftunrelated 1/thth scope=col class=leftgt;=/th/tr /thead thead trth scope=col class=leftTest1/thth scope=col class=left=/th/tr /thead tbody trtd class=leftunrelated 2/tdtd class=leftlt;=/td/tr trtd class=leftTest2/tdtd class=left==/td/tr trtd class=leftunrelated 3/tdtd class=left-=/td/tr /tbody thead trth scope=col class=leftTest3/thth scope=col class=left:=/th/tr /thead tbody trtd class=leftunrelated 4/tdtd class=leftgt;=/td/tr trtd class=leftTest4/tdtd class=left=/td/tr trtd class=leftunrelated 5/tdtd class=leftlt;=/td/tr trtd class=leftTest5/tdtd class=left==/td/tr /tbody thead trth scope=col class=leftunrelated 6/thth scope=col class=left-=/th/tr trth scope=col class=leftTest6/thth scope=col class=left:=/th/tr /thead /table --8---cut here---end---8--- And ASCII: --8---cut here---start-8--- unrelated 1 - Test1 - unrelated 2 Test2 unrelated 3 - Test3 - unrelated 4 Test4 unrelated 5 Test5 - unrelated 6 Test6 --8---cut here---end---8--- If somebody has an idea how to make the table alignment work, please lend me a hand. Experimental patch is attached, comments are welcome. From 0fd4e39641ab17ae1586747396acbe1e9fa48321 Mon Sep 17 00:00:00 2001 From: Achim Gratz strom...@stromeko.de Date: Sun, 16 Jan 2011 19:06:13 +0100 Subject: [PATCH] Allow headings inside tables without splicing them. *EXPERIMENTAL* This patch is an incomplete implementation, most notably, table (re-)alignment does not work. --- lisp/org-html.el | 15 +-- lisp/org-table.el | 30 +++--- lisp/org.el |4 ++-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index 9a5d225..d69d037 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1899,7 +1899,7 @@ for formatting. This is required for the DocBook exporter. html-table-tag attributes)) (head (and org-export-highlight-first-table-line (delq nil (mapcar - (lambda (x) (string-match ^[ \t]*|- x)) + (lambda (x) (string-match ^[ \t]*|[-~] x)) (cdr lines) (nline 0) fnum