all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oliver Scholz <alkibiades@gmx.de>
Cc: boris@gnu.org, alex@emacswiki.org, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: enriched-mode and switching major modes.
Date: Mon, 20 Sep 2004 15:27:09 +0200	[thread overview]
Message-ID: <uy8j5kr4i.fsf@ID-87814.user.uni-berlin.de> (raw)
In-Reply-To: <m3d60hxius.fsf@kfs-l.imdomain.dk> (Kim F. Storm's message of "Mon, 20 Sep 2004 13:47:23 +0200")

storm@cua.dk (Kim F. Storm) writes:

> Oliver Scholz <alkibiades@gmx.de> writes:
>
>> Consider this HTML fragment:
>>
>> <h1>Some <i>meaningless</i> heading</h1>
>>
>> When encoding a buffer, I need to identify the whole paragraph as
>> being of the type "h1".  I.e. I have to distinguish it from:
>
> Maybe we can get some of the way with Emacs' category text properties?!
>
> In this case, you could put a 'category 'H1 text property on the heading.
[...]

<blush/> I have to admit that I have never thought of the `category'
property, instead I have always experimented with implementing its
functionality myself.  Thanks for the reminder.  This might indeed be
useful.

We still have have a problem if we mean to distinguish paragraphs by
hard newlines instead of a text property covering the region of
characters that make the content of the paragraph:

(progn (put 'h1 'face 'Info-title-1-face)
       (put 'h2 'face 'Info-title-2-face)
       (switch-to-buffer (generate-new-buffer "*tmp*"))
       (use-hard-newlines 1 'never)
       (insert (propertize "Lirum larum"
                           'category 'h1))
       (newline 1)
       (save-excursion
         (insert (propertize "lirum larum"
                             'category 'h2))))

We have to deal with the case that a user deletes the hard newline (if
you evaluate the code above: just hit backspace).  Is the resulting
paragraph of type 'h1 or of type 'h2?  What about this:

(progn (put 'h1 'face 'Info-title-1-face)
       (switch-to-buffer (generate-new-buffer "*tmp*"))
       (use-hard-newlines 1 'never)
       (insert (propertize "lirum larum" 'category 'h1))
       (insert " lirum larum") ; no `category' property.
       (newline 1))

This might happen as the result of yanking something in.

To use the `category' property for paragraphs (blocks), we have to do
something like:

(progn (put 'h1 'block t)
       (put 'h1 'space-before XX)
       (put 'h1 'left-margin XX)
       etc. ...)

I can see four ways to deal with that.  The first two imply that we
ditch the semantics of hard newlines altogether in WP documents.
(`use-hard-newlines' would remain useful for text/plain;
format=flowed.)  In order of decreasing preference and in order of
increasing fragility:

1.  A box model supported by the display engine, of course.

2.  A special fill function that examines the properties and 
    DTRT.  This is basically how `epos-fill-paragraph' in
    wp-example.el works.

3.  Make sure that each region covered by a `category' property which
    identifies the text as content of a block is separeted by hard
    newlines.  For example by letting a function run by jit-lock,
    which updates that stuff constantly.  That would mean that in the
    first example hitting backspace would have this effect:
    `delete-char-backward' would remove the hard newline, but the
    updating function would insert it again immediately.

4.  Make every hard newline read-only, whenever the user says "this
    paragraph is of type h1".  Advice `yank' to DTRT.


I don't like 3. at all.  (I think that 4. is rather silly, mentioned
only for completeness.)  IMO it short circuits two different semantics
of distinguishing paragraphs.  And my gut feeling is that exactly this
is a potential source for a lot of subtle bugs.

The problem of XML's nested blocks is still another, unresolved issue.

    Oliver
