From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: one variable to set indent length: example (was: Re: How to change Perl mode indentation to two spaces and no tabs?) Date: Fri, 19 Jun 2015 00:35:48 +0200 Organization: Aioe.org NNTP Server Message-ID: <87lhfgbq63.fsf@debian.uxu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1434666619 625 80.91.229.3 (18 Jun 2015 22:30:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Jun 2015 22:30:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 19 00:30:18 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z5iK9-0006j7-M7 for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Jun 2015 00:30:17 +0200 Original-Received: from localhost ([::1]:55114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5iK8-0005Ch-VW for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Jun 2015 18:30:16 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 91 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:IeEbOpBiDxzQ5jdISboisFKFA6Y= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:212761 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105045 Archived-At: Robert Thorpe 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