* one variable to set indent length: example (was: Re: How to change Perl mode indentation to two spaces and no tabs?)
[not found] <mailman.5133.1434513333.904.help-gnu-emacs@gnu.org>
@ 2015-06-18 22:35 ` Emanuel Berg
0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2015-06-18 22:35 UTC (permalink / raw)
To: help-gnu-emacs
Robert Thorpe <rt@robertthorpeconsulting.com> writes:
>> As a side note, I don't understand why one cannot
>> get this by the use of a single variable value.
>> I seems like a thing one would just store in a (1)
>> variable and then have that configurable by the
>> user, and propagated down the pipe. Why should it
>> be there three times - out of which, once negated?
>> If there is a good answer, this is a serious
>> question, if there isn't, consider it rhetorical...
>
> This is tricky.
No it isn't! :)
I just checked out my own fpscalc major mode which
I wrote not later than 2014-07-03 with no thought
whatsoever to this problem, and now I examine the
"fpscalc-indent-line" function (line 320) and see
there is a variable called "indent-unit", so I added
right before the function:
(defvar *supposedly-all-emacs-indent-width* 2)
;; (setq *supposedly-all-emacs-indent-width* 4)
and then replaced that hard-coded data inside the
function with a reference to the global, and here is
how it looks, with and without evaluating that second
line on the fly and then reindenting:
http://user.it.uu.se/~embe8573/dumps/one-indent-var.png
Feel free to try it out - all links are here, and all
files are in the fps dir, and there is even the demo
system that is dumped in the above PNG.
http://user.it.uu.se/~embe8573/fps/fpscalc.el
Wow! Even tho I got a lot of help with that pack
(which isn't anything bad, on the contrary) I have to
say the code speaks a clear language. It is a pity
that mode is about a tool (namely fpscalc) which isn't
in the Debian repos or any other software archive to
my knowledge, otherwise I would supply that mode to
ELPA which (if accepted) would give me immense
pride...
> There are two aspects to tabs:
>
> * How a tab character is displayed. This is
> controlled by the variable tab-width.
> Usually though, the only way you can insert a tab
> character is with C-q TAB or C-q C-i though.
> By default Emacs binds TAB to a command.
>
> * What pressing tab inserts. If a mode doesn't have
> an indentation convention then this is defined by
> tab-stops-list and tab-to-tab-stop. If the mode does
> have an indentation convention then that takes over
> and it's defined by a mode specific variable.
Right. There are several things at work here which
perhaps do not always intersect.
TAB is a key which can be bound to do useful stuff.
It should since it is a good, big, and close key.
A tab is a char that should be avoided in code.
In Makefiles they must be there for some reason so
that is the exception. This char can be displayed as
a custom number of spaces. But then why not have it
spaces? Good question. The only answer that is valid
but without that much weight is that people want it to
look their ways, and with spaces in sequence, that
isn't possible because it not only looks different, it
is! However, most people should be fine with two or
three spaces. If you are that picky typically you
don't work on huge projects where dozens of people
edit your source all day long.
How many spaces there should be should be easily
configurable. Then everyone can have that as they
please. However for the scenario above with
collaborative source it will be a complete
catastrophe because if people start re-indenting the
entire source with a single keystroke that will make
for one big commit :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-06-18 22:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.5133.1434513333.904.help-gnu-emacs@gnu.org>
2015-06-18 22:35 ` one variable to set indent length: example (was: Re: How to change Perl mode indentation to two spaces and no tabs?) Emanuel Berg
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.