emacs-devel
[Top][All Lists]
Advanced

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

Re: Variable-width font indentation: pasting outside Emacs


From: Yuri Khan
Subject: Re: Variable-width font indentation: pasting outside Emacs
Date: Wed, 7 Mar 2018 13:28:10 +0700

On Wed, Mar 7, 2018 at 5:15 AM, Drew Adams <address@hidden> wrote:

> 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).

Okay, that is the essence of the problem: you are copying and pasting
code across a formatting convention boundary and you have to realize
and acknowledge the fact and reformat the code according to the
conventions of the target (or have code reformatted for you).

That problem is not limited to tabs, spaces, indentation, and
alignment. It involves also:

* maximum line length;
* spaces around punctuation;
* omitting or including optional grammar elements (e.g. quotes around
HTML attribute values, or the trailing semicolon in a Pascal compound
statement);
* preference for one of several equivalent forms of expressing an idea
(e.g. in C++, “const Foo” vs “Foo const”; or in HTML, using a Unicode
character directly vs character reference vs entity reference);
* …


There are some modes (web-mode comes to mind) that automatically
reindent after a paste operation. That could be made a universal
feature. I imagine it could be quite convenient if (a) your preferred
indentation style matches their defaults, or (b) you take the effort
to teach them your style; and quite annoying otherwise.

A good first step would be to make reindentation also tabify or
untabify the leading whitespace of each reindented line according to
the current value of indent-tabs-mode. (Now, if the line is to be
indented at 4, indent-tabs-mode is nil, tab-width is 4, and there is a
single tab character at the start of the line, it will be kept with a
tab.)



reply via email to

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