-
Notifications
You must be signed in to change notification settings - Fork 42
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
support multi-line notes in logbook entry #4
Conversation
As of now, the bulk of it works, but 2 tests are failing, and I'm stumped. @nevenz could you pull it down and take a look? The bulk of it are indentation issues, which I can't seem to resolve:
FWIW I think the latter has to do with some special handling for org-indent-mode which wasn't carried over to logbooks |
These failures look good to me. As in - code wins and tests need to be updated. testParserHook failed because LOGBOOK is not part of the content anymore, so it needs to be indented, which is what (properly) happened. testRich1 failed because of some trailing spaces after |
@@ -42,4 +42,7 @@ | |||
public static final Pattern HEAD_TAGS_P = Pattern.compile("^(.*)\\s+:(\\S+):\\s*$"); | |||
|
|||
public static final Pattern PROPERTY = Pattern.compile("^:([^:\\s]+):\\s+(.*)\\s*$"); | |||
|
|||
public static final Pattern LOGBOOK_NOTE_P = Pattern.compile("^- Note taken on " + DT); |
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.
@nevenz I don't like this regexp: in particular it doesn't match the full line. I couldn't seem to add anything after DT
, that would cause the regexp to fail matching everything. Any ideas?
Cleaned up the tests so that they pass, I think my next PR will be setting up travis to run the tests. |
@nevenz i've fixed the bad regex, and added some unit tests, I think this is good to go now. |
We should try to handle some badly formatted drawers. I've made a mess of my files quite a few times either by entering random command by accident or misplacing characters. For example - missing
These should be two notes, I think? Or having Also, the other way around - when something should be part of the note, but it isn't:
Perhaps user wanted a list inside a note (...inside the note). Remembering There are probably more cases like this, we should try adding tests for anything crazy that comes to mind. It can get tricky, but the top priority is that no data is lost. Worst case - drawer (or what we think it might be drawer, but couldn't quite get there) ends up being part of the content, like right now. So if we don't know how to handle something, we simply fall back to that. BTW, can we do without |
I think I handle this already, but I shall add test cases for these.
I'm not sure we want to be so resilient with parsing on these malformed drawers. This can lead to a lot of complexity. I'll handle the second case you brought up though.
This should already be handled properly. Anything that fails to get picked up ends up as a generic string logbook entry. Anything that gets picked up has a 1-1 mapping between the object and the text representation.
I'm not too worried about this, because the read ahead is at max a line ahead. That said, this was the most elegant solution I can think of. I don't actually really know Java, so if you know a better way let me know. |
@nevenz is this alright? |
I'll see if I can come up with tests that are failing, if not I'll merge it. One thing we'll need is a method for adding the latest log entry to Also, this is breaking app currently if used, so I'll remove the usage of local directory from Orgzly for now, so it doesn't confuse people. |
Is
How so? Are there integration tests in orgzly for this that I can look at? |
No,
As a user, I'd be wondering:
Random thoughts/suggestions:
Anyway, let me know what you think.
Anything that's using a database and has notes with LOGBOOK - two tests in Orgzly keeps This is expected and fine, it's why I bumped org-java version to 1.2. But Orgzly can't use the new version before it either starts storing This is what I meant by:
It's probably easier to just prepend the content for now. |
Yes, I don't think this needs to be exposed.
We could probably use a linked list, with a pointer to the end? Or maybe just maintain consistency with how other drawers are currently being implemented. I think as an internal representation having them in chronological order is alright.
If the latter meaning is wanted (check if has entries), then the function should be renamed to
Should be beginning, just like how org does it I believe.
Yes, that's fine by me too, for now. |
@nevenz i'm not sure about the latest changes I made. There are tests to be written, but I want to be sure that it's okay before I proceed.
Because of this we need to rethink the API for logbooks in AFAIK, the only thing we need in there is whether the logbook exists. However, this entails |
1 and 2 sounds good to me.
I suggest adding "addLogbookEntry" to For parser it doesn't matter that much, but user (app) shouldn't have to init + get + add. |
@nevenz is this ok? One thing to consider is how the internal representation -> text logic is not within the class itself. It's hard to move it in, considering it's not entirely dependent on the class itself, having additional properties like indentation. |
There could be I'll check what needs to be done on Orgzly side for this to be used. |
@nevenz any updates on how we could make this work? |
I'm updating the app to target Oreo, I'll get back to this as soon as that's done. |
sure 😄 no hurry |
I was looking to merge this, but I don't think this will work the way we planned. 😭 LOGBOOK can be in the middle of the content, which is perfectly valid (notes are added to it, state changes are recorded, etc.). Which means content must be left alone. We can't extract LOGBOOK from it, because we won't know where to put it back. Users might not want it at the beginning of the content. This is different from planning times or properties, which do have their own special place in the note. But it's similar to plain timestamps (#7) for example. So we can do it the same way and have:
Does that make sense? |
The issue makes sense, and is indeed a blocker for merging. I fail to see how this helps us figure out how to convert this I think I'll wait for #7 to settle, before making further changes. |
I'm just thinking out loud when I ask... |
@keithcrone The end goal was clocking, which involves logging state changes. |
I'm just throwing it out there...
Couldn't you treat a :LOGBOOK: (or any drawer) as a sibling to the note
text, or sandwiched between multiple note text?
* Heading1 :tag:
<Scheduled> <Deadline>
:Properties:
Body text
:LOGBOOK:
Body text
Couldn't you treat them as three seperate entries in the DB and rebuild
them accordingly on export? From a GUI perspective, you can make the
Logbook foldable like any other entry and allow it to be moved up or down
(restricting it to movement amongst it's siblings and not outside the note
body). Maybe make the note areas clickable by themselves instead of part of
the note edit screen?
Does that make sense? Breaking up areas as seperate pieces?
On Jan 20, 2018 20:37, "Jethro Kuan" <notifications@github.com> wrote:
@keithcrone <https://github.com/keithcrone> The end goal was clocking,
which involves logging state changes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AZ17nCGUSGTStB-U50a3pFluvsiPfa_Rks5tMqLugaJpZM4Q0ugU>
.
|
@keithcrone thanks for the input. I think having sibling content entries within OrgContent is ideal for the parser, kind of like how This parser is primarily a per-line parser. We could do a one line look-ahead, as I'm doing with multi-line logbook entries right now, but that felt a little out-of-place. Do you have a better idea of how to achieve the same result cleanly? |
What are you going to do with the LOGBOOK data that you need to parse all of it? |
Parsing all of My concerns are with how a logbook drawer can fit into the larger picture. There can be multiple logbook drawers under an org heading. Does a logbook drawer only belong to the content right above it? If so, should we encode this information in the internal representation? If I had a logbook drawer in the middle of a piece of content, when I perform an org-clock-in would a new drawer be created? All these must be designed to be completely aligned to how Org works in Emacs. |
Right, which I guess is more my point. With all that said, it doesn't seem like you need to parse the entire LOGBOOK if you're only interested in inserting your CLOCK times into here:
Which is why I asked if you were going to do anything with all the entries in LOGBOOK. It seems like a lot of work and uncertainty to parse and rebuild the drawer when there are a dizzying number of ways this could go wrong. Again, I'm just thinking out loud, so don't let me dissuade you if you have a plan in mind. I'm picturing my use, which is someone who doesn't use CLOCK but takes a lot of notes in multiple drawers that aren't named LOGBOOK. |
I think this is a healthy level of discussion, I'm taking all your points into consideration.
I'd like to make sure my work is extensible to this use case as well.
Yes, I agree, this would be outside the scope of my PR as well. All I'm trying to do is ensure that LOGBOOK has an appropriate internal representation, and can be converted accurately back to its textual representation.
Is this true? It seems to me that even
Hmm, this actually isn't too hard, we can add this in when the need arises I guess.
I hear you... but...
Like I mentioned above, I don't think this would really be an issue. Everything should just work now, and support for new kinds of logbook entries should be simple, by subclassing LogbookEntry! The uncertainty I have is not with parsing the LOGBOOK drawer itself, but where LOGBOOK should be. From what I understand now, the hierarchy would look something like this:
Where |
I'm sorry for sounding repetitive, but you still aren't really answering my question. When I'm using Orgzly and I need to take a note in one of my drawers, I use a text expand type app. I open the heading, edit the text, insert a blank line under the drawer name, and after a couple of keys, the text expands into "-Note was taken on ..." with full date and time and slashes at the end. Cursor positions automatically to the next line and I start banging away at my note. The point is: I don't need to know anything else about the rest of the content of the drawer. I'm in complete control of the information placement, in the drawer of my choice, with literally just a key press. Unless you're planning on actually doing something with the information inside a drawer, you can create the simplest solution with just a few buttons in all the empty space on the note edit screen. |
Sorry if I didn't make myself clear -- let me address your concerns directly. There are 2 broad considerations:
You are saying that there is no need to parse the logbook if my intentions were to simply add a new CLOCK entry into the LOGBOOK. You are absolutely right. It is correct to say I only need to identify where the drawer starts, and insert the clock entry at the top of the drawer. Hence, (2) is not necessary. In fact, prior to this PR, Logbook was represented as an array of lines, precisely how you expect it to be. What I've been trying to get at is that (2) is already implemented in this PR. This all works out very well, and would've been merged in. What is blocking this PR is (1), with the issues that @nevenz has raised. |
Sounds like the time for healthy discussion may have passed. Good luck, I hope you figure it out. |
@keithcrone Thanks, sorry if i offended you in any way, that was never my intention. |
I think we just keep the content as it is, no extracting anything from it and no rebuilding. @keithcrone's idea about breaking content to separate pieces by type is interesting and could be used as kind of optimization inside Clocking in/out, adding state changes etc. are all methods that can be in
Folding drawer is another thing too keep in mind. But that's mostly Orgzly's job. It will need to be able to get the location of the drawer from this library. This PR could be saved by removing most code from parser and writer I guess. And modifying methods for adding entries to deal with |
Sorry for the inactivity, I'm afraid I have to push this back quite a bit, I don't have the time to work on this at the moment. |
That's fine, thanks for all the work so far. There's a lot of good points in this discussion too. |
This PR sets the stage for parsing of logbook entries. The goal is to enable logbook parsing, whie ensuring the existing tests pass.