diff --git a/src/actions/base.js b/src/actions/base.js
index e9ff2d0ce..9dfe49c10 100644
--- a/src/actions/base.js
+++ b/src/actions/base.js
@@ -102,6 +102,11 @@ export const setShouldLogIntoDrawer = shouldLogIntoDrawer => ({
shouldLogIntoDrawer,
});
+export const setShouldNotIndentOnExport = shouldNotIndentOnExport => ({
+ type: 'SET_SHOULD_NOT_INDENT_ON_EXPORT',
+ shouldNotIndentOnExport,
+});
+
export const setShouldStoreSettingsInSyncBackend = newShouldStoreSettingsInSyncBackend => {
return (dispatch, getState) => {
dispatch({
diff --git a/src/actions/org.js b/src/actions/org.js
index 5d51a5696..d7b7bf5a8 100644
--- a/src/actions/org.js
+++ b/src/actions/org.js
@@ -112,7 +112,8 @@ const doSync = ({
getState().org.present.get('headers'),
getState().org.present.get('todoKeywordSets'),
getState().org.present.get('fileConfigLines'),
- getState().org.present.get('linesBeforeHeadings')
+ getState().org.present.get('linesBeforeHeadings'),
+ getState().base.get('shouldNotIndentOnExport')
)
)
.then(() => {
diff --git a/src/components/OrgFile/OrgFile.unit.test.js b/src/components/OrgFile/OrgFile.unit.test.js
index 53aaeec3f..5eafb25e8 100644
--- a/src/components/OrgFile/OrgFile.unit.test.js
+++ b/src/components/OrgFile/OrgFile.unit.test.js
@@ -13,14 +13,21 @@ import { fromJS } from 'immutable';
* This is a convenience wrapper around parsing an org file using
* `parseOrg` and then export it using `exportOrg`.
* @param {String} testOrgFile - contents of an org file
+ * @param {Boolean} dontIndent - by default false, so indent drawers
*/
-function parseAndExportOrgFile(testOrgFile) {
+function parseAndExportOrgFile(testOrgFile, dontIndent = false) {
const parsedFile = parseOrg(testOrgFile);
const headers = parsedFile.get('headers');
const todoKeywordSets = parsedFile.get('todoKeywordSets');
const fileConfigLines = parsedFile.get('fileConfigLines');
const linesBeforeHeadings = parsedFile.get('linesBeforeHeadings');
- const exportedFile = exportOrg(headers, todoKeywordSets, fileConfigLines, linesBeforeHeadings);
+ const exportedFile = exportOrg(
+ headers,
+ todoKeywordSets,
+ fileConfigLines,
+ linesBeforeHeadings,
+ dontIndent
+ );
return exportedFile;
}
@@ -40,25 +47,25 @@ describe('Tests for export', () => {
test('Simple description export of empty description works', () => {
const description = '';
const header = createSimpleHeaderWithDescription(description);
- expect(createRawDescriptionText(header, false)).toEqual(description);
+ expect(createRawDescriptionText(header, false, false)).toEqual(description);
});
test('Simple description export of empty line works', () => {
const description = '\n';
const header = createSimpleHeaderWithDescription(description);
- expect(createRawDescriptionText(header, false)).toEqual(description);
+ expect(createRawDescriptionText(header, false, false)).toEqual(description);
});
test('Simple description export of non-empty line works', () => {
const description = 'abc\n';
const header = createSimpleHeaderWithDescription(description);
- expect(createRawDescriptionText(header, false)).toEqual(description);
+ expect(createRawDescriptionText(header, false, false)).toEqual(description);
});
test('Simple description export of non-empty line without trailing newline works (newline will be added)', () => {
const description = 'abc';
const header = createSimpleHeaderWithDescription(description);
- expect(createRawDescriptionText(header, false)).toEqual(`${description}\n`);
+ expect(createRawDescriptionText(header, false, false)).toEqual(`${description}\n`);
});
});
@@ -372,6 +379,12 @@ ${description}`;
expect(exportedFile).toEqual(testOrgFile);
});
+ test('Properties are flush-left when dontIndent is true', () => {
+ const testOrgFile = readFixture('properties');
+ const exportedLines = parseAndExportOrgFile(testOrgFile, true).split('\n');
+ expect(exportedLines[2]).toEqual(':PROPERTIES:');
+ });
+
test('Tags are formatted as is default in Emacs', () => {
const testOrgFile = readFixture('tags');
const exportedFile = parseAndExportOrgFile(testOrgFile);
@@ -385,6 +398,18 @@ ${description}`;
const exportedFile = parseAndExportOrgFile(testOrgFile);
expect(exportedFile).toEqual(testOrgFile);
});
+ test('Logbook entries are indented by default', () => {
+ const testOrgFile = readFixture('logbook');
+ const exportedLines = parseAndExportOrgFile(testOrgFile).split('\n');
+ expect(exportedLines[1]).toEqual(' :LOGBOOK:');
+ expect(exportedLines[2].startsWith(' CLOCK:')).toBeTruthy();
+ });
+ test('Logbook entries are not indented when dontIndent', () => {
+ const testOrgFile = readFixture('logbook');
+ const exportedLines = parseAndExportOrgFile(testOrgFile, true).split('\n');
+ expect(exportedLines[1]).toEqual(':LOGBOOK:');
+ expect(exportedLines[2].startsWith('CLOCK:')).toBeTruthy();
+ });
});
});
diff --git a/src/components/OrgFile/components/HeaderContent/index.js b/src/components/OrgFile/components/HeaderContent/index.js
index 155ea82b7..44fd61990 100644
--- a/src/components/OrgFile/components/HeaderContent/index.js
+++ b/src/components/OrgFile/components/HeaderContent/index.js
@@ -78,7 +78,8 @@ class HeaderContent extends PureComponent {
}
calculateRawDescription(header) {
- return createRawDescriptionText(header, false);
+ // this is for display only, se we keep the default indentation behaviour
+ return createRawDescriptionText(header, false, false);
}
handleTextareaRef(textarea) {
diff --git a/src/components/Settings/index.js b/src/components/Settings/index.js
index d9a151e3f..757c96734 100644
--- a/src/components/Settings/index.js
+++ b/src/components/Settings/index.js
@@ -21,6 +21,7 @@ const Settings = ({
shouldSyncOnBecomingVisibile,
shouldShowTitleInOrgFile,
shouldLogIntoDrawer,
+ shouldNotIndentOnExport,
agendaDefaultDeadlineDelayValue,
agendaDefaultDeadlineDelayUnit,
hasUnseenChangelog,
@@ -57,6 +58,9 @@ const Settings = ({
const handleShouldLogIntoDrawer = () => base.setShouldLogIntoDrawer(!shouldLogIntoDrawer);
+ const handleShouldNotIndentOnExport = () =>
+ base.setShouldNotIndentOnExport(!shouldNotIndentOnExport);
+
const handleShouldStoreSettingsInSyncBackendChange = () =>
base.setShouldStoreSettingsInSyncBackend(!shouldStoreSettingsInSyncBackend);
@@ -137,6 +141,22 @@ const Settings = ({
(setq org-adapt-indentation nil)
+
+ , then activate this setting. The raw content text is left unchanged.
+