From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brent Goodrick 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 09:41:07 -0700 Message-ID: References: <877f2cvnpe.fsf@nicolasgoaziou.fr> <87h919zc40.fsf@nicolasgoaziou.fr> <87ziezy1p2.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4VQk-0005S1-N7 for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 12:41:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4VQj-0007Ki-Pp for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 12:41:10 -0400 Received: from mail-io0-x235.google.com ([2607:f8b0:4001:c06::235]:35149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d4VQj-0007J7-Ln for emacs-orgmode@gnu.org; Sat, 29 Apr 2017 12:41:09 -0400 Received: by mail-io0-x235.google.com with SMTP id r16so86483894ioi.2 for ; Sat, 29 Apr 2017 09:41:08 -0700 (PDT) In-Reply-To: <87ziezy1p2.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org On Sat, Apr 29, 2017 at 2:59 AM, Nicolas Goaziou wrote: > 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. Agreed. > 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, Yes, I wondered about the performance impact. Agreed. > 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? It works splendidly! Thanks Nicolas. --Brent