On Sat, Apr 29, 2017 at 2:59 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote: > Hello, > > Brent Goodrick <bgo...@gmail.com> 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