From: Drew Adams <drew.adams@oracle.com>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: "Clément Pit-Claudel" <cpitclaudel@gmail.com>,
"Paul Eggert" <eggert@cs.ucla.edu>,
"Emacs developers" <emacs-devel@gnu.org>
Subject: RE: Variable-width font indentation: pasting outside Emacs
Date: Tue, 6 Mar 2018 11:52:00 -0800 (PST) [thread overview]
Message-ID: <bdef1456-d3b6-4391-8eae-ea5d45bbb13a@default> (raw)
In-Reply-To: <CAP_d_8Vu35isu_Q_8Pq_z3Yt1T8W6otoWYmVaVhu_xHH7TYHqA@mail.gmail.com>
> > Could we, for example, (optionally) affect copy or paste
> > operations, to automatically try to compensate by inserting
> > the (more or less) right number of SPC chars of the
> > variable-width font (of the first non-whitespace char on the
> > line)?
>
> You mean changing the number of spaces used as indentation,
> depending on what font the receiving application uses?
Perhaps. If the design chosen for solving this inside Emacs were
just to add lots of variable-width SPC chars, and if that were
totally inappropriate in some paste context (fixed-width, for
example), a user should be able to copy the text in a way that
pasting it didn't produce something awful. I said "optionally".
(And I'm not supposing that that would be the design choice for
Emacs.)
But _I'm not proposing_ any design or implementation. I just
wanted to mention that we might want to think ahead to the fact
that users will want to paste text, including code, into other
apps. Knowing that fact might affect decisions for how we deal
with the indentation and alignment inside Emacs.
> > People communicate about code and other text in more and more
> > ways, many of which are and will remain outside Emacs. Can we
> > try to DTRT for variable-width text, so that the result of
> > pasting into another app gives indentation and alignment that
> > at least approximates what one would want/expect? If so,
> > should we try to do that?
>
> Oh please don’t.
>
> Why? Because the widget where the text is going to be pasted from
> Emacs is not the widget that will ultimately display the text.
>
> How is that? Imagine a chat application such as Mattermost. Its UI is
> a web page with a text input widget on the bottom. That widget
> normally uses a variable width font, and accepts Markdown syntax. The
> user will normally type three grave accent characters ``` and a hard
> newline, then paste a snippet of code from clipboard, then close with
> another ```. On the server, Markdown will be interpreted and the
> recipient will receive a syntax-highlighted, fixed-width-formatted
> fragment of code.
>
> With your suggestion, that fragment will have the wrong amount of
> indentation. (Where “wrong” denotes “other than the sender intended or
> expected”.)
I didn't suggest any such thing. You've gone off half-cocked.
Try reading what I wrote again, please.
There are any number of different paste contexts. Clearly it is
the _user_ who should be able to control what the paste operation,
which really means the Emacs copy operation, does.
Obviously, if an HTML text input box accepts input that is then
displayed in some particular way (using a markup convention or
whatever), the user is the one to know about that and choose the
right kind of copy from Emacs. Emacs itself cannot know about
the paste context. But the user can, if anyone can.
If Emacs doesn't offer a user any control over this then the
result will mostly be bad, not good, I'm afraid. One size does
not fit all.
> Relatedly, I have worked with several applications that support
> copying and pasting HTML markup. In their striving to make the result
> “intuitive”, they introduce abominations on the receiving side.
I didn't suggest trying to make the result intuitive or automatic.
Just the opposite.
Here are two limited/bad approaches, neither of which I'd like to
see: (1) do something in Emacs that makes display great but makes
copy+paste to other apps awful, and (2) do something in Emacs that
tries to provide a one-size-fits-all "intuitive" guess about what
the paste needs might be.
We can imagine other problematic designs, when it comes to their
effect on pasting. If _all_ indentation is realized in Emacs
only by, say, a `display' property, what will that give when the
text is pasted somewhere? There are any number of designs that
might have negative consequences for pasting. Let's keep pasting
in the back of the mind when thinking about designing display of
indentation and alignment in Emacs. That's all I wanted to say.
Only the user will know (might know) what is needed wrt pasting.
The question I'm raising is whether we can give users some control
over that.
And even if it's decided that we cannot or should not try, I expect
that ignoring the fact that people will paste copied text may lead
to a pretty indentation and alignment display inside Emacs but may
make pasting outside it problematic. Users will then need to do a
fair amount of manual whitespace cleanup after pasting, and such
cleanup is a bother in most contexts outside Emacs.
I'm contrasting that with the case we have today with fixed-width
fonts and using only SPC (not tab chars) for indentation. Piece
of cake, in general.
If we don't offer some control over this then providing pretty
display inside Emacs may make pasting outside Emacs so bad that
some users will just stick with fixed-width fonts. (I may be one
of them.)
> Example: You are reading a web page. You copy a fragment of text. The
> source page is styled with CSS that specifies a blue-black foreground
> color and a fancy font for the body text. When you paste that into a
> blog post, the receiving widget attempts to preserve that color. But,
> since the body text style of the target article specifies dark gray
> foreground color and a different fancy font, it applies direct
> formatting to the pasted text: <span style="color: rgb(0,51,102);
> font-family: Proxima Nova, …">Lorem ipsum…</span>.
>
> Now the post text is tainted. It will appear in blue-black and in
> Proxima Nova for every viewer, regardless of their preferred color
> scheme and font. A user who prefers green text on a dark gray
> background will break his/her eyes trying to read that.
>
> Copying and pasting WYSIWYG formatting: Just say no. Doing things
> behind the user’s back on copy/paste: Just say no.
You have misread me completely, I'm afraid. I am 100% against
doing any such thing, especially behind the user's back.
Ignoring the paste problem (like ignoring the serialization problem,
which is similar) won't help Emacs find the right design for solving
the problem of displaying text with proper indentation and alignment.
next prev parent reply other threads:[~2018-03-06 19:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 18:21 Variable-width font indentation: pasting outside Emacs Drew Adams
2018-03-06 19:09 ` Yuri Khan
2018-03-06 19:52 ` Drew Adams [this message]
2018-03-06 22:15 ` Drew Adams
2018-03-07 6:28 ` Yuri Khan
2018-03-06 20:21 ` Eli Zaretskii
2018-03-06 20:56 ` Richard Stallman
2018-03-06 21:31 ` Drew Adams
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bdef1456-d3b6-4391-8eae-ea5d45bbb13a@default \
--to=drew.adams@oracle.com \
--cc=cpitclaudel@gmail.com \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=yuri.v.khan@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).