|
@@ -29,26 +29,25 @@ A collection of simple utility functions
|
|
|
|
|
|
* File I/O
|
|
* File I/O
|
|
** reading and writing files
|
|
** reading and writing files
|
|
-Read the contents of the file at =path= into a string.
|
|
|
|
|
|
+Read the contents of the file at =file=. The =:results vector= and
|
|
|
|
+=:results scalar= header arguments can be used to read the contents of
|
|
|
|
+file as either a table or a string.
|
|
#+srcname: read
|
|
#+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))))
|
|
|
|
|
|
+#+begin_src emacs-lisp :var file=""
|
|
|
|
+ (if (member "vector" result-params)
|
|
|
|
+ (with-temp-buffer
|
|
|
|
+ (org-table-import (expand-file-name file) nil)
|
|
|
|
+ (org-table-to-lisp))
|
|
|
|
+ (with-temp-buffer
|
|
|
|
+ (insert-file-contents (expand-file-name file))
|
|
|
|
+ (buffer-string)))
|
|
#+end_src
|
|
#+end_src
|
|
|
|
|
|
-Write =data= to a file at =path=. If =data= is a list, then write it
|
|
|
|
|
|
+Write =data= to a file at =file=. If =data= is a list, then write it
|
|
as a table in traditional Org-mode table syntax.
|
|
as a table in traditional Org-mode table syntax.
|
|
#+srcname: write
|
|
#+srcname: write
|
|
-#+begin_src emacs-lisp :var data="" :var path=""
|
|
|
|
- (with-temp-file path
|
|
|
|
|
|
+#+begin_src emacs-lisp :var data="" :var file=""
|
|
|
|
+ (with-temp-file file
|
|
(org-babel-insert-result data))
|
|
(org-babel-insert-result data))
|
|
nil
|
|
nil
|
|
#+end_src
|
|
#+end_src
|