all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oliver Scholz <alkibiades@gmx.de>
To: emacs-devel@gnu.org
Subject: Re: Saving markup formats
Date: Tue, 19 Jun 2007 09:43:08 +0200	[thread overview]
Message-ID: <f581ee$4mh$1@sea.gmane.org> (raw)
In-Reply-To: 87fy4prmdf.fsf@jurta.org

Juri Linkov <juri@jurta.org> writes:

>> This is a very old project of mine, and an abandoned one, I am afraid.
>> Of course, anybody is free to make use of the codebase, but I for
>> myself am convinced that it is the wrong approach.
>
> Could you tell why do you think it is the wrong approach?  This would help
> someone who will do something similar to avoid mistakes you think you made.

Basically the approach was too naive. Basically I started like this:
"Hey, implementing RTF can't be too hard. Let's just take the RTF
spec, write a parser for it, get the text with some text properties
into a buffer and write a major mode for editing it."

Until I realised, a) if you want word processing in Emacs this SHOULD
be designed with different target formats right from the start and b)
even for RTF alone this is not sufficient. IIRC I was originally
planning for flat data structure: RTF's paragraph formatting
properties and character formatting properties each stored as lists or
vectors in a separate text property. Font-lock then would resolve
character formatting properties and apply faces, Fill-paragraph would
resolve whitespace formatting properties. This would work for simple
cases. But it wouldn't in all cases preserve the logical structure of
the original document, if you got it from somebody using a different
word processor. This is a very bad thing; a _reliable_ word
processor---as opposed to an unreliable hack---shouldn't make any
changes to the logical structure of a document unless explicitly
ordered to do it. Also, while it is o.k. to implement only a subset of
RTF in the beginning, the design (or lack thereof) of the data
structure would eventually lead to a dead end.

> How would you do things over if you had enough time?

I'd start designing the data structure. I would do it with an eye on
the various specifications for XML (most notably: the XML info set and
the style properties in CSS), for the simple reason that they were
designed to cover a wide range of needs for text/data representation,
formatting, text processing etc. and that in this area they are tested
by a lot of people. So looking at XML right from the start could help
avoiding shortcomings in the design that lead to dead ends or crude
kludges later. Also, for a word processing suite in Emacs, XML file
formats would be the major target formats besides RTF: XHTML, TEI XML,
DocBook, eventually techinfo XML.

So, IMNSHO spending thought about text representation and rendering in
Emacs is the _very first_ thing to do. Once you have a capable data
structure, parsing RTF is not too hard. You can regard an RTF document
as some sort of weird s-expression, with "{" and "}" instead of
parentheses. It is still a dreadful file format, because of its lack
of constraints, but, again, if and only if you have a well designed
data structure, you have a fighting chance to deal with those dreads.

I'd start with designing a data structure that is a realisation of the
XML info set. (This has nothing to do with pointy brackets. The XML
info set is a specification of requirements for a data structure. IIRC
there is a W3C technical report out there.) This doesn't have to be
DOM. I am pretty confident, that it is rather straight forward to
parse RTF into an instance of the XML info set.

Unfortunately, this is were the trouble starts. With the XML info set
the logical structure of the internal data structure is clear (except
for style properties). But the specifics depend on Emacs' ability to
render text on-screen. Of course, there are ways to implement a
tree-like data structure even with CDATA as text in a buffer right
now---I was experimenting with overlays, for instance. But eventually,
if you really go for word processing, you'd have to enhance the
display engine anyways to deal with certain style properties. So you'd
might as well design both, the tree-like data structure and how the
display engine deals with it, right from the beginning---thus gaining,
possibly, maximum reliability.

