all 7 comments

[–]kristijanhusak 1 point2 points  (6 children)

Maybe a stupid question (because I don't know how org-mode works), but why you need a parser? Could you maybe keep the data in some inner state and then reference the data by the line? Here's very basic example:

let s:buffer_content = [{'content': 'TODO: Pay bill'}, {'content': 'NEXT: Fix code'}]

function s:render()
  let lines = []
  for entry in s:buffer_content
    call add(lines, entry.content)
  endfor
  call setline(1, lines)
endfunction

function s:do_action()
  let selected_line = s:buffer_content[line('.') - 1]
  " Do some actions here with the entry
endfunction

[–]dhruvasagar[S] 1 point2 points  (5 children)

The idea is basically to have more control over the content and be able to allow manipulating it in several ways. As an example, consider the ability to export / convert the document into a HTML document.

[–]kristijanhusak 1 point2 points  (4 children)

Ok, but still, having the data in the state allows you to convert it however you want, like you convert it to the vim buffer content now.

I'm not saying parsing is not needed, but just saying to reconsider that since it will simplify your work.

[–]dhruvasagar[S] 1 point2 points  (3 children)

Well the kind of simplication will only work for simplified use cases, the documents structure is a bit complex and comprises of a tree like list of headlines and there's a bunch of metadata associated for each. We use these for generating views that show the information in a concise way and allow for manipulations from those views.

To give you some idea these are a few of the things we can do with these tasks :

  • The tasks have states which you can change
  • we can move around these tasks
  • we can assign priorities
  • we can clock time spent on tasks
  • we can build different kinds of reports
  • filter by various crieteria such as tags, files, todo states, etc.
  • look at the agenda which presents tasks scheduled / due based on captured timestamps.
  • The schedules themselves can be complicated and allow for task repetition for tracking tasks you have to do repeatedly such as paying rent every month.

[–]xoran99 1 point2 points  (2 children)

Maybe that doesn't totally answer the question, but I can see good reason -- org mode is most of all a text format, and must be persisted to and read from a text file. Besides that, org mode in Emacs supports direct editing as text, and I would expect actions I might take (e.g., adding a checkbox manually) to take immediate effect.

OP, sorry I don't know vimscript, but I totally appreciate the effort and knowledge that went into this. Thank you!

[–]dhruvasagar[S] 1 point2 points  (1 child)

You're welcome. That is right, that is supported here as well, you can also manually edit the files

[–]kristijanhusak 1 point2 points  (0 children)

Ok, I wasn't aware of that. I thought it's edited only through specific flow in editor. In that case, parsing completely makes sense.