From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-src--contents-for-write-back : preserve original major-mode, and avoid mixing tabs and spaces in org-mode buffers Date: Fri, 28 Apr 2017 01:04:15 +0200 Message-ID: <87h919zc40.fsf@nicolasgoaziou.fr> References: <877f2cvnpe.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3sSU-0004Fx-WB for emacs-orgmode@gnu.org; Thu, 27 Apr 2017 19:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3sSQ-0002la-0A for emacs-orgmode@gnu.org; Thu, 27 Apr 2017 19:04:23 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57345) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3sSP-0002l5-QY for emacs-orgmode@gnu.org; Thu, 27 Apr 2017 19:04:17 -0400 In-Reply-To: (Brent Goodrick's message of "Sat, 22 Apr 2017 20:21:07 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Brent Goodrick Cc: emacs-orgmode@gnu.org Hello, Brent Goodrick writes: > In the current implementation of org-src--contents-for-write-back, the > `with-temp-buffer` uses fundamental-mode. Correct. > Later, while inside that temp buffer, spaces are inserted in to indent > the entire source block over to where it needs to be (in my original > post, notice that I have the source block within a list item so the > source block needs to be aligned properly under that list item, no > matter to what depth that list item is). Correct. > It is in mode hook functions that certain changes to indentation can > occur, so that is why I'm switching into that mode. This is where I don't follow you. At this point, indentation changes are tailored for the source, i.e., Org, buffer. Special indentation rules from the source block mode do not apply here. > But that is not enough: In order for the text to be aligned properly > inside the org mode buffer after indentation, there cannot be a mix of > tabs and spaces, as shown in my original post. IIRC, `indent-to' is > called within the `write-back' function, and `indent-to' is affected > by the `indent-tabs-mode' value, which by default in emacs lisp mode > buffers, is t. You cannot set `indent-tabs-mode' to nil and discard user's configuration. What if I want it to be non-nil in Org buffers? Another option is to delete any leading indentation and indent it again according to `indent-tabs-mode' value in source buffer. WDYT? Regards, -- Nicolas Goaziou