(in-package hemlock) ;;; Scratch windows' documents have their ns:isa slots reset (defclass ns::my-ns-document (ns:ns-document) () (:metaclass ns:+ns-object)) (declaim (special ns::my-ns-document)) (defun cl-user::my (&optional (scratch-p t)) (gui::execute-in-gui (lambda nil (let* ((hview (gui::find-or-make-hemlock-view nil)) (buffer (hemlock-view-buffer hview)) (window (#/window (hi::hemlock-view-pane hview))) (wc (#/windowController window)) (document (#/document wc)) (stream (hi:make-hemlock-output-stream (buffer-end-mark buffer) :none))) ; All possible values {:none, :line, :full} have identical effect) (#/setTitle: window (objc::make-nsstring (copy-seq "My title"))) (when scratch-p (setf (slot-value document 'ns:isa) (find-class 'ns::my-ns-document))) (format stream "A change~%")))))