organice icon indicating copy to clipboard operation
organice copied to clipboard

Default for org-adapt-indentation has changed in Org 9.5

Open schoettl opened this issue 1 year ago • 5 comments

This is intended behavior, since this is the default Emacs Org mode indentation style.

Since Org 9.5, the default value of org-adapt-indentation has changed to nil. So now, the Org mode default is to not indent anything (including drawers). In Org 9.4 the default was t (indent everything, including text).

I just wanted to bring this to attention. For now, I have not enough time to learn JavaScript to work on it.

Originally posted by @whxvd in https://github.com/200ok-ch/organice/issues/121#issuecomment-1183603468

Thanks for bringing this up. I hated the auto-indent and I'm glad the default is now nil! It was really bad for version control.

Reference: https://orgmode.org/Changes.html

@munen I'd quickly fix the default but I can't find it. The closest thing is here:

./src/util/settings_persister.js:160:    name: 'shouldNotIndentOnExport',

but this specific option has no default key like some of the others.

schoettl avatar Jul 13 '22 19:07 schoettl

I guess because shouldNotIndentOnExport has no default defined, it defaults to false => indentation.

I just got the case again where a new colleague messed up whitespaces in our shared org files with organice.

@munen Is it alright when we catch up with org-mode now, and set the default to true? I can provide a PR.

schoettl avatar Oct 21 '22 08:10 schoettl

Hi @schoettl,

I'm in favor of configuring defaults in the organice settings the same as for Emacs Org mode. It is my understanding from https://orgmode.org/Changes.html that the default is nil for org-adapt-indentation since Org mode 9.5. I double checked with a clean install of Emacs and Org mode 9.5.2 which confirms it:

image

Still, I understand your use-case. You want all team members to conform to the same defaults. Maybe we could add a new feature 'team profile'. I'm just thinking aloud here. It could be a link to a remote .organice-config.json file. It could either provide other defaults or completely override the users file (super corporate style).

What do you think?

Kind regards, Alain

munen avatar Oct 21 '22 10:10 munen

I think this is a misunderstanding:

  • if org-adapt-indentation is t, the indentation level is adapted. But it's now nil by default.
  • if shouldNotIndentOnExport is true, it does not adapt the indentation level.

So my understanding is that these options are inverted in Org and organice.

Regarding the .organice-config.json, I have some problems with it (#895).

schoettl avatar Oct 21 '22 11:10 schoettl

I think this is a misunderstanding:

  • if org-adapt-indentation is t, the indentation level is adapted. But it's no nil by default.
  • if shouldNotIndentOnExport is true, it does not adapt the indentation level.

So my understanding is that these options are inverted in Org and organice.

You are correct! My apologies for not reading it properly through.

Now that I understand it, and have tested the setting in Emacs and organice and have a follow-up question: Setting the flag in Emacs has a different effect than in organice. The reason is that organice parses an Org file on startup and later transforms the internal representation back to an Org file. Hence, setting the flag in Emacs will result in a change only for future headlines, leaving the indentation the same for all existing headlines. Whereas making the switch in organice will re-indent all files for all users who haven't explicitly set the setting before. Since it will affect most users and create big diffs, I would say this is a regression. If we invert the meaning of the flag (and align it with Emacs) and set the default to false, we won't have this regression, correct?

As for the PR, I see these tasks:

  • [ ] Rename the option in organice, or at least invert the boolean meaning so that it is aligned with Emacs. If I can make this mistake, others can, too.

  • [ ] If need be, write a migration so that there's no regression. It is my understanding that this is not required if we do it as described above.

  • [ ] Make a changelog entry.

Does that sound right?

Regarding the .organice-config.json, I have some problems with it (#895).

I'll answer there.

munen avatar Oct 21 '22 12:10 munen

Hm, I don't quite understand. Yes, there is the difference between Org and organice that you described (apart from the inversion).

Fixing organice to adapt indentation only for new text would be more work. I can't do that and I'd rather keep organice's behaviour but align with Org's default.

Changing the default and renaming the option to align with Org would need a migration strategy, I think, because user that currently have indentation enabled probably want to keep this.

Is there a problem when we only change the default? Current users have organice config files so they wouldn't be affected as long as they don't delete the config or start a new Dropbox. I think that would be acceptable.

New users would get "a sane default".

Note that in organice, shouldNotIndentOnExport (and dontIndent) always adjust indentation, it does not keep original indentation. Example:

    contents += `${indentation}:PROPERTIES:\n`;
    contents += `${propertyListItemsContent}\n`;
    contents += `${indentation}:END:\n`;

We could change the UI to invert the option. But I'm not sure if it's worth to rename the option internally and write a migration.

schoettl avatar Oct 23 '22 11:10 schoettl