Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg: (-with-inhibit-read-only) Don't modify buffer-undo-list
Resolves nobiot#177 by making `org-transclusion-add` and `org-transclusion-remove` not affect the buffer undo history.
- Loading branch information
ac40d2a
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.
Oops! This doesn't actually solve the problem.
ac40d2a
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 could be problematic because the user expects an undo operation to act as
org-transclusion-remove
somewhat -- although it doesn't function as such since org-transclusion-remove also does operations on the source buffer too -- removing overlays and so on;I thought of this idea too - but abandoned it since this could result in problems elsewhere. Particularly in how user expects transclusions to function.
ac40d2a
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.
@akashpal-21 IMO
undo
andundo-redo
should not act asorg-transclusion-remove
. I think transclusions should not be considered buffer modifications, but rather a different way to view the same buffer contents. What do you think?ac40d2a
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.
I agree with you - but it won't be as direct as just blocking writing entries to the
buffer-undo-list
.Transclusions are simply yanking text from another buffer with some extra steps -- which means they make buffer modifications - so we have to update the org environment nevertheless with the changes we have made else we would be corrupting positional pointers - if we have to really make transclusions invisible to the
buffer-undo-list
we have to block entries in strategic positions and not turn it off for the entire duration.We could block entirely for the save-buffer protocol because we make changes and their inverses as part of the same operation, so it works there - but wouldn't work for
org-transclusion-add
andorg-transclusion-remove
so easily.It could nevertheless be done if we desire as such.
ac40d2a
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.
When adding/removing tranclusions, which buffer modifications need to be included in
buffer-undo-list
?ac40d2a
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.
As a simple example consider the text:
(position x-1) #+transclude: [[something]]
(position x) Here is some text
When we do
(org-transclusion-add)
"Here is some text" is moved from position (x) to (x+d) where d is some deltaIn place of position x - there is now the transcluded text -- if we
undo
here - but this change is not recorded -- the undo will look for "Here is some text" in position x - but it doesn't exist here.ac40d2a
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.
@akashpal-21 Thank you for explaining! This is why we get
primitive-undo: Changes to be undone are outside visible portion of buffer
when we exclude transclusions from the undo history.