Subject: Re: bug#8108: 24.0.50; debugging pre-write-conversion in define-coding-system

From: Eli Zaretskii <[email-masked]>
Date: Thu, 21 Apr 2011 12:06:40 +0300

> Date: Thu, 21 Apr 2011 07:48:19 +0200 (CEST)
> From: Werner LEMBERG <[email-masked]>
> 
> 
> Any takers?

I don't know enough about Edebug to help you understand why it doesn't
get activated.  However, if you can tell which version of Emacs was
last that did invoke the debugger, I could try looking for the changes
that could have caused that.  E.g., does that work in Emacs 23.x?

> The very problem is that cjk-enc.el, after being adapted
> to define-coding-system, completely fails: I no longer get any
> reasonable output, and all CJK characters disappear in the output.
> But without being able to debug I can't tell what and where exactly it
> is failing...

Are you comfortable with debugging on the C level, or does the
solution have to be on the Lisp level?

If the former, it looks like the pre-write-conversion function is
invoked in this fragment from encode_coding_object:

	args[0] = CODING_ATTR_PRE_WRITE (attrs);
	args[1] = make_number (BEG);
	args[2] = make_number (Z);
	safe_call (3, args);

By stepping into the safe_call function, then into Funcall that it
calls, you should be able to see how the Lisp interpreter runs the
code of you pre-write-conversion function and where it fails.  It is
less convenient than debugging in Lisp, but you still should be able
to display all the forms that are being evaluated, show the Lisp
backtrace with "xbacktrace", and even step into C-level primitives you
invoke from your pre-write-conversion function, something you cannot
do from Lisp.

Alternatively, maybe post here the code of your pre-write-conversion
function, perhaps someone will be able to find the problem just by
looking at the code.