babel: adding library-of-babel functions for file I/O
* contrib/babel/lisp/org-babel.el (org-babel-insert-result): Replaced call to `org-cycle' with a call to the simpler and more appropriate `org-table-align'. * contrib/babel/library-of-babel.org (Read/Write): adding library-of-babel functions for file I/O
This commit is contained in:
parent
367d81d9dc
commit
4e43e7fea8
|
@ -35,6 +35,32 @@
|
|||
The raw Org-mode text of this file can be downloaded at
|
||||
[[repofile:contrib/babel/library-of-babel.org][library-of-babel.org]]
|
||||
|
||||
* File I/O
|
||||
** reading and writing files
|
||||
Read the contents of the file at =path= into a string.
|
||||
#+srcname: read
|
||||
#+begin_src emacs-lisp :var path=""
|
||||
(with-temp-filebuffer path
|
||||
(buffer-substring (point-min) (point-max)))
|
||||
#+end_src
|
||||
|
||||
Read the lines of the file at =path= into a list.
|
||||
#+srcname: read-lines
|
||||
#+begin_src emacs-lisp :var path=""
|
||||
(split-string
|
||||
(with-temp-filebuffer path
|
||||
(buffer-substring (point-min) (point-max))))
|
||||
#+end_src
|
||||
|
||||
Write =data= to a file at =path=. If =data= is a list, then write it
|
||||
as a table in traditional Org-mode table syntax.
|
||||
#+srcname: write
|
||||
#+begin_src emacs-lisp :var data="" :var path=""
|
||||
(with-temp-file path
|
||||
(org-babel-insert-result data))
|
||||
nil
|
||||
#+end_src
|
||||
|
||||
* Plotting code
|
||||
|
||||
** R
|
||||
|
|
|
@ -965,7 +965,7 @@ code ---- the results are extracted in the syntax of the source
|
|||
(listp (cdr (car result)))))
|
||||
result (list result))
|
||||
'(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
|
||||
(goto-char beg) (org-cycle))
|
||||
(goto-char beg) (org-table-align))
|
||||
((member "file" result-params)
|
||||
(insert result))
|
||||
((member "html" result-params)
|
||||
|
|
Loading…
Reference in New Issue