emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Brent Goodrick <bgoodr@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
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 09:41:07 -0700	[thread overview]
Message-ID: <CAJj=8EHhMaZ9qo86ximHh4DLvdC3hLibzRJ2PGAVEAYNKsVNVQ@mail.gmail.com> (raw)
In-Reply-To: <87ziezy1p2.fsf@nicolasgoaziou.fr>

On Sat, Apr 29, 2017 at 2:59 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> 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.

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

      reply	other threads:[~2017-04-29 16:41 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
2017-04-29 16:41           ` Brent Goodrick [this message]

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='CAJj=8EHhMaZ9qo86ximHh4DLvdC3hLibzRJ2PGAVEAYNKsVNVQ@mail.gmail.com' \
    --to=bgoodr@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).