-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If startup option "nologrepeat" is set, don't log repeat information #119
Changes from 1 commit
9b9f859
3cf37ef
dd6bf0f
435591e
a3b64a8
7ef6c0c
aa8cbfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1033,73 +1033,80 @@ function updatePlanningItemsWithRepeaters( | |
newTodoState, | ||
currentTodoState | ||
) { | ||
{ | ||
indexedPlanningItemsWithRepeaters.forEach(([planningItem, planningItemIndex]) => { | ||
state = state.setIn( | ||
['headers', headerIndex, 'planningItems', planningItemIndex, 'timestamp'], | ||
applyRepeater(planningItem.get('timestamp'), new Date()) | ||
); | ||
}); | ||
indexedPlanningItemsWithRepeaters.forEach(([planningItem, planningItemIndex]) => { | ||
state = state.setIn( | ||
['headers', headerIndex, 'titleLine', 'todoKeyword'], | ||
currentTodoSet.get('keywords').first() | ||
['headers', headerIndex, 'planningItems', planningItemIndex, 'timestamp'], | ||
applyRepeater(planningItem.get('timestamp'), new Date()) | ||
); | ||
const startupOptNoLogRepeat = state | ||
.get('fileConfigLines') | ||
.some(elt => elt.match(/^#\+STARTUP:\s+nologrepeat/)); | ||
const loggingProp = inheritedValueOfProperty(state.get('headers'), headerIndex, 'LOGGING'); | ||
if ( | ||
!startupOptNoLogRepeat && | ||
!( | ||
loggingProp && | ||
loggingProp.some( | ||
v => v.get('type') === 'text' && v.get('contents').match(/\s*nologrepeat\s*/) | ||
) | ||
) | ||
) { | ||
const lastRepeatTimestamp = getCurrentTimestamp({ isActive: false, withStartTime: true }); | ||
const newLastRepeatValue = [ | ||
{ | ||
type: 'timestamp', | ||
id: generateId(), | ||
firstTimestamp: lastRepeatTimestamp, | ||
secondTimestamp: null, | ||
}, | ||
]; | ||
|
||
state = state.updateIn(['headers', headerIndex, 'propertyListItems'], propertyListItems => | ||
propertyListItems.some(item => item.get('property') === 'LAST_REPEAT') | ||
? propertyListItems.map(item => | ||
item.get('property') === 'LAST_REPEAT' | ||
? item.set('value', fromJS(newLastRepeatValue)) | ||
: item | ||
) | ||
: propertyListItems.push( | ||
fromJS({ | ||
property: 'LAST_REPEAT', | ||
value: newLastRepeatValue, | ||
id: generateId(), | ||
}) | ||
) | ||
); | ||
state = state.updateIn(['headers', headerIndex], header => { | ||
let rawDescription = header.get('rawDescription'); | ||
if (rawDescription.startsWith('\n')) { | ||
rawDescription = rawDescription.slice(1); | ||
} | ||
rawDescription = | ||
`\n- State "${newTodoState}" from "${currentTodoState}" ${renderAsText( | ||
fromJS(lastRepeatTimestamp) | ||
)}\n` + rawDescription; | ||
return header | ||
.set('rawDescription', rawDescription) | ||
.set('description', parseRawText(rawDescription)); | ||
}); | ||
} | ||
}); | ||
state = state.setIn( | ||
['headers', headerIndex, 'titleLine', 'todoKeyword'], | ||
currentTodoSet.get('keywords').first() | ||
); | ||
if (noLogRepeatEnabledP({ state, headerIndex })) { | ||
const lastRepeatTimestamp = getCurrentTimestamp({ isActive: false, withStartTime: true }); | ||
const newLastRepeatValue = [ | ||
{ | ||
type: 'timestamp', | ||
id: generateId(), | ||
firstTimestamp: lastRepeatTimestamp, | ||
secondTimestamp: null, | ||
}, | ||
]; | ||
|
||
state = state.updateIn(['headers', headerIndex, 'propertyListItems'], propertyListItems => | ||
propertyListItems.some(item => item.get('property') === 'LAST_REPEAT') | ||
? propertyListItems.map(item => | ||
item.get('property') === 'LAST_REPEAT' | ||
? item.set('value', fromJS(newLastRepeatValue)) | ||
: item | ||
) | ||
: propertyListItems.push( | ||
fromJS({ | ||
property: 'LAST_REPEAT', | ||
value: newLastRepeatValue, | ||
id: generateId(), | ||
}) | ||
) | ||
); | ||
state = state.updateIn(['headers', headerIndex], header => { | ||
let rawDescription = header.get('rawDescription'); | ||
if (rawDescription.startsWith('\n')) { | ||
rawDescription = rawDescription.slice(1); | ||
} | ||
rawDescription = | ||
`\n- State "${newTodoState}" from "${currentTodoState}" ${renderAsText( | ||
fromJS(lastRepeatTimestamp) | ||
)}\n` + rawDescription; | ||
return header | ||
.set('rawDescription', rawDescription) | ||
.set('description', parseRawText(rawDescription)); | ||
}); | ||
} | ||
return state; | ||
} | ||
|
||
/** | ||
* Is the `nologrepeat` feature enabled for this buffer? | ||
* More info: | ||
* https://www.gnu.org/software/emacs/manual/html_node/org/Repeated-tasks.html | ||
*/ | ||
export function noLogRepeatEnabledP({ state, headerIndex }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I was actually thinking about this name for a moment when I had the same idea as you^^ I'm not super happy about the name, because it's quite long, but here's my thought process: The native Org feature is called Atm it's kinda hard to read and if I would do it from scratch, I'd call the feature "logrepeatenabled", but Org mode has prior art here(; On the other hand, having you trip up over the same naming issue that I was already thinking about is not a great argument for the name. So I'm open for a change if after reading this you have a strong fealing it woud be better the other way around! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we keep the name, but invert what it returns, so when nologrepeat is set it returns true? That way we keep the name, but it reads a bit more naturally; e.g. the check for logging the repeat information would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, my, of course! It's a little late for me here, I apologize. I should take a break, maybe(; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😄 Can't hurt! I can make that change & push it up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet! Also thanks for adding the test for detecting via properties. I was just starting to type that one in when I got the notification about your commit(; I'll happily pull the changes in when you ping me. |
||
const startupOptNoLogRepeat = state | ||
.get('fileConfigLines') | ||
.some(elt => elt.match(/^#\+STARTUP:.*nologrepeat.*/)); | ||
const loggingProp = inheritedValueOfProperty(state.get('headers'), headerIndex, 'LOGGING'); | ||
return ( | ||
!startupOptNoLogRepeat && | ||
!( | ||
loggingProp && | ||
loggingProp.some( | ||
v => v.get('type') === 'text' && v.get('contents').match(/\s*nologrepeat\s*/) | ||
) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Function wrapper around `updateCookiesOfHeaderWithId` and | ||
* `updateCookiesOfParentOfHeaderWithId`. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* TODO Header with repeater | ||
SCHEDULED: <2019-11-27 Wed +1d> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#+STARTUP: nologrepeat | ||
|
||
* TODO Header with repeater | ||
SCHEDULED: <2019-11-27 Wed +1d> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#+STARTUP: showeverything nologrepeat | ||
|
||
* TODO Header with repeater | ||
SCHEDULED: <2019-11-27 Wed +1d> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains only whitespace change from prettier and can be ignored during the review. Sorry for that.