#(1 2 3)
I think it's supposed to be a vector of numbers, but I don't really
care about this stuff; for my purposes it would be sufficient if the
Emacs Lisp reader just ignored it, but everything else is fine, too.
Is it possible to customize the Emacs Lisp reader such that it is able
to read sexes containing stuff like this? Example:
(:document
(:postings #(1 2 3)
:headline "foo bar"
:id "baz"))
,-----
| Footnotes:
| [1] or should that be `sexpy'?
`-----
tia,
kai
--
Abort this operation? [Abort] [Cancel]
> Is it possible to customize the Emacs Lisp reader such that it is able
> to read sexes containing stuff like this? Example:
I highly doubt it. I wanted to do *exactly* the same thing. Instead
I just wrote an elisp script that would convert a buffer with #(...)
to the [...] notation. But, of course it's easy to tell true CL to
understand the [...] elisp notation as being (vector ...). So if you
want that code, then it's like this:
(defmacro defdelim (left right param-list &body body)
"Define a new LISP delimiter!"
`(ddfn ,left ,right #'(lambda ,param-list ,@body)))
(let ((rpar (get-macro-character #\))))
(defun ddfn (left right fn)
(set-macro-character right rpar)
(set-macro-character left
#'(lambda (stream char1 char2)
(declare (ignore char1 char2))
(apply fn
(read-delimited-list right stream t))))))
(defdelim #\[ #\] (&rest args)
`(vector ,@args))
good luck, and keep having fun w/ elisp.
dave
yes. the Emacs Lisp reader defers to the value LOAD-READ-FUNCTION, if
that is non-NIL, from the functions LOAD and EVAL-REGION. this has been
used (or abused) to hack a Common Lisp reader for Emacs, but right now I
can't find that package. anyway, the package "eval-reg" (distributed
with Emacs) replaces a few functions with new versions that allow
customization to the Emacs Lisp reader. it may be worth a shot.
#:Erik
--
http://www.naggum.no/spam.html is about my spam protection scheme and how
to guarantee that you reach me. in brief: if you reply to a news article
of mine, be sure to include an In-Reply-To or References header with the
message-ID of that message in it. otherwise, you need to read that page.
> [...] anyway, the package "eval-reg" (distributed with Emacs)
> replaces a few functions with new versions that allow
> customization to the Emacs Lisp reader. it may be worth a shot.
I've got Emacs 20.2. I have looked at `eavl-reg.el' and there are
only 3 occurrences of the word `read', two of them are in comment
lines. The third is (setq elisp-form (read elisp-buf)).
It seems that this package only redefines the eval functions, but not
read. I don't want to EVAL the sexes, I just want to READ them.
And then there's your hint to use LOAD-READ-FUNCTION. The
documentation says that's the function which LOAD and EVAL-REGION use
for READing. Which also doesn't change what READ does.
As this #( ... ) construct is the only unREADable thing in the output
of waisq, I think I would be better off by putting said output in a
buffer, then replace the construct with [ ... ], then READ the
result. If only there wasn't the problem that `#(' might occur in a
string, too :-(