[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rendering a string as a new line?
From: |
Oliver Scholz |
Subject: |
Re: rendering a string as a new line? |
Date: |
Fri, 19 Sep 2003 06:19:05 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt) |
"Stefan Monnier" <monnier@iro.umontreal.ca> writes:
>>>> If the tag is more than 1 character (e.g. an XML tag),
>>> That's the case.
>> That would probably rule out a coding system as a more efficient
>> alternative to font-lock.
>
> What makes you think so ?
[...]
It's more or less a guess. It depends on the actual tag. If it is
indeed an XML tag among other XML tags, then it could be hairy to
write a CCL program. I believe that you could always--as a last
resort--implement a state machine to decode arbitrary tags, using the
`branch' statement from CCL, but it would still be hairy. As I said,
depending on the actual tag.
Hmmm, for example if the newline-tag is <p/>:
(define-ccl-program egoge-test
'(1 ((r0 = 0)
(loop
(read r1)
(branch r0
(if (r1 == ?<)
(r0 = 1)
(write r1))
(if (r1 == ?p)
(r0 = 2)
((write ?<)
(write r1)
(r0 = 0)))
(if (r1 == ?/)
(r0 = 3)
((write ?<)
(write ?p)
(write r1)
(r0 = 0)))
(if (r1 == ?>)
((r0 = 0)
(write ?\n))
((write ?<)
(write ?p)
(write ?/)
(write r1)
(r0 = 0))))
(repeat)))))
;; Testing
(let ((str "<other-tag>lirum</other-tag><p/>larum")
(vect (make-vector 9 nil)))
(ccl-execute-on-string 'egoge-test vect str))
The question is, where you draw the line between character encoding
and formatting markup. If those “tags” are rather formatting markup,
then I think it is better to use the functionality already provided by
Emacs for this purpose: either `after-insert-file-functions' and
`write-file-functions' respectively or the functionality provided by
format.el. This has also the benefit that you could put a text
property on the converted newlines to distinguish them from regular
newlines (if there are any) so that there is no ambiguity, when
encoding the buffer again.
This is all very hypothetical. Now I am curious how those tags
actually look like and what the file format in question is.
Oliver
--
Jour du Génie de l'Année 211 de la Révolution
Liberté, Egalité, Fraternité!
- Re: regexp NOT matching an extension, (continued)
- Re: regexp NOT matching an extension, Gareth Rees, 2003/09/16
- Message not available
- Re: rendering a string as a new line?, Stefan Monnier, 2003/09/16
- Message not available
- Re: rendering a string as a new line?, Oliver Scholz, 2003/09/18
- Re: rendering a string as a new line?, Kevin Rodgers, 2003/09/18
- Re: rendering a string as a new line?, Oliver Scholz, 2003/09/19
- Re: rendering a string as a new line?, Janusz S. Bień, 2003/09/19
- Re: rendering a string as a new line?, Stefan Monnier, 2003/09/18
- Re: rendering a string as a new line?,
Oliver Scholz <=
- Re: rendering a string as a new line?, Stefan Monnier, 2003/09/19
- Re: rendering a string as a new line?, Oliver Scholz, 2003/09/20
Message not available