[Openmcl-devel] Is this a bug?

Ron Garret ron at flownet.com
Mon Jan 25 01:21:11 PST 2010


On Jan 24, 2010, at 6:43 PM, Ron Garret wrote:

> 
> On Jan 24, 2010, at 2:17 PM, Ron Garret wrote:
> 
>> Seems like this ought to work but it doesn't:
>> 
>> ? (hi:buffer-region (gui::hemlock-buffer (second (gui::windows))))
>> #<Hemlock Region "foo">
>> ? (hi:region-to-string *)
>>> Error: value NIL is not of the expected type STRUCTURE.
>>> While executing: HI::ENSURE-BUFFER-GAP-CONTEXT, in process Listener(6).
>> 
>> This doesn't work either:
>> 
>> ? (hi::string-to-region "foo")
>> #<Hemlock Region "
>>> Error: value NIL is not of the expected type STRUCTURE.
>> 
>> The mere existence of string-to-region leaves me mightily puzzled.  I don't see how that could possibly do anything even remotely coherent, and trying to reverse-eningeer it seems to lead down a serious rabbit hole.
> 
> It seems that before you use either of these functions you have to bind hi::*current-buffer*.

Spoke too soon.  There seem to be some actual bugs here.

The print functions for regions and marks invoke INSURE-BUFFER-GAP-CONTEXT, which relies on HI::*CURRENT-BUFFER* being bound to a buffer.  But regions and marks are not necessarily associated with any buffers.  In particular, a region created by HI::STRING-TO-REGION is not associated with any buffer.  So if such a region gets printed you lose.

? (progn (setf r (hi::string-to-region "snoz")) t)
T
? (princ-to-string r)
> Error: value NIL is not of the expected type STRUCTURE.
> While executing: HI::ENSURE-BUFFER-GAP-CONTEXT, in process Listener(6).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 > :b
*(10EBB690) : 0 (ENSURE-BUFFER-GAP-CONTEXT NIL) 31
 (10EBB6E0) : 1 (CURRENT-OPEN-LINE) 29
 (10EBB6F0) : 2 (CURRENT-OPEN-LINE-P #<Hemlock Line "#<error printing object>) 29
 (10EBB708) : 3 (BUFFER-LINE-LENGTH #<Hemlock Line "#<error printing object>) 85
...

Also, when I try to manipulate regions associated with buffers, CCL tends to crash.  For example:

(setf hv (gui::cocoa-edit "/path/to/some/file"))
(setf b (slot-value hv 'hi:buffer))

? (hi::delete-region (hi::buffer-region b))
> Error: value NIL is not of the expected type STRUCTURE.
> While executing: HI::ENSURE-BUFFER-GAP-CONTEXT, in process Listener(7).
...
? (let ((hi::*current-buffer* b)) (hi::delete-region (hi::buffer-region b))) --> KABLOOEY

In the AltConsole:

> Error: Objective-C runtime exception: 
>        *** NSRunStorage, _NSBlockNumberForIndex(): index (15) beyond array bounds (12)
> While executing: (:INTERNAL GUI::|-[HemlockTextStorage noteHemlockDeletionAtPosition:length:]|), in process Initial(0).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > 

And yet somehow Hemlock seems to work without blowing up when I select all the text in a file and press the delete key.  So what am I doing wrong?

rg




More information about the Openmcl-devel mailing list