-- 
Oliver Scholz               Jour des Récompenses de l'Année 212 de la Révolution
Ostendstr. 61               Liberté, Egalité, Fraternité!
60314 Frankfurt a. M.       

  reply	other threads:[~2004-09-20 13:27 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-04 23:58 enriched-mode and switching major modes Luc Teirlinck
2004-09-05 17:25 ` Richard Stallman
2004-09-06  0:59   ` Luc Teirlinck
2004-09-06 16:42     ` Stefan
2004-09-06 16:53       ` Luc Teirlinck
2004-09-10 17:40     ` Richard Stallman
2004-09-11  2:14       ` Luc Teirlinck
2004-09-11 16:56         ` Stefan
2004-09-11 21:51           ` Luc Teirlinck
2004-09-11 22:55             ` Stefan
2004-09-12  1:46               ` Luc Teirlinck
2004-09-12 18:18                 ` Stefan
2004-09-12  2:50               ` Luc Teirlinck
2004-09-13  7:00               ` Richard Stallman
2004-09-12  9:10         ` Richard Stallman
2004-09-12 16:51           ` Luc Teirlinck
2004-09-12 17:08             ` Oliver Scholz
2004-09-12 18:36             ` Kim F. Storm
2004-09-12 20:01               ` Luc Teirlinck
2004-09-13  7:32                 ` Kim F. Storm
2004-09-13 23:03             ` Richard Stallman
2004-09-14  3:46               ` Luc Teirlinck
2004-09-14 12:26                 ` Stefan Monnier
2004-09-14 22:12                   ` Luc Teirlinck
2004-09-15  9:32                 ` Richard Stallman
2004-09-17  9:36                 ` Richard Stallman
2004-09-19 20:07                   ` Luc Teirlinck
2004-09-06  7:36   ` Oliver Scholz
2004-09-06 19:01     ` Alex Schroeder
2004-09-10 17:40       ` Richard Stallman
2004-09-10 19:30         ` Oliver Scholz
2004-09-13 23:04           ` Richard Stallman
2004-09-14 14:41             ` Oliver Scholz
2004-09-14 16:31               ` Oliver Scholz
2004-09-15  1:39               ` Luc Teirlinck
2004-09-15  1:47                 ` Luc Teirlinck
2004-09-15  8:06                 ` Oliver Scholz
2004-09-15 15:42               ` Richard Stallman
2004-09-16 13:20                 ` Kai Grossjohann
2004-09-17 23:22                   ` Richard Stallman
2004-09-16 17:04                 ` Oliver Scholz
2004-09-17  5:15                   ` Eli Zaretskii
2004-09-17 14:34                     ` Oliver Scholz
2004-09-17 20:43                       ` Kai Grossjohann
2004-09-17 22:05                         ` Kim F. Storm
2004-09-18 19:07                           ` Richard Stallman
2004-09-18 15:37                         ` Robert J. Chassell
2004-09-18 11:14                       ` Eli Zaretskii
2004-09-18 12:04                         ` David Kastrup
2004-09-18 13:32                           ` Eli Zaretskii
2004-09-18 13:46                             ` David Kastrup
2004-09-18 15:57                               ` Eli Zaretskii
2004-09-19 17:19                                 ` Kai Grossjohann
2004-09-18 22:55                           ` Richard Stallman
2004-09-18 17:08                         ` Oliver Scholz
2004-09-18 17:48                           ` Eli Zaretskii
2004-09-18 20:02                             ` Oliver Scholz
2004-09-18 21:25                               ` Eli Zaretskii
2004-09-18 21:54                                 ` Oliver Scholz
2004-09-20  0:06                                   ` Richard Stallman
2004-09-20 11:48                                     ` Oliver Scholz
2004-09-21 18:30                                       ` Richard Stallman
2004-09-21 19:08                                         ` Eli Zaretskii
2004-09-21 20:06                                           ` Stefan Monnier
2004-09-22  4:54                                             ` Eli Zaretskii
2004-09-22 18:20                                           ` Richard Stallman
2004-09-22 18:39                                             ` Eli Zaretskii
2004-09-23 16:44                                               ` Richard Stallman
2004-09-22 10:01                                         ` Oliver Scholz
2004-09-22 13:08                                           ` Stefan Monnier
2004-09-22 13:11                                           ` Stefan Monnier
2004-09-22 13:14                                             ` Oliver Scholz
2004-09-22 16:27                                               ` Stefan Monnier
2004-09-23  1:48                                               ` Luc Teirlinck
2004-09-23  9:29                                             ` Richard Stallman
2004-09-23  9:48                                               ` David Kastrup
2004-09-23 16:44                                                 ` Richard Stallman
2004-09-23 11:35                                               ` Stefan
2004-09-23 12:46                                                 ` David Kastrup
2004-09-23 12:59                                                 ` Oliver Scholz
2004-09-24 12:08                                                 ` Richard Stallman
2004-09-24 12:50                                                   ` Stefan
2004-09-25 15:34                                                     ` Richard Stallman
2004-09-24 10:59                                           ` Eli Zaretskii
2004-09-24 11:53                                             ` Oliver Scholz
2004-09-24 15:51                                               ` Oliver Scholz
2004-09-24 20:55                                                 ` Alex Schroeder
2004-09-24 21:11                                                   ` Oliver Scholz
2004-09-25 16:36                                                 ` Eli Zaretskii
2004-09-22 10:35                                         ` Oliver Scholz
2004-09-22 18:21                                           ` Richard Stallman
2004-09-20  0:05                               ` Richard Stallman
2004-09-18 22:11                             ` Kim F. Storm
2004-09-19  3:47                               ` Eli Zaretskii
2004-09-20  0:05                               ` Richard Stallman
2004-09-20 11:07                                 ` Oliver Scholz
2004-09-20 11:55                                   ` Kim F. Storm
2004-09-21 18:30                                   ` Richard Stallman
2004-09-22  7:44                                     ` Kim F. Storm
2004-09-22 18:14                                       ` Eli Zaretskii
2004-09-22 21:53                                         ` Kim F. Storm
2004-09-23  4:47                                           ` Eli Zaretskii
2004-09-23  7:13                                             ` Kim F. Storm
2004-09-22 18:20                                       ` Richard Stallman
2004-09-22 21:58                                         ` Kim F. Storm
2004-09-20 12:47                                 ` Kai Grossjohann
2004-09-17 15:08                   ` Robert J. Chassell
2004-09-18 17:34                     ` Oliver Scholz
2004-09-18 23:05                       ` Robert J. Chassell
2004-09-19 11:07                         ` Oliver Scholz
2004-09-19 11:24                           ` David Kastrup
2004-09-19 13:14                           ` Robert J. Chassell
2004-09-20  5:49                           ` Stefan
2004-09-20  6:17                             ` David Kastrup
2004-09-20  6:26                               ` Stefan
2004-09-20 11:00                             ` Oliver Scholz
2004-09-20 13:24                               ` Stefan Monnier
2004-09-20 14:17                                 ` Oliver Scholz
2004-09-20 14:55                                   ` Stefan Monnier
2004-09-20 19:18                                     ` David Kastrup
2004-09-20 19:49                                       ` Stefan Monnier
2004-09-20 19:37                                     ` Oliver Scholz
2004-09-20 20:04                                       ` Stefan Monnier
2004-09-21  9:07                                         ` Oliver Scholz
2004-09-21 14:43                                           ` Robert J. Chassell
2004-09-20 21:44                                   ` Robert J. Chassell
2004-09-17 23:22                   ` Richard Stallman
2004-09-18 16:57                     ` Oliver Scholz
2004-09-18 17:12                       ` Oliver Scholz
2004-09-20  0:05                       ` Richard Stallman
2004-09-20 11:35                         ` Oliver Scholz
2004-09-20 11:47                           ` Kim F. Storm
2004-09-20 13:27                             ` Oliver Scholz [this message]
2004-09-20 14:23                               ` Kim F. Storm
2004-09-20 19:35                                 ` Oliver Scholz
2004-09-20 19:35                               ` Oliver Scholz
2004-09-20 20:21                                 ` Kim F. Storm
2004-09-21  9:07                                   ` Oliver Scholz
2004-09-21 11:20                                     ` Kim F. Storm
2004-09-22  7:11                                   ` Richard Stallman
2004-09-21 18:30                             ` Richard Stallman
2004-09-21 20:31                               ` Miles Bader
2004-09-22  3:20                               ` James Clark
2004-09-23  9:30                                 ` Richard Stallman
2004-09-21  9:53                         ` Kai Grossjohann
2004-09-21 11:32                           ` Kim F. Storm
2004-09-21 18:53                           ` Eli Zaretskii
2004-09-21 20:34                             ` Miles Bader
2004-09-22  0:31                             ` David Kastrup
2004-09-22 14:00                           ` 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=uy8j5kr4i.fsf@ID-87814.user.uni-berlin.de \
    --to=alkibiades@gmx.de \
    --cc=alex@emacswiki.org \
    --cc=boris@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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.