From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Musings on creating an HTML-based WYSIWYG mode Date: Tue, 01 May 2018 16:54:51 +0200 Organization: Programmerer Ingebrigtsen Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1525186391 25768 195.159.176.226 (1 May 2018 14:53:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 1 May 2018 14:53:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 01 16:53:07 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fDWeN-0006Xq-1F for ged-emacs-devel@m.gmane.org; Tue, 01 May 2018 16:53:03 +0200 Original-Received: from localhost ([::1]:42941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDWgU-0001yV-3W for ged-emacs-devel@m.gmane.org; Tue, 01 May 2018 10:55:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDWgM-0001yP-2m for emacs-devel@gnu.org; Tue, 01 May 2018 10:55:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDWgI-0000zi-3W for emacs-devel@gnu.org; Tue, 01 May 2018 10:55:06 -0400 Original-Received: from [195.159.176.226] (port=57711 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fDWgH-0000z5-Sh for emacs-devel@gnu.org; Tue, 01 May 2018 10:55:02 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fDWe6-0006FP-1P for emacs-devel@gnu.org; Tue, 01 May 2018 16:52:46 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 63 Original-X-Complaints-To: usenet@blaine.gmane.org Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEULBwfgxmf053o3GQyD TyD+/YNlMRG4kUs+7yfQAAACeUlEQVQ4jVWUTW/iMBCGRzKiZ0e0PmMpd0uOvFdYLPuOxD1VrOEc SPHf33cctqUWMjCP5+OdcUJ1YlUiB44m3/rL96LKxZc4hZKX3L0C9uwDwFRivl1eQIzRw4UZP+rq 0f8HU8CWYo51TWItvgiHUywpnoY4HfX7T6gkDoiTsM/m/dLbS39uoco4NMDlapDECpBQQxo3MbZM dda/qhq3K3iLczOdbd83cIJyKXq4f15+lcs0MVAq6fgErdyYJue5pASnvMpYQUnsFDoCkenztSWF mVTwRENccpNtV+WKT4En8g61Lb0kuJybDgpj4kl5T5MvXy+hRlKOnCNPjv58t+psKbqtUuRH74je 7LPes7WUD8opuAjYPkcIe0/LQWyTV9jVDbZmh8cyemRh9n6Cx3nhv2vFVEdUNAUAFY56gX67gh1i i3KPyWeTa02d1p2EIiTlAIme8y5XnWaNBaCgkR2yBz5+xFkvtYoLLR5RIERJqKXMXRUAj8eIJk4O do7zI9f5VqttoU44LiUx53m3aF3NIunJPJS0XTGHqk2czViXuYGI7L6B67yPJdKjNrBrANNNnDv7 ERxlAZqWBpQaeMp2/wFVKjdQ7wByH1CU3e8A6NrAfNii3G1JJUKWQYMoihDShwFzV7jvGdXru4SS JGTuW0d4njjm2VhtHu5aG0B3nXSx4JzptKmyBIySTuGGxPZfNyA50HTM1EFgNgLMDyCZbYA+NG8P 01zNE2CNcuNrp38W4svHOzwJWf8CG/HAa+AqYP80dwIOApA75nqzzbzX3R73ElNXpwAzlHRCsGHm tClOQKp5gZDmYq2AoYZxc9rGVfAaChfuHwhbA2O/ZhImAAAAAElFTkSuQmCC Mail-Copies-To: never Cancel-Lock: sha1:d481D2lHCjdSWvKi8lzfY0xkxA8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225012 Archived-At: I'm not going to implement this any time soon, but I wondering how much work it would be to create a WYSIWYG mode for Emacs based on round-tripping through shr. I think most people who have approached this subject before have said "just use some text properties and store as enriched text and there you go", but it's just not sufficient: If you're writing a
    list, then you want this to be rendered as it should be, and it should be rendered as the recipient is likely to read the text. Otherwise it's not very WYSIWYG, is it? So: The serialisation format would be HTML. Whenever a user types something, Emacs generates HTML, asks shr to render it, and then present the user with the results. This would, of course, potentially be horrifically slow, but we could envision strategies to only re-render parts of the buffer/document. Let's say the user is typing away at something resembling this paragraph, and then decides to make "typing" bold, so the user would go back to that work, mark it and issue whatever command there is for "make this bold". The mode would do the change to the HTML document, ask shr to re-render it, and then display the results. This is, of course, not like what Emacs does normally when editing text, and would break a lot of invariants that people are used to. We can preserve basic things like point and mark easily enough (by inserting special constructs into the HTML that allows us to find and restore them after re-generating the buffer), but I'm sure there's oodles of stuff that will stop working with such a radical approach. But perhaps that's OK? Inserting images and the like into the buffer would be unproblematic -- just add a few new dired commands like "copy image to WYSIWYG clipboard" and then yank from that "clipboard" into the buffer. This presents further interesting questions about the serialisation format... but we could, for instance, use MIME for that: multipart/related with the images stashed as cid: links. "External" images are simpler, of course. The WYSIWYG clipboard would also be necessary for when cutting and yanking text: If you're killing text starting from the middle of a link and ending up in the middle of an
      link, you have to ensure that you end up with something similar when you yank this mess somewhere else. And you have to ensure that everything remains valid around where you killed the region, too. And then there's always the interesting subject of tables, or rather: Side-by-side continuous regions. Making editing commands work in those circumstances may be, er, interesting... So here's what I think: I think somebody (i.e., me) should try implementing this. I think there are so many unknowns here that it's difficult to say whether this is a workable way of doing WYSIWYG in Emacs before you have something semi-working and get a grip on how this would feel in practice. But like I said, I don't have time at the moment. :-) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no