Also, after I discarded the naive approach I have spent a lot of
thought on UI issues and I would advice anybody to do the
same---again, right from the beginning, before you write a single line
of code. What is word processing exactly? Current word processors are
hybrid beasts, undecided between DTP software (like Adobe Indesign,
Quark Express, Macromedia Freehand, Inkscape, Scribus) and programmes
dealing the logical structure of documents. Word processors have an
ambiguous editing model, resulting from a long history starting with
their origin as replacements for typewriters. Emacs' editing model on
the other hand is mostly about dealing with text/plain, even were it
goes beyond that. So if you come from the Emacs world alone, you are
bound to unwillingly design your UI according to your best known
editing model (especially because it is easiest to implement in Emacs)
and maybe you even make decisions for the design of the data structure
which make that mandatory. Thus, you'd add to the confusion that's
already there. The result being probably the worst word processor
ever, not the best. In that case, would be better to stick with
packages like Muse or emacs-wiki or something similar, which are
one-way (no reading of other file formats), for your own documents
(that's what I do); and use Abiword or OpenOffice if you receive
documents from somebody else. Word processors are good for document
exchange, that's why they are more popular than DTP software. So,
should the UI make the logical structure which would be stored in the
file explicit? What are the objects a user wants to interact with?
I.e. if there are four spaces at the right margin, and if the user can
put the cursor on those spaces, copy them etc., then those spaces are
an object, the use can interact with. They are _there_. But is this
what he or she wants? Or does she just want a left margin that is 4em
wide? How do you distinguish a 4em margin from four spaces at the
left?

If somebody is seriously going to implement WP with a good large-scale
battle plan, then please drop me a line. I'd might find a little time
to contribute.

    Oliver
-- 
1 Messidor an 215 de la Révolution
Liberté, Egalité, Fraternité!

  reply	other threads:[~2007-06-19  7:43 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <871wgi9jzb.fsf@jidanni.org>
     [not found] ` <87odjlwpu1.fsf@jurta.org>
     [not found]   ` <E1HyNsO-000697-UX@fencepost.gnu.org>
     [not found]     ` <87ir9r1m99.fsf@jurta.org>
     [not found]       ` <E1Hys3j-0004Ml-Vp@fencepost.gnu.org>
     [not found]         ` <87myz2i9tj.fsf@jurta.org>
     [not found]           ` <E1HzHMV-0002cZ-DJ@fencepost.gnu.org>
     [not found]             ` <87r6ocx0tk.fsf_-_@jurta.org>
     [not found]               ` <E1HzdLq-0006ns-K7@fencepost.gnu.org>
2007-06-16 19:56                 ` Saving markup formats Reiner Steib
2007-06-17 18:54                   ` Juri Linkov
2007-06-17 21:08                     ` Nic James Ferrier
2007-06-17 21:18                       ` Lennart Borgman (gmail)
2007-06-17 21:57                         ` Juri Linkov
2007-06-17 22:13                           ` Lennart Borgman (gmail)
2007-06-17 22:27                           ` Nic James Ferrier
2007-06-17 22:37                             ` Lennart Borgman (gmail)
2007-06-17 22:47                               ` Nic James Ferrier
2007-06-17 23:02                                 ` Lennart Borgman (gmail)
2007-06-17 23:13                                   ` Nic James Ferrier
2007-06-17 23:46                                     ` Lennart Borgman (gmail)
2007-06-18  8:03                                       ` Nic James Ferrier
2007-06-18  8:26                                         ` Lennart Borgman (gmail)
2007-06-18  8:44                                           ` Nic James Ferrier
2007-06-18  9:25                                         ` Dave Pawson
2007-06-18 21:25                                         ` Juri Linkov
2007-06-18 22:13                                           ` Nic James Ferrier
2007-06-19  7:18                                             ` Dave Pawson
2007-06-19  7:41                                               ` Nic James Ferrier
2007-06-17 23:08                                 ` Jason Rumney
2007-06-18  0:30                             ` XML editing wishlist (was: Saving markup formats) Drew Adams
2007-06-18  8:10                               ` XML editing wishlist Lennart Borgman (gmail)
2007-06-18 13:51                                 ` Drew Adams
2007-06-18 14:39                                   ` Lennart Borgman (gmail)
2007-06-19 23:57                               ` Lennart Borgman (gmail)
2007-06-20 20:49                                 ` Vagn Johansen
2007-06-17 21:55                       ` Saving markup formats Juri Linkov
2007-06-18 21:31                     ` Richard Stallman
2007-06-18  0:05                   ` Oliver Scholz
2007-06-18 21:19                     ` Juri Linkov
2007-06-19  7:43                       ` Oliver Scholz [this message]
2007-06-19 13:38                         ` Drew Adams
2007-06-19 13:59                         ` Stefan Monnier
2007-06-19 22:25                         ` Richard Stallman
2007-06-19 23:40                           ` Nic James Ferrier
2007-06-20  0:10                             ` Lennart Borgman (gmail)
2007-06-20  0:22                               ` Nic James Ferrier
2007-06-20  0:38                                 ` Lennart Borgman (gmail)
2007-06-20  1:02                                   ` Nic James Ferrier
2007-06-20  2:19                                     ` Jeremy Maitin-Shepard
2007-06-20  8:51                                     ` David House
2007-06-20 10:16                                       ` Nic James Ferrier
2007-06-20 10:46                                         ` David House
2007-06-20 10:56                                           ` Nic James Ferrier
2007-06-20  9:45                                     ` Mathias Dahl
2007-06-20 10:19                                       ` Nic James Ferrier
2007-06-20 11:20                                         ` Mathias Dahl
2007-06-20 11:49                                           ` Nic James Ferrier
2007-06-20  0:08                           ` Oliver Scholz
2007-06-20  5:37                             ` David Kastrup
2007-06-20 10:05                               ` Oliver Scholz
2007-06-20 10:23                                 ` Nic James Ferrier
2007-06-20 11:12                                   ` Oliver Scholz
2007-06-20 11:20                                     ` Nic James Ferrier
2007-06-20 12:36                                       ` Oliver Scholz
2007-06-20 17:36                                     ` Richard Stallman
2007-06-20 20:10                                       ` Nic James Ferrier
2007-06-21  0:05                                         ` Nic James Ferrier
2007-06-21  3:59                                           ` Davis Herring
2007-06-21  7:56                                             ` Nic James Ferrier
2007-06-21 10:07                                               ` Thien-Thi Nguyen
2007-06-21 10:31                                                 ` Nic James Ferrier
2007-06-21 10:52                                                   ` Kim F. Storm
2007-06-21 12:50                                                   ` Thien-Thi Nguyen
2007-06-21 13:05                                               ` Davis Herring
2007-06-21 13:23                                                 ` Nic James Ferrier
2007-06-22  1:51                                                 ` Richard Stallman
2007-06-21 17:32                                         ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='f581ee$4mh$1@sea.gmane.org' \
    --to=alkibiades@gmx.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.