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: Sat, 29 Apr 2017 11:59:05 +0200 Message-ID: <87ziezy1p2.fsf@nicolasgoaziou.fr> References: <877f2cvnpe.fsf@nicolasgoaziou.fr> <87h919zc40.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4P9j-0002OR-Um for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 05:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4P9g-0004sH-TY for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 05:59:12 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:47215) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d4P9g-0004q4-NW for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 05:59:08 -0400 In-Reply-To: (Brent Goodrick's message of "Fri, 28 Apr 2017 08:29:03 -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: > I do not understand what is meant by "tailored for the source" which > is the Org buffer. All of the indentation changes being made here are > within the temporary buffer created by with-temp-buffer, which is > using fundamental-mode which is not the same as either emacs-lisp-mode > or org-mode. That is the wrong mode to be in when running `indent-line-to` > function since it is that particular editing mode that the user has > control over the `indent-tabs-mode` variable (typically from mode hook > functions). So I conclude that the temporary buffer, at that point in > execution, has to be in the mode of the language used when indenting. This is not necessary. `org-src--contents-for-write-back' merely adds up indentation to the existing one. In particular, it doesn't re-indent lines. The indentation being added depends on Org mode (was the block in a list? Is it a src block where special indentation rules apply...), not on the major mode from the edit buffer. However, you have a point, as we need to somehow retain the values of `indent-tabs-mode' and `tab-width' from Org source buffer, since those may differ from the ones used in the temporary buffer. Also, calling `org-mode' again in the temporary buffer, in addition to being slow, wouldn't preserve, e.g., local values from the source buffer. So I think the best thing to do is to store `indent-tabs-mode' and `tab-width' from source buffer and apply them back into the temporary buffer. I committed a change along those lines, along with tests, in the maint branch. Does it fix the issues you were encountering? Regards, -- Nicolas Goaziou