[climacs-devel] Some small patches

Robert Strandh strandh at labri.fr
Thu Jan 6 12:57:02 UTC 2005


Hello Rudi.

Rudi Schlatte writes:
 > 
 > Just to mingle with the cool kids, I've superficially browsed the
 > climacs code.  I must say it was an enjoyable read, very clean and
 > with good naming and structure.  

Thank you.  That's good to hear. 

 > I append some proposed fixes for
 > things that caught my eye; since I haven't even downloaded the code
 > locally, it's in the form of whole, modified functions, for which I
 > apologize.

No problem. 

 > 1) buffer.lisp: buffer-sequence conses unnecessarily, since the length 
 > of
 > the result vector is known; the following (untested) might be
 > better.  As before, the case of offset1 > offset2 returns a
 > zero-length vector, but this is more apparent in the code now.
 > 
 > (defmethod buffer-sequence ((buffer standard-buffer) offset1 offset2)
 >    ;; untested, for illustration purposes only
 >    (assert (<= 0 offset1 (size buffer)) ()
 >            (make-condition 'no-such-offset :offset offset1))
 >    (assert (<= 0 offset2 (size buffer)) ()
 >            (make-condition 'no-such-offset :offset offset2))
 >    (if (< offset1 offset2)
 >      (let ((result (make-array (list (- offset2 offset1)))))
 >        (loop for offset from offset1 below offset2
 >              for i upfrom 0
 >              do (setf (svref result i) (buffer-object buffer offset)))
 >        result)
 >      (make-array '(0))))

I took this idea but modified your code a bit.  In particular I
removed some of your consing :) in your call to make-array.

 > 2) gui.lisp could use a method
 > 
 > (defmethod frame-standard-output ((frame climacs))
 >    (get-frame-pane frame 'int))
 > 
 > (if the minibuffer is indeed the standard-output, of course), 

It is not.  It is *standard-input* in fact.  And *standard-input* and
*standard-output* are bound by the toplevel loop.  But it might be a
good idea, to bind something like *error-output*.  I'll have to think
about that some more.

 > so that
 > the function display-message can display to *standard-output* instead
 > of *standard-input*.
 > 
 > 3) Also, in gui.lisp, initialize-instance shouldn't unconditionally
 > clobber the syntax:
 > 
 > (defmethod initialize-instance :after ((pane climacs-pane) &rest args)
 >    (declare (ignore args))
 >    (with-slots (buffer point syntax mark) pane
 >       (when (null point)
 >         (setf point (make-instance 'standard-right-sticky-mark
 >                        :buffer buffer)))
 >       (when (null mark)
 >         (setf mark (make-instance 'standard-right-sticky-mark
 >                        :buffer buffer)))
 >       (when (null syntax)
 >         (setf syntax (make-instance 'texinfo-syntax :pane pane)))))

OK, but that required adding an :initform to the syntax in the class. 

Thanks again, 
-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------



More information about the climacs-devel mailing list