From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Brent Goodrick <bgoodr@gmail.com>
Cc: emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <87ziezy1p2.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAJj=8EHMJwo4N+BkcpZaqB8xqtco_b759CNzt3NBsw8bBc6UdQ@mail.gmail.com> (Brent Goodrick's message of "Fri, 28 Apr 2017 08:29:03 -0700")
Hello,
Brent Goodrick <bgoodr@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. 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
next prev parent reply other threads:[~2017-04-29 9:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-03 4:15 org-src--contents-for-write-back : preserve original major-mode, and avoid mixing tabs and spaces in org-mode buffers Brent Goodrick
2017-04-22 8:41 ` Nicolas Goaziou
2017-04-23 3:21 ` Brent Goodrick
2017-04-27 23:04 ` Nicolas Goaziou
2017-04-28 15:29 ` Brent Goodrick
2017-04-29 9:59 ` Nicolas Goaziou [this message]
2017-04-29 16:41 ` Brent Goodrick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ziezy1p2.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=bgoodr@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).