io/write added

This commit is contained in:
Sameer Rahmani 2010-12-27 17:08:19 +03:30
parent c2e1f406e0
commit 76133a7f2b
2 changed files with 30 additions and 9 deletions

View File

@ -16,16 +16,38 @@
;; IO library
(defun io/read (FILE)
"Read the contents of a file into a buffer and return the content.
already opend buffer died after reading content."
(defun io/read-buf (FILE)
"Read the file content of FILE into a buffer and return
the buffer it self."
(if (file-readable-p FILE)
(let (x data)
(setq x (find-file FILE))
(setq data (buffer-string))
(kill-buffer x)
(identity data)
(let (read-buffer)
(setq read-buffer (find-file FILE))
)
(error "Can't read '%s' file.")
)
)
(defun io/read (FILE)
"Read the contents of FILE into a buffer and return the content.
already opend buffer died after reading content."
(let (buf data)
(setq buf (io/read-buf FILE))
(setq data (buffer-string))
(kill-buffer buf)
(identity data)
)
)
(defun io/write (FILE STRING)
"Write the STRING into FILE if file was writable."
(if (file-writable-p FILE)
(with-temp-buffer
(insert STR)
(write-region (point-min)
(point-max)
FILE)
)
)
)

View File

@ -66,7 +66,6 @@
(if (= DEBUG 1) (message "[SHIT] DEBUG >>> %s" ARG))
)
(defun start-shit ()
"A peace of shit configuration that tune emacs to be an IDE."
(interactive)