[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Variable-width font indentation: pasting outside Emacs

From: Drew Adams
Subject: RE: Variable-width font indentation: pasting outside Emacs
Date: Tue, 6 Mar 2018 14:15:06 -0800 (PST)

Maybe this will clarify my raising of this pasting question:

Today, I copy some code from a Lisp file included in Emacs,
or from an Info node.  Then I modify it, add to it, subtract
from it, etc., to come up with something I think might help
answer a user question on some web site.

It happens sometimes that the code I copied uses tab chars
for indentation.  I use a nil value of `indent-tabs-mode'
for my own use, but the copied code introduces some tab
chars (alas).   I also use a fixed-width font where I'm
working on the copied code.

Depending on the particular context where I might end up
pasting (outside Emacs) my code that now includes some tab
chars, the result might mess up indentation because the
paste context handles tab chars differently.  This is so
even in the common case where the destination expects code
and a fixed-width font and handles such input well.

So today, I'm in the habit of first using `untabify' to
convert such tab chars to SPC.  End of story - great and
easy solution.

In effect, I performed a simple operation before copying.
I could just as well have used a custom command that
copied the text after converting (perhaps a copy of) it
by replacing the tab chars.

Without the simple `untabify' function that Emacs provides,
or something similar (e.g. `query-replace'), I might have
pasted the text with tab chars into the destination, and
then have had to manually clean it up using the inferior
editor of the destination context.  Ugh.

Tab chars are, in effect, variable-width text.  What we
do now to handle tab chars across different environments
can perhaps give us some idea of the problem, and perhaps
of possible solutions, about variable-width text in general.

When using a variable-width font, SPC as well as tab chars
have variable width.  Other chars do too, of course, but
SPC and tab chars are typically used for indentation and

Do we have such a simple solution, analogous to using
`untabify' before pasting, for a case where copied code
(or other text) is variable-width?  And where perhaps
the paste destination also handles variable-width text?

Should we?  If we don't, how much trouble will users have
to go through to work around the problem or clean up when
they see crazy results from pasting?

That's the question I'm suggesting we think about.  And
this context is likely more complex, as there are different
kinds of destinations, which may handle variable-width text
differently.  IOW, there may not be a single, simple,
one-size-fits-all `untabify' analog.  We might need more
than one approach.

Yes, it is the user who knows the destination (better than
Emacs knows it, at least).  It is the user whom I would
want to be able to choose how to handle it.

How we can best respond to this question/problem, I don't
know.  I was only asking that we take it into account while
designing an improved-variable-text-indentation-&-alignment
approach for use inside Emacs.  It's not just about how
things look in Emacs.  Text copied from Emacs sometimes
gets pasted outside Emacs.  Let's think about that too;
that's all.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]