emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [Babel] Lisp error: (wrong-type-argument listp hline)


From: Sebastien Vauban
Subject: [O] [Babel] Lisp error: (wrong-type-argument listp hline)
Date: Mon, 23 Sep 2013 16:16:37 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt)

Hello Eric,

This ECM does generate an error, when run with ":hlines yes".

#+name: table
| Key | Value |
|-----+-------|
| ABJ |     1 |
| DEK |     2 |

As you can see, there is one header and one horizontal line in the input
table.

* Set :hlines to "no"

Adding `:hlines no' strips the horizontal line, but does keep the header.

  #+begin_src emacs-lisp :var data=table :results output :hlines no
  (mapc (lambda (item) (princ (format "UPDATE dim SET val=%s WHERE code='%s'\n"
                                      (nth 1 item) (nth 0 item))))
   data)
  #+end_src

  #+results:
  #+begin_example
  UPDATE dim SET val=Value WHERE code = 'Key'              <<< LINE NOT WANTED
  UPDATE dim SET val=1 WHERE code = 'ABJ'
  UPDATE dim SET val=2 WHERE code = 'DEK'
  #+end_example

* Set :hlines to "yes"

`:hlines yes' should leave the horizontal line, but generates an error.

  #+begin_src emacs-lisp :var data=table :results output :hlines yes
  (mapc (lambda (item) (princ (format "UPDATE dim SET val=%s WHERE code='%s'\n"
                                      (nth 1 item) (nth 0 item))))
   data)
  #+end_src

--8<---------------cut here---------------start------------->8---
  Debugger entered--Lisp error: (wrong-type-argument listp hline)
    nth(1 hline)
    (format "UPDATE dim SET val=%s WHERE code='%s'\n" (nth 1 item) (nth 0 item))
    (princ (format "UPDATE dim SET val=%s WHERE code='%s'\n" (nth 1 item) (nth 
0 item)))
    (lambda (item) (princ (format "UPDATE dim SET val=%s WHERE code='%s'\n" 
(nth 1 item) (nth 0 item))))(hline)
    mapc((lambda (item) (princ (format "UPDATE dim SET val=%s WHERE 
code='%s'\n" (nth 1 item) (nth 0 item)))) (("Key" "Value") hline ("ABJ" 1) 
("DEK" 2)))
    ...
    call-interactively(org-self-insert-command nil nil)
--8<---------------cut here---------------end--------------->8---

* Ignore the table header

Finally, how am I then supposed to *ignore the header line*?  By adding

  #+begin_src emacs-lisp
  (setq table (cdr table))
  #+end_src

?

Do I have to do that explicitly in my code block, or is there an option for
telling that to Babel?

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]