Commit bd1ebe6e authored by Troels Henriksen's avatar Troels Henriksen
Browse files

Signal an error when trying to save a buffer that contains a

parent 92326ff7
......@@ -24,9 +24,31 @@
(in-package :climacs-core)
(define-condition buffer-contains-noncharacter (buffer-writing-error)
(:report (lambda (condition stream)
(format stream "Buffer ~A contains non-character object"
(name (buffer condition)))))
(:documentation "This error is signalled whenever an attempt is
made to save a buffer that contains a non-character object."))
(defun buffer-contains-noncharacter (buffer filepath)
"Signal an error of type `buffer-contains-noncharacter' with
the buffer `buffer' and the filepath `filepath'."
(error 'buffer-contains-noncharacter :buffer buffer :filepath filepath))
(defmethod check-buffer-writability ((application-frame climacs) (filepath pathname)
(buffer drei-buffer))
(do-buffer-region (object offset buffer 0 (size buffer))
(unless (characterp object)
(buffer-contains-noncharacter buffer filepath)))
(defmethod frame-save-buffer-to-stream ((application-frame climacs) (buffer climacs-buffer) stream)
(let ((seq (buffer-sequence buffer 0 (size buffer))))
(write-sequence seq stream)))
(if (every #'characterp seq)
(write-sequence seq stream)
(display-message "Cannot save to file, buffer contains non-character object"))))
(defun input-from-stream (stream buffer offset)
(let* ((seq (make-string (file-length stream)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment