ndwarshuis / org-sql

SQL backend for Emacs Org-Mode
GNU General Public License v3.0
100 stars 9 forks source link

Timestamp from headline doesn't land in timestamps table #22

Closed aviav closed 3 months ago

aviav commented 4 months ago

Often, I put my timestamps in headlines. It seems these timestamps don't make it to the timestamps table.

This is a pre-check if a) my practice is bad and I should change it, or b) there's some other reason why headlines are an exception when it comes to timestamps, when considering either org-mode or org-sql, or c) this cannot be reproduced.

In case you can answer a), b), and c) with 'no', I'd prepare a pull request at some point. In case of a 'yes', I'd be eager to learn and then possibly consider to change my practice of putting timestamps in headlines.

Great package by the way, thanks a lot!

ndwarshuis commented 4 months ago

By "timestamps in headlines" do you mean something like this?

* headline with timestamp at [1976-04-01 Thu]
etc
etc
etc

If so that's not currently supported, since (to me at least) this seems like a narrow edge-case.

It won't be hard to add, however, since the timestamp node should already be parsed and sitting in the :title property of the headline. It would probably also require a flag in the timestamps table indicating if it is in the headline or the contents (since now all the timestamps are in the contents, ie the stuff beneath the headline).

aviav commented 4 months ago

Yes, this is what I mean. As soon as I need it for one of the org files that I push to the database, I'll look into adding what you describe.

Thanks for the input!

aviav commented 3 months ago

I took a first shot at implementing this in #26, which also includes the two small fix PRs I made earlier.

I haven't added a flag regarding where the timestamp is coming from, because I don't understand the purpose of such a flag yet. Is it a goal of org-sql to be able to reconstruct an org file from SQL? This was the most likely purpose that occurred to me.

In case the flag that denotes timestamp origin is indeed required, I'd appreciate it if I knew the intended purpose. As soon as I know it, or at least know that it's really needed, I'll make that change.

Otherwise, #26 would be ready for review. I'm very open for change suggestions, especially since this would be my first Emacs Lisp code that goes beyond the Emacs Lisp tutorial and my editor's config.

PS: As to my reason for using timestamps in headline titles: It's the most convenient place for timestamps that I frequently edit manually, which I do for repeating appointments that are only somewhat regular. This way, I can skip from title to title and don't have to deal with headline contents

aviav commented 3 months ago

Just to be sure, I checked the Org Manual on timestamps. It states 'A timestamp can appear anywhere in the headline or body of an Org tree entry. Its presence causes entries to be shown on specific dates in the agenda[...].'

So it seems to me there's no semantic difference between timestamps occurring in the headline vs. body of an entry, as far as Org Mode is concerned. The difference that I found is that DEADLINE/SCHEDULE don't appear to work with timestamps that are in the headline/title. But I think this doesn't lead to a requirement of tracking where the timestamp came from

ndwarshuis commented 3 months ago

fixed with https://github.com/ndwarshuis/org-sql/pull/26