Skip to content

fix(agenda): make spans work like emacs #915

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

sahinf
Copy link
Contributor

@sahinf sahinf commented Mar 3, 2025

Summary

This PR adds.. Core feature parity with emacs agenda views. All view changes should take into account the cursor position.

Currently, view month and view day both shift the cursor to and start the view's span from the start day (Monday by default). In emacs, all view changes take into account the agenda date that the cursor is on, and then choose the start date accordingly. These changes aim to mimic emacs behavior by

  1. modifying all view changes to stop moving the cursor
  2. displaying the week number in all spans types
  3. change the first day of the view to be the first day of the span

Changes

  1. modifying all view changes to stop moving the cursor
  2. displaying the week number in all spans types
  3. change the first day of the view to be the first day of the span

To expand on 3, month view should change the view to start with the first day of the month that the user's cursor is on when the changing spans. I verified that this behavior is consistent with all views in emacs. It's also the behavior that I would expect when changing views.

I additionally added a day-of-the-year tracker next to the week-of-the-year tracker.

Checklist

I confirm that I have:

  • [ x ] Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • [ x ] My PR title also follows the conventional commits specification.
  • [ x ] Updated relevant documentation, if necessary.
  • [ x ] Thoroughly tested my changes.
  • [ x ] Added tests (if applicable) and verified existing tests pass with
    make test.
  • [ x ] Checked for breaking changes and documented them, if any.

@kristijanhusak
Copy link
Member

Emacs parity with jumping to the next week/month should already be in place
For week view, if you put a cursor on Wednesday for example, it should keep the cursor on Wednesday on each next/prev span.
On month view, it should jump to the exact day of month. For year, it should jump to exact day and month.

If that's not working, let me know how to reproduce.

Regarding the week number, that's fine, we can add that.

@sahinf
Copy link
Contributor Author

sahinf commented Mar 3, 2025

You're right, the cursor does already follow the date as spans change. But the view span still isn't the same as with emacs. You can reproduce by switching to month view from week view on emacs and on orgmode.nvim. Notice the first entry in the agenda. In emacs, it will be the first day of the month the cursor was on. In orgmode.nvim, it will be the first day of the week (Monday on my end) instead. Scroll to a later week in the month and switch back to week view. Notice that in emacs, the new week view will start with the day of the week right before the day the cursor was on. While on orgmode.nvim it will go to the first week showing in the month view.

And the same for day view and year view. Switching to day view always goes to Monday for me when I expect it remain on the day my cursor was on like in emacs.

Let me know if this doesn't make sense I will try to record it.

Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! Now I understand what you mean.
I left few comments, and once addressed this is good to go.

Currently, view month and view day both shift the cursor to and start
the view's span from the start day (Monday by default). In emacs, all
view changes take into account the agenda date that the cursor is on,
and then choose the beginning date accordingly. These changes aim to
mimic emacs behavior by
1. modifying all view changes to stop moving the cursor
2. displaying the W number in all spans types
3. change the first day of the view to be the first day of the span

Reuse existing function OrgDate:start_of(span)

Ensure start is on user configured start week for initial
week view as well

Co-authored-by: Kristijan Husak <[email protected]>
@sahinf sahinf force-pushed the fix-agenda-view branch from a9292c7 to 05bf0e8 Compare March 5, 2025 12:51
Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@kristijanhusak kristijanhusak merged commit 88c71f3 into nvim-orgmode:master Mar 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants