[ yes, I'm responding to old mail... ] On Tue, 2001-12-11 at 02:15, Richard Stallman wrote: > We could modify Fread to optionally return character positions in the > stream of the components of the form it reads, perhaps by recursively > substituting every form with (form . position), in the way > Fread_from_string does. > > The resulting Lisp object would be rather strange and not possible to > compile. The byte compiler expects to get Lisp expressions. It > sometimes has to evaluate those expressions. > > Storing the correspondence in another place would work better. > The compiler could access it there. The recent discussion about symbol properties reminded me of this thread, and gave me an idea for how to implement this (my initial idea was storing the read position of the symbol as a property, but that didn't end up working out, so I did it another way). Please test this patch! It is kind of a hack (especially the modifications to the byte-compiler), but it seems to work for most of the cases I've tried. The problem really with this approach is that it is very unlikely to ever be perfect. I do think though that we can get it to work in 95% or so of the cases, and possibly more. Before I go to that effor though, I'd like to double-check that people like this idea and agree we should include it. (ignore the bit about using delete* in bytecomp.el; I suppose what I'll have to do is copy it into bytecomp.el...) src/ChangeLog: 2002-05-23 Colin Walters * lread.c (readchar_count): New variable. (readchar): Increment it. (unreadchar): Decrement it. (read_multibyte): Decrement it. (Vread_with_symbol_positions): New variable. (Vread_symbol_positions_list): New variable. (read_internal_start): New function, created from Fread and Fread_from_string. Handle Vread_symbol_positions_list and Vread_with_symbol_positions. (readevalloop, Fread, Fread_from_string): Use it. (read1): Use readchar_count to add symbol positions to Vread_symbol_positions_list if Vread_with_symbol_positions is non-nil. (syms_of_lread): DEFVAR_LISP and initialize them. * lread.c (read0, read1, read_list, read_vector, read_multibyte) (substitute_object_recurse, substitute_object_in_subtree) (substitute_in_interval): Prototype. (read_multibyte): Return c if it's less than zero. lisp/ChangeLog: 2002-05-24 Colin Walters * emacs-lisp/bytecomp.el (byte-compile-last-line): Deleted. (byte-compile-read-position): New variable. (byte-compile-last-position): New variable. (byte-compile-log-1): Use it. (byte-compile-set-symbol-position): New function. (byte-compile-obsolete, byte-compile-callargs-warn) (byte-compile-arglist-warn, byte-compile-arglist-warn) (byte-compile-print-syms, byte-compile-file-form-defmumble) (byte-compile-check-lambda-list, byte-compile-lambda) (byte-compile-form, byte-compile-variable-ref) (byte-compile-subr-wrong-args, byte-compile-negation-optimizer) (byte-compile-condition-case, byte-compile-defun) (byte-compile-defvar, byte-compile-autoload) (byte-compile-lambda-form): Use it. (byte-compile-from-buffer): Set it, and bind `read-with-symbol-positions' and `read-symbol-positions-list